|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
@@ -40,6 +41,49 @@ public class IKuaiShouCommentServiceImpl implements IKuaiShouCommentService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void deleteComment(UserAllocation allocation) {
|
|
|
+ CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
|
|
|
+ deleteCommentByPage(token,1);
|
|
|
+ log.info("删除评论完成:accounId=>{}",allocation.getAccountId());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteCommentByPage(CtopOauthToken token, int pageNum) {
|
|
|
+ //1:查询评论数据
|
|
|
+ JSONArray comments = getComments(token,pageNum,500);
|
|
|
+ if(null!=comments&&!comments.isEmpty()){
|
|
|
+ //存在评论则执行删除查询下一页,循环
|
|
|
+ shieldCommentApi(token.getAccessToken(), token.getAccountId(), comments);
|
|
|
+ deleteCommentByPage(token,pageNum+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONArray getComments(CtopOauthToken token, int pageNum, int pageSize) {
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.COMMENT_LIST;
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Access-Token", token.getAccessToken());
|
|
|
+ header.put("Content-Type", "application/json");
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ //未隐藏数据
|
|
|
+ params.put("shield_status", NoEn.NO1.valueInt());
|
|
|
+ params.put("page", pageNum);
|
|
|
+ params.put("page_size", pageSize);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, header);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
+ JSONArray details = dataJson.getJSONArray("details");
|
|
|
+ if (!Check.isNull(details)) {
|
|
|
+ return details;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new JSONArray();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询评论
|
|
|
*
|