Ver Fonte

快手-应用创建修改

yumeng há 5 anos atrás
pai
commit
ca5bc1f4ea

+ 19 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/service/impl/KuaishouInterfaceServiceImpl.java

@@ -1,12 +1,13 @@
 package org.jeecg.modules.kuaishou.service.impl;
 
-import cn.com.ctop.common.utils.*;
+import cn.com.ctop.common.utils.Check;
+import cn.com.ctop.common.utils.HttpUtils;
+import cn.com.ctop.common.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.entity.*;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -18,9 +19,9 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.TypeFactory;
 import constant.KuaishouInterfaceConstant;
-import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.http.ParseException;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.FileMD5Util;
 import org.jeecg.common.util.LoadFileUtil;
 import org.jeecg.modules.kuaishou.entity.*;
 import org.jeecg.modules.kuaishou.mapper.*;
@@ -41,7 +42,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -1023,7 +1023,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             ArrayList<String> strArray = new ArrayList<String>();
             strArray.add(photoId);
             param.put("photo_ids", strArray);
-            Map<String, String> headers = new HashMap<String, String>();
+            Map<String, String> headers = new HashMap<>();
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
@@ -1368,16 +1368,26 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     public Map<String, Object> urlAppCreate(Long accountId, String accessToken, JSONObject apkJson) {
         Map<String, Object> returnMap = new HashMap<>();
         try {
+            String appUrl = apkJson.getString("url");
+            String appVersion = apkJson.getString("app_version");
+            String appName = apkJson.getString("app_name");
+            QueryWrapper<KuaiShouAppCreate> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_id", accountId).eq("url", appUrl).eq("app_version", appVersion).eq("app_name", appName).orderByDesc("create_time");
+            queryWrapper.last("limit 1");
+            KuaiShouAppCreate kuaiShouAppCreate = appCreateMapper.selectOne(queryWrapper);
+            if (!Check.isNull(kuaiShouAppCreate)) {
+                returnMap.put("code", 0);
+                returnMap.put("message", "文件已上传");
+                returnMap.put("success", true);
+                returnMap.put("appId", kuaiShouAppCreate.getAppId());
+                return returnMap;
+            }
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_CREATE;
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", "multipart/form-data");
             apkJson.put("advertiser_id", accountId + "");
             String result = exceptInfoForRestTemplate(url, apkJson, headers, null);
-            System.err.println(apkJson);
-            System.err.println(url);
-            System.err.println(JSON.toJSONString(headers));
-
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(result)) {
                 Integer code = resultJson.getInteger("code");
@@ -1392,7 +1402,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         appCreate.setReturnUrl(dataJson.getString("url"));
                         appCreate.setAppId(dataJson.getLong("app_id"));
                         appCreate.setAppVersion(apkJson.getString("app_version"));
-
                         appCreate.setImageToken(apkJson.getString("image_token"));
                         appCreate.setAppName(apkJson.getString("app_name"));
                         int i = appCreateMapper.insert(appCreate);
@@ -1570,16 +1579,5 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         return null;
     }
 
-    public static void main(String[] args) throws IOException {
-        String path = "https://ctop-media.oss-cn-beijing.aliyuncs.com/06.13-%E5%8A%A8%E7%94%BB-%E5%A5%B3%E6%9C%8B%E5%8F%8B%E8%B7%9F%E6%88%91%E5%88%86%E6%89%8B-1566461277270.mp4";
-        String localUrl = LoadFileUtil.downLoadFromUrl(path, "D:\\file\\video");
-
-        try {
-            String s = DigestUtils.md5Hex(new FileInputStream(localUrl));
-            System.err.println(s);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
 
 }