Browse Source

修改快手拉取素材分页问题

yumeng 3 years ago
parent
commit
800b019077

+ 9 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -198,7 +198,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             headers.put("Access-Token", token.getAccessToken());
             Map<String, Object> param = new HashMap<>();
             param.put("advertiser_id", token.getAccountId());
-            param.put("page_size", 500);
+            Integer page_size = 500;
+            param.put("page_size", page_size);
             param.put("page", page);
             if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
                 param.put("start_date", startDate);
@@ -220,6 +221,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
                 return;
             }
+            Boolean doGet = true;
+            if (details.size() < page_size) {
+                doGet = false;
+            }
+
             List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detailJson = details.getJSONObject(i);
@@ -269,10 +275,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(videoGetList)) {
                 videoGetService.replaceBatch(videoGetList);
             }
-            Integer total_count = resultJson.getJSONObject("data").getInteger("total_count");
-            if (!Check.isNull(total_count) && total_count == 500) {
+            if (doGet) {
                 getVideoListByPage(token, startDate, endDate, page + 1);
             }
+
         } catch (Exception e) {
             e.printStackTrace();
         }