|
|
@@ -8,9 +8,11 @@ import cn.com.ctop.job.bytedance.data.mapper.BytedanceFileVideoGetMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedanceFileVideoGetService;
|
|
|
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 com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -34,6 +36,8 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
|
|
|
private String bytedanceApiUrl;
|
|
|
@Resource
|
|
|
BytedanceFileVideoGetMapper bytedanceFileVideoGetMapper;
|
|
|
+ @Autowired
|
|
|
+ private RateLimitUtil rateLimitUtil;
|
|
|
|
|
|
@Override
|
|
|
public void getFileVideoData(OauthToken oauthToken, String startDate, String endDate, int page, int pageSize) {
|
|
|
@@ -53,7 +57,15 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
|
|
|
param2.put("end_time", endDate);
|
|
|
}
|
|
|
param.put("filtering", param2);
|
|
|
- JSONObject resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject resultObject = new JSONObject();
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
Integer code = resultObject.getInteger("code");
|
|
|
if (null == code || !code.equals(0)) {
|
|
|
@@ -119,7 +131,12 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
|
|
|
*/
|
|
|
param.put("filtering", param2);
|
|
|
|
|
|
- JSONObject resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
|
|
|
+ JSONObject resultObject = new JSONObject();
|
|
|
+ if (rateLimitUtil.acquire("1635316529903624", url)) {
|
|
|
+ resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
Integer code = resultObject.getInteger("code");
|
|
|
if (null == code || !code.equals(0)) {
|
|
|
log.error("获取视频素材接口异常==》accountId:{},message:{}", oauthToken.getAccountId(), resultObject.getString("message"));
|