yumeng před 2 měsíci
rodič
revize
2b24172a22

+ 18 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceProjectServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.job.bytedance.data.mapper.OauthTokenMapper;
 import cn.com.ctop.job.bytedance.data.service.IBytedanceProjectService;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
+import cn.com.ctop.job.bytedance.data.utils.RateLimitUtil;
 import cn.com.ctop.job.bytedance.data.utils.weixin.CorpWexinUtils;
 import cn.com.ctop.job.bytedance.utils.RedisUtil;
 import com.alibaba.fastjson.JSONArray;
@@ -46,6 +47,9 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
     @Resource
     private CorpWexinUtils corpWexinUtils;
 
+    @Autowired
+    private RateLimitUtil rateLimitUtil;
+
     @Override
     public void getProjectList(OauthToken oauthToken, String startDate, String endDate, int page) {
         log.info("开始获取获取项目列表 accountId:{},日期{},page:{}", oauthToken.getAccountId(), startDate, page);
@@ -60,7 +64,13 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
             filtering.put("project_modify_time", startDate);
             filtering.put("project_create_time", startDate);
             param.put("filtering", filtering);
-            JSONObject resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
+
+            JSONObject resultObject = new JSONObject();
+            if (rateLimitUtil.acquire("1635316529903624", url)) {
+                resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
+            }
+
+
             if (Check.isNull(resultObject)) {
                 log.error("获取项目列表异常==》accountId:{},调用结果为null", oauthToken.getAccountId());
                 return;
@@ -162,7 +172,13 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
             JSONObject filtering = new JSONObject();
             filtering.put("status", "PROJECT_STATUS_ENABLE");//项目 仅查询启动状态
             param.put("filtering", filtering);
-            JSONObject resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
+
+            JSONObject resultObject = new JSONObject();
+            if (rateLimitUtil.acquire("1635316529903624", url)) {
+                resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
+            }
+
+
             if (Check.isNull(resultObject)) {
                 log.error("checkAdvertiserProject异常==》accountId:{},结果为null", oauthToken.getAccountId());
                 return;

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/utils/RateLimitUtil.java

@@ -26,7 +26,7 @@ public class RateLimitUtil {
             .put("/open_api/v3.0/report/custom/get/", 24)
             .put("/open_api/2/file/video/get/", 10)
             .put("/open_api/v3.0/promotion/list/", 30)
-            .put("/open_api/v3.0/project/list/", 30)
+            .put("/open_api/v3.0/project/list/", 10)
             .put("/open_api/2/customer_center/advertiser/list/", 50)
             .put("/open_api/v3.0/tools/micro_app/list/", 10)
             .put("/open_api/v3.0/tools/asset_link/list/", 10)