|
@@ -7,6 +7,7 @@ import cn.com.ctop.job.bytedance.data.mapper.BytedancePromotionListMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedancePromotionListService;
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedancePromotionListService;
|
|
|
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.utils.RedisUtil;
|
|
import cn.com.ctop.job.bytedance.utils.RedisUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -36,11 +37,13 @@ public class BytedancePromotionListServiceImpl implements IBytedancePromotionLis
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RateLimitUtil rateLimitUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void getPromotionList(OauthToken oauthToken, String startDate, String endDate, int pageNumber, int pageSize) {
|
|
public void getPromotionList(OauthToken oauthToken, String startDate, String endDate, int pageNumber, int pageSize) {
|
|
|
- log.info("开始获取体验版-广告列表数据 accountIDL{},日期{},page:{}", oauthToken.getAccountId(), startDate,pageNumber);
|
|
|
|
|
|
|
+ log.info("开始获取体验版-广告列表数据 accountIDL{},日期{},page:{}", oauthToken.getAccountId(), startDate, pageNumber);
|
|
|
// 请求地址
|
|
// 请求地址
|
|
|
String url = bytedanceApiUrl + BytedanceConstant.BYTEDANCE_V3_PROMOTION_LIST_GET;
|
|
String url = bytedanceApiUrl + BytedanceConstant.BYTEDANCE_V3_PROMOTION_LIST_GET;
|
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
@@ -50,19 +53,24 @@ public class BytedancePromotionListServiceImpl implements IBytedancePromotionLis
|
|
|
JSONObject filtering = new JSONObject();
|
|
JSONObject filtering = new JSONObject();
|
|
|
filtering.put("promotion_create_time", startDate);
|
|
filtering.put("promotion_create_time", startDate);
|
|
|
param.put("filtering", filtering);
|
|
param.put("filtering", filtering);
|
|
|
- JSONObject resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
|
|
|
|
|
- if(Check.isNull(resultObject)){
|
|
|
|
|
|
|
+ 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());
|
|
log.error("体验版-广告列表异常==》accountId:{},调用结果为null", oauthToken.getAccountId());
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
Integer code = resultObject.getInteger("code");
|
|
Integer code = resultObject.getInteger("code");
|
|
|
if (null == code || !code.equals(0)) {
|
|
if (null == code || !code.equals(0)) {
|
|
|
- log.error("获取体验版-广告列表接口异常==》accountId:{},message:{},code{}", oauthToken.getAccountId(), resultObject.getString("message"),code);
|
|
|
|
|
|
|
+ log.error("获取体验版-广告列表接口异常==》accountId:{},message:{},code{}", oauthToken.getAccountId(), resultObject.getString("message"), code);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
|
|
JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
|
|
|
if (null == data || data.isEmpty()) {
|
|
if (null == data || data.isEmpty()) {
|
|
|
- log.error("获取体验版-广告列表数据为空==》accountId:{},message:{},code{}", oauthToken.getAccountId(), resultObject.getString("message"),code);
|
|
|
|
|
|
|
+ log.error("获取体验版-广告列表数据为空==》accountId:{},message:{},code{}", oauthToken.getAccountId(), resultObject.getString("message"), code);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
List<BytedancePromotionList> list = new ArrayList<>();
|
|
List<BytedancePromotionList> list = new ArrayList<>();
|
|
@@ -81,7 +89,4 @@ public class BytedancePromotionListServiceImpl implements IBytedancePromotionLis
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|