浏览代码

删除评论接口

zhaoxian 4 年之前
父节点
当前提交
0768209259

+ 2 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -511,7 +511,6 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             }
             }
             type 1:头条2:快手
             type 1:头条2:快手
         }*/
         }*/
-//        String msg = MatchLogic.getMsg(ruleGroup, user, obj, isPause, accountName);
             if (isPause) {
             if (isPause) {
                 msg += "现已被关停,请您及时查看并调整!";
                 msg += "现已被关停,请您及时查看并调整!";
             } else {
             } else {
@@ -527,8 +526,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             } else if ("TEL".equals(sendType)) {
             } else if ("TEL".equals(sendType)) {
 
 
             } else {
             } else {
-//                sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
-                sendMessageService.sendMessage(user.getString("id"), msg);
+                sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
+//                sendMessageService.sendMessage(user.getString("id"), msg);
                 Thread.sleep(200);
                 Thread.sleep(200);
             }
             }
             if (!Check.isNull(msg)) {
             if (!Check.isNull(msg)) {

+ 16 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -293,6 +293,21 @@ public class KuaishouInterfaceConstant {
      * 请求前缀
      * 请求前缀
      */
      */
     public static final String HTTPS_PREFIX = "https:";
     public static final String HTTPS_PREFIX = "https:";
-
+    /**
+     * 评论列表数据查询接口
+     */
+    public static final String COMMENT_LIST = "/rest/openapi/v1/comment/list";
+    /**
+     * 批量回复评论接口
+     */
+    public static final String COMMENT_REPLY = "/rest/openapi/v1/comment/reply";
+    /**
+     * 回复评论接口
+     */
+    public static final String COMMENT_TREE = "/rest/openapi/v1/comment/tree";
+    /**
+     * 屏蔽评论接口
+     */
+    public static final String COMMENT_SHIELD = "/rest/openapi/v1/comment/shield";
 
 
 }
 }

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCommentService.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+/**
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-19
+ */
+public interface IKuaiShouCommentService {
+
+    /**
+     * 屏蔽评论,先查后屏蔽
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void shieldComment(Long accountId);
+}

+ 107 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/IKuaiShouCommentServiceImpl.java

@@ -0,0 +1,107 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCommentService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.enums.NoEn;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 评论
+ */
+@Slf4j
+@Service
+public class IKuaiShouCommentServiceImpl implements IKuaiShouCommentService {
+
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Override
+    public void shieldComment(Long accountId) {
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        queryComments(oauthToken.getAccessToken(), accountId, 1, 500, 0);
+    }
+
+    /**
+     * 查询评论
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONArray
+     * @throws
+     * @author ZHAOXA
+     */
+    private JSONArray queryComments(String token, Long accountId, int page, int pageSize, int num) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.COMMENT_LIST;
+        Map<String, String> header = new HashMap<>();
+        header.put("Access-Token", token);
+        header.put("Content-Type", "application/json");
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", accountId);
+        params.put("shield_status", NoEn.NO1.valueInt());//未隐藏数据
+        params.put("page", page);
+        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)) {
+                    if (num <= 50) {
+                        System.out.println(num);
+                        if (shieldCommentApi(token, accountId, details)) {
+                            queryComments(token, accountId, page, pageSize, ++num);
+                        }
+                    }
+                }
+                return null;
+            } else {
+                log.error("查询评论列表数据接口返回信息错误:accountId:{},返回信息:{}", accountId, resultJson);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 执行屏蔽接口
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONArray
+     * @throws
+     * @author ZHAOXA
+     */
+    private boolean shieldCommentApi(String token, Long accountId, JSONArray comments) {
+        if (Check.isNull(comments)) {
+            return false;
+        }
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.COMMENT_SHIELD;
+        Map<String, String> header = new HashMap<>();
+        header.put("Access-Token", token);
+        header.put("Content-Type", "application/json");
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", accountId);
+        params.put("shield_list", comments);
+        String result = HttpUtils.httpPostRequest(url, params, header);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            return code == 0;
+        }
+        return false;
+    }
+
+
+}