Bladeren bron

修改重复请求逻辑

xuzuoyun 5 jaren geleden
bovenliggende
commit
277debeb3b

+ 10 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/controller/KuaishouWebController.java

@@ -101,7 +101,8 @@ public class KuaishouWebController {
     public Result<Map<String, Object>> videoList(String ksid, String pcursor) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();
         try {
-            Map<String, Object> statusMap = kuaishouWebInterfaceService.videoList(ksid, pcursor);
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            Map<String, Object> statusMap = kuaishouWebInterfaceService.videoList(user.getId(), ksid, pcursor);
             result.setSuccess(true);
             result.setResult(statusMap);
         } catch (Exception e) {
@@ -115,7 +116,8 @@ public class KuaishouWebController {
     public Result<Map<String, Object>> commentList(String ksid, String photoId, String pcursor) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();
         try {
-            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentList(ksid, photoId, pcursor);
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentList(user.getId(), ksid, photoId, pcursor);
             result.setSuccess(true);
             result.setResult(statusMap);
         } catch (Exception e) {
@@ -129,7 +131,8 @@ public class KuaishouWebController {
     public Result<Map<String, Object>> commentDelete(String ksid, String photoId, Long commentId) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();
         try {
-            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentDelete(ksid, photoId, commentId);
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentDelete(user.getId(), ksid, photoId, commentId);
             result.setSuccess(true);
             result.setResult(statusMap);
         } catch (Exception e) {
@@ -143,7 +146,8 @@ public class KuaishouWebController {
     public Result<Map<String, Object>> commentAdd(String ksid, String photoId, String content, Long replyToCommentId, Long repltTo) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();
         try {
-            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentAdd(ksid, photoId, content, replyToCommentId, repltTo);
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentAdd(user.getId(), ksid, photoId, content, replyToCommentId, repltTo);
             result.setSuccess(true);
             result.setResult(statusMap);
         } catch (Exception e) {
@@ -157,7 +161,8 @@ public class KuaishouWebController {
     public Result<Map<String, Object>> subCommentList(String ksid, String photoId, Long rootCommentId, String pcursor) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();
         try {
-            Map<String, Object> statusMap = kuaishouWebInterfaceService.subCommentList(ksid, photoId, rootCommentId, pcursor);
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            Map<String, Object> statusMap = kuaishouWebInterfaceService.subCommentList(user.getId(), ksid, photoId, rootCommentId, pcursor);
             result.setSuccess(true);
             result.setResult(statusMap);
         } catch (Exception e) {

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/entity/KuaishouCommentConfig.java

@@ -10,7 +10,7 @@ import lombok.Data;
 public class KuaishouCommentConfig {
     @TableId(value = "ksid", type = IdType.INPUT)
     private String ksid;
-    private Boolean autoDelete;
+    private Integer autoDelete;
     private String strategy;
     private String cycle;
 }

+ 20 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/job/KuaishouCommentDayJob.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.graphql.job;
 
 import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouCommentConfig;
+import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouCommentStat;
 import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouUserCookie;
 import cn.com.ctop.kuaishou.modules.graphql.service.*;
 import com.alibaba.fastjson.JSONArray;
@@ -31,7 +32,7 @@ public class KuaishouCommentDayJob implements Job {
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         QueryWrapper<KuaishouCommentConfig> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("auto_delete", true);
+        queryWrapper.eq("auto_delete", 1);
         queryWrapper.eq("cycle", "DAY");
         List<KuaishouCommentConfig> kuaishouCommentConfigList = kuaishouCommentConfigService.list(queryWrapper);
         if (kuaishouCommentConfigList != null && kuaishouCommentConfigList.size() > 0) {
@@ -43,7 +44,7 @@ public class KuaishouCommentDayJob implements Job {
                 try {
                     String pcursor = "";
                     do {
-                        Map<String, Object> videoMap = kuaishouWebInterfaceService.videoList(config.getKsid(), pcursor);
+                        Map<String, Object> videoMap = kuaishouWebInterfaceService.videoList(kuaishouUserCookie.getUserId(), config.getKsid(), pcursor);
                         JsonNode videoNode = mapToJson(videoMap);
                         pcursor = videoNode.get("data").get("publicFeeds").get("pcursor").asText();
                         Iterator<JsonNode> list = videoNode.get("data").get("publicFeeds").get("list").iterator();
@@ -54,20 +55,32 @@ public class KuaishouCommentDayJob implements Job {
                                 String photoId = node.get("photoId").asText();
                                 String commentPcursor = "";
                                 do {
-                                    Map<String, Object> commentMap = kuaishouWebInterfaceService.commentList(config.getKsid(), photoId, commentPcursor);
+                                    Map<String, Object> commentMap = kuaishouWebInterfaceService.commentList(kuaishouUserCookie.getUserId(), config.getKsid(), photoId, commentPcursor);
                                     JsonNode commentNode = mapToJson(commentMap);
                                     commentPcursor = commentNode.get("data").get("shortVideoCommentList").get("pcursor").asText();
                                     Iterator<JsonNode> commentList = commentNode.get("data").get("shortVideoCommentList").get("commentList").iterator();
                                     while (commentList.hasNext()) {
                                         JsonNode commentListNode = commentList.next();
                                         Long commentId = commentListNode.get("commentId").asLong();
-                                        Map<String, Object> deleteMap = kuaishouWebInterfaceService.commentDelete(config.getKsid(), photoId, commentId);
-
+                                        Map<String, Object> deleteMap = kuaishouWebInterfaceService.commentDelete(kuaishouUserCookie.getUserId(), config.getKsid(), photoId, commentId);
+                                        if ((int) deleteMap.get("result") == 1) {
+                                            KuaishouCommentStat kuaishouCommentStat = kuaishouCommentStatService.getById(commentId);
+                                            if (kuaishouCommentStat == null) {
+                                                kuaishouCommentStat = new KuaishouCommentStat();
+                                                kuaishouCommentStat.setCommentId(commentId);
+                                                kuaishouCommentStat.setDeleteCount(1);
+                                                kuaishouCommentStat.setKsid(config.getKsid());
+                                                kuaishouCommentStatService.save(kuaishouCommentStat);
+                                            } else {
+                                                kuaishouCommentStat.setDeleteCount(kuaishouCommentStat.getDeleteCount() + 1);
+                                                kuaishouCommentStatService.updateById(kuaishouCommentStat);
+                                            }
+                                        }
                                     }
-                                } while (!commentPcursor.equals("no_more"));
+                                } while (commentPcursor != null && !commentPcursor.equals("no_more"));
                             }
                         }
-                    } while (!pcursor.equals("no_more"));
+                    } while (pcursor != null && !pcursor.equals("no_more"));
 
                 } catch (Exception e) {
                     e.printStackTrace();

+ 96 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/job/KuaishouCommentHourJob.java

@@ -0,0 +1,96 @@
+package cn.com.ctop.kuaishou.modules.graphql.job;
+
+import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouCommentConfig;
+import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouCommentStat;
+import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouUserCookie;
+import cn.com.ctop.kuaishou.modules.graphql.service.*;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class KuaishouCommentHourJob implements Job {
+    @Autowired
+    private IKuaishouCommentConfigService kuaishouCommentConfigService;
+    @Autowired
+    private IKuaishouCommentKeywordService kuaishouCommentKeywordService;
+    @Autowired
+    private IKuaishouCommentStatService kuaishouCommentStatService;
+    @Autowired
+    private IKuaishouUserCookieService kuaishouUserCookieService;
+    @Autowired
+    private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        QueryWrapper<KuaishouCommentConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("auto_delete", 1);
+        queryWrapper.eq("cycle", "HOUR");
+        List<KuaishouCommentConfig> kuaishouCommentConfigList = kuaishouCommentConfigService.list(queryWrapper);
+        if (kuaishouCommentConfigList != null && kuaishouCommentConfigList.size() > 0) {
+            for (KuaishouCommentConfig config : kuaishouCommentConfigList) {
+                QueryWrapper<KuaishouUserCookie> queryWrapper1 = new QueryWrapper<>();
+                queryWrapper1.eq("ksid", config.getKsid());
+                KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper1);
+
+                try {
+                    String pcursor = "";
+                    do {
+                        Map<String, Object> videoMap = kuaishouWebInterfaceService.videoList(kuaishouUserCookie.getUserId(), config.getKsid(), pcursor);
+                        JsonNode videoNode = mapToJson(videoMap);
+                        pcursor = videoNode.get("data").get("publicFeeds").get("pcursor").asText();
+                        Iterator<JsonNode> list = videoNode.get("data").get("publicFeeds").get("list").iterator();
+                        while (list.hasNext()) {
+                            JsonNode node = list.next();
+                            Integer commentCount = node.get("commentCount").asInt();
+                            if (commentCount > 0) {
+                                String photoId = node.get("photoId").asText();
+                                String commentPcursor = "";
+                                do {
+                                    Map<String, Object> commentMap = kuaishouWebInterfaceService.commentList(kuaishouUserCookie.getUserId(), config.getKsid(), photoId, commentPcursor);
+                                    JsonNode commentNode = mapToJson(commentMap);
+                                    commentPcursor = commentNode.get("data").get("shortVideoCommentList").get("pcursor").asText();
+                                    Iterator<JsonNode> commentList = commentNode.get("data").get("shortVideoCommentList").get("commentList").iterator();
+                                    while (commentList.hasNext()) {
+                                        JsonNode commentListNode = commentList.next();
+                                        Long commentId = commentListNode.get("commentId").asLong();
+                                        Map<String, Object> deleteMap = kuaishouWebInterfaceService.commentDelete(kuaishouUserCookie.getUserId(), config.getKsid(), photoId, commentId);
+                                        if ((int) deleteMap.get("result") == 1) {
+                                            KuaishouCommentStat kuaishouCommentStat = kuaishouCommentStatService.getById(commentId);
+                                            if (kuaishouCommentStat == null) {
+                                                kuaishouCommentStat = new KuaishouCommentStat();
+                                                kuaishouCommentStat.setCommentId(commentId);
+                                                kuaishouCommentStat.setDeleteCount(1);
+                                                kuaishouCommentStat.setKsid(config.getKsid());
+                                                kuaishouCommentStatService.save(kuaishouCommentStat);
+                                            } else {
+                                                kuaishouCommentStat.setDeleteCount(kuaishouCommentStat.getDeleteCount() + 1);
+                                                kuaishouCommentStatService.updateById(kuaishouCommentStat);
+                                            }
+                                        }
+                                    }
+                                } while (commentPcursor != null && !commentPcursor.equals("no_more"));
+                            }
+                        }
+                    } while (pcursor != null && !pcursor.equals("no_more"));
+
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public JsonNode mapToJson(Map<String, Object> map) throws Exception {
+        ObjectMapper mapper = new ObjectMapper();
+        String json = mapper.writeValueAsString(map);
+        return mapper.readTree(json);
+    }
+}

+ 5 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/IKuaishouWebInterfaceService.java

@@ -22,13 +22,13 @@ public interface IKuaishouWebInterfaceService {
 
     public Map<String, Object> loginStatus(String taskId);
 
-    public Map<String, Object> commentDelete(String ksid, String photoId, Long commentId);
+    public Map<String, Object> commentDelete(String userId, String ksid, String photoId, Long commentId);
 
-    public Map<String, Object> videoList(String ksid, String pcursor);
+    public Map<String, Object> videoList(String userId, String ksid, String pcursor);
 
-    public Map<String, Object> commentList(String ksid, String photoId, String pcursor);
+    public Map<String, Object> commentList(String userId, String ksid, String photoId, String pcursor);
 
-    public Map<String, Object> commentAdd(String ksid, String photoId, String content, Long replyToCommentId, Long replyTo);
+    public Map<String, Object> commentAdd(String userId, String ksid, String photoId, String content, Long replyToCommentId, Long replyTo);
 
-    public Map<String, Object> subCommentList(String ksid, String photoId, Long rootCommentId, String pcursor);
+    public Map<String, Object> subCommentList(String userId, String ksid, String photoId, Long rootCommentId, String pcursor);
 }

+ 64 - 33
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java

@@ -107,11 +107,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         return queryStr;
     }
 
-    public Map<String, Object> subCommentList(String ksid, String photoId, Long rootCommentId, String pcursor) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    public Map<String, Object> subCommentList(String userId, String ksid, String photoId, Long rootCommentId, String pcursor) {
         QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
         Map<String, Object> resultMap = new HashMap<>();
-        queryWrapper.eq("user_id", user.getId());
+        queryWrapper.eq("user_id", userId);
         queryWrapper.eq("ksid", ksid);
         KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
         if (kuaishouUserCookie != null) {
@@ -138,7 +137,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 if (resultNode.get("subCommentList").isNull() || resultNode.get("subCommentList").get("pcursor").isNull()) {
                     ipPool.setStatus(2);
                     iIpPoolService.updateById(ipPool);
-                    return subCommentList(ksid, photoId, rootCommentId, pcursor);
+                    return subCommentList(userId, ksid, photoId, rootCommentId, pcursor);
                 }
             } catch (Exception e) {
                 e.printStackTrace();
@@ -146,17 +145,16 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                     ipPool.setStatus(2);
                     iIpPoolService.updateById(ipPool);
                 }
-                return subCommentList(ksid, photoId, rootCommentId, pcursor);
+                return subCommentList(userId, ksid, photoId, rootCommentId, pcursor);
             }
         }
         return resultMap;
     }
 
-    public Map<String, Object> commentList(String ksid, String photoId, String pcursor) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    public Map<String, Object> commentList(String userId, String ksid, String photoId, String pcursor) {
         QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
         Map<String, Object> resultMap = new HashMap<>();
-        queryWrapper.eq("user_id", user.getId());
+        queryWrapper.eq("user_id", userId);
         queryWrapper.eq("ksid", ksid);
         KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
         if (kuaishouUserCookie != null) {
@@ -193,7 +191,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 if (httpClientEntity.getResult() == null) {
                     ipPool.setStatus(2);
                     iIpPoolService.updateById(ipPool);
-                    return commentList(ksid, photoId, pcursor);
+                    return commentList(userId, ksid, photoId, pcursor);
                 }
                 resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
                 });
@@ -201,7 +199,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 if (resultNode.get("shortVideoCommentList").isNull() || resultNode.get("shortVideoCommentList").get("pcursor").isNull()) {
                     ipPool.setStatus(2);
                     iIpPoolService.updateById(ipPool);
-                    return commentList(ksid, photoId, pcursor);
+                    return commentList(userId, ksid, photoId, pcursor);
                 }
             } catch (Exception e) {
                 if (ipPool != null) {
@@ -209,7 +207,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                     iIpPoolService.updateById(ipPool);
                 }
                 e.printStackTrace();
-                return commentList(ksid, photoId, pcursor);
+                return commentList(userId, ksid, photoId, pcursor);
             }
         }
         return resultMap;
@@ -239,11 +237,11 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         return map;
     }
 
-    public Map<String, Object> videoList(String ksid, String pcursor) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    public Map<String, Object> videoList(String userId, String ksid, String pcursor) {
+
         QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
         Map<String, Object> resultMap = new HashMap<>();
-        queryWrapper.eq("user_id", user.getId());
+        queryWrapper.eq("user_id", userId);
         queryWrapper.eq("ksid", ksid);
         KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
         if (kuaishouUserCookie != null) {
@@ -266,7 +264,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 if (httpClientEntity.getResult() == null) {
                     ipPool.setStatus(2);
                     iIpPoolService.updateById(ipPool);
-                    return videoList(ksid, pcursor);
+                    return videoList(userId, ksid, pcursor);
                 }
                 Map<String, String> map = getTTfNumber(kuaishouUserCookie);
                 for (String key : map.keySet()) {
@@ -280,7 +278,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 if (resultNode.get("publicFeeds").isNull() || resultNode.get("publicFeeds").get("pcursor").isNull()) {
                     ipPool.setStatus(2);
                     iIpPoolService.updateById(ipPool);
-                    return videoList(ksid, pcursor);
+                    return videoList(userId, ksid, pcursor);
                 }
             } catch (Exception e) {
                 if (ipPool != null) {
@@ -288,7 +286,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                     iIpPoolService.updateById(ipPool);
                 }
                 e.printStackTrace();
-                return videoList(ksid, pcursor);
+                return videoList(userId, ksid, pcursor);
             }
         }
         return resultMap;
@@ -337,11 +335,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         return kuaishouNumberMap.get(key);
     }
 
-    public Map<String, Object> commentDelete(String ksid, String photoId, Long commentId) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    public Map<String, Object> commentDelete(String userId, String ksid, String photoId, Long commentId) {
         QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
         Map<String, Object> resultMap = new HashMap<>();
-        queryWrapper.eq("user_id", user.getId());
+        queryWrapper.eq("user_id", userId);
         queryWrapper.eq("ksid", ksid);
         KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
         if (kuaishouUserCookie != null) {
@@ -375,11 +372,18 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 ObjectMapper mapper = new ObjectMapper();
                 resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
                 });
-                if (((Integer) resultMap.get("result")) == 109) {
-                    ipPool.setStatus(2);
-                    iIpPoolService.updateById(ipPool);
-                    return commentDelete(ksid, photoId, commentId);
-                }
+                Integer code = ((Integer) resultMap.get("result"));
+//                if(code == 109){
+//
+//                }
+//                if (((Integer) resultMap.get("result")) == 109) {
+//                    reLogin(httpClientEntity,kuaishouUserCookie);
+//                    if(ipPool != null){
+//                        ipPool.setStatus(2);
+//                        iIpPoolService.updateById(ipPool);
+//                    }
+//                    return commentDelete(userId,ksid, photoId, commentId);
+//                }
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -387,11 +391,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         return resultMap;
     }
 
-    public Map<String, Object> commentAdd(String ksid, String photoId, String content, Long replyToCommentId, Long replyTo) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    public Map<String, Object> commentAdd(String userId, String ksid, String photoId, String content, Long replyToCommentId, Long replyTo) {
         QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
         Map<String, Object> resultMap = new HashMap<>();
-        queryWrapper.eq("user_id", user.getId());
+        queryWrapper.eq("user_id", userId);
         queryWrapper.eq("ksid", ksid);
         KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
         if (kuaishouUserCookie != null) {
@@ -427,11 +430,12 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 ObjectMapper mapper = new ObjectMapper();
                 resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
                 });
-                if (((Integer) resultMap.get("result")) == 109) {
-                    ipPool.setStatus(2);
-                    iIpPoolService.updateById(ipPool);
-                    return commentAdd(ksid, photoId, content, replyToCommentId, replyTo);
-                }
+//                if (((Integer) resultMap.get("result")) == 109) {
+//                    reLogin(httpClientEntity,kuaishouUserCookie);
+//                    ipPool.setStatus(2);
+//                    iIpPoolService.updateById(ipPool);
+//                    return commentAdd(userId,ksid, photoId, content, replyToCommentId, replyTo);
+//                }
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -985,6 +989,32 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         return httpClientEntity;
     }
 
+    public HttpClientEntity reLogin(HttpClientEntity httpClientEntity, KuaishouUserCookie kuaishouUserCookie) throws Exception {
+        Map<String, Object> params = new HashMap<String, Object>();
+        IpPool ipPool = iIpPoolService.getAvaliableIp();
+        params.put("sid", "kuaishou.live.web");
+        HttpClientUtils httpClientUtils = new HttpClientUtils();
+        httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault(ipPool));
+        httpClientEntity.setUrl("https://id.kuaishou.com/pass/kuaishou/login/passToken");
+        httpClientEntity.setResult("");
+        httpClientEntity.setHeaders(getHeaders());
+        httpClientEntity.setParams(params);
+        httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
+        ObjectMapper mapper = new ObjectMapper();
+        JsonNode jsonNode = mapper.readTree(httpClientEntity.getResult());
+        String at = jsonNode.get("kuaishou.live.web.at").asText();
+        httpClientEntity.setUrl("https://live.kuaishou.com/graphql");
+        httpClientEntity = httpClientUtils.callingGraph(httpClientEntity, userLogin(at));
+        httpClientEntity = httpClientUtils.callingGraph(httpClientEntity, userInfoQuery());
+        JsonNode userNode = mapper.readTree(httpClientEntity.getResult());
+        QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("user_id", kuaishouUserCookie.getUserId());
+        queryWrapper.eq("ksid", kuaishouUserCookie.getKsid());
+        kuaishouUserCookie.setCookie(new Gson().toJson(httpClientEntity.getCookieStore()));
+        kuaishouUserCookieService.update(kuaishouUserCookie, queryWrapper);
+        return httpClientEntity;
+    }
+
     public Date getCST(String strGMT) throws ParseException {
         if (strGMT == null) {
             return null;
@@ -1008,6 +1038,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         return httpClientEntity;
     }
 
+
     public String qrLogin(String taskId) throws Exception {
         HttpClientEntity httpClientEntity = this.kuaishouIndex();
         httpClientEntity = this.kuaishouQrStart(httpClientEntity);