Bläddra i källkod

KuaishouMaterialsLoadJob视频信息接口修改

hcst_sunzhen 5 år sedan
förälder
incheckning
16d340dd30

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java

@@ -242,5 +242,11 @@ public class KuaiShouController {
         kuaishouInterfaceService.getImageList(accessToken, advertiserId, new Date(), new Date(), 1);
     }
 
+    @RequestMapping("getVideoList")
+    public void getVideoList() {
+        String accessToken = "e8959cf08e59e78b91b22aa4ed593c00";
+        Long advertiserId = 1022694L;
+        kuaishouInterfaceService.getVideoList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
+    }
 
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -241,6 +241,8 @@ public interface IKuaishouInterfaceService {
 
     void getVideoList(CtopOauthToken token, Date startDate, Date endDate);
 
+    void getVideoList(String token, Long advertiserId,Date startDate, Date endDate, int page);
+
     void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
     void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate);

+ 50 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -218,8 +218,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("page_size", 500);
         param.put("page", page);
         if(startDate != null && endDate != null){
-            param.put("start_date", DateUtils.formatDate(new Date()));
-            param.put("end_date", DateUtils.formatDate(new Date()));
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
         }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
@@ -2718,4 +2718,52 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         kuaiShouImageGetService.replaceBatch(imageGets);
         getImageList(token, accountId, startDate, endDate, page+1 );
     }
+
+    /**
+     * 获取全量视频素材数据--测试使用
+     * @param token
+     * @param startDate
+     * @param endDate
+     * @param page
+     */
+    public void getVideoList(String token, Long accountId, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+        if(startDate != null && endDate != null){
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手视频列表数据异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手视频列表信息为空=》accountId:{}", accountId);
+            return;
+        }
+        List<KuaiShouVideoGet> videoGets = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
+            kuaiShouVideoGet.setAccountId(accountId);
+            kuaiShouVideoGet.setId("" + accountId + kuaiShouVideoGet.getPhotoId());
+            kuaiShouVideoGet.setCreateTime(new Date());
+            kuaiShouVideoGet.setUpdateTime(new Date());
+            videoGets.add(kuaiShouVideoGet);
+        }
+        kuaiShouVideoGetService.replaceBatch(videoGets);
+        getVideoList(token, accountId, startDate, endDate, page + 1);
+    }
+
 }