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