Browse Source

Merge branch 'dev-xym-audit' of Server/long-article-manage into master

xueyiming 4 months ago
parent
commit
dad0f32f14

+ 13 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/dto/AuditContentRequest.java

@@ -0,0 +1,13 @@
+package com.tzld.piaoquan.longarticle.model.dto;
+
+import lombok.Data;
+import lombok.ToString;
+
+@Data
+@ToString
+public class AuditContentRequest {
+
+    private String contentId;
+
+    private String flowPoolLevel;
+}

+ 14 - 15
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CrawlerVideoServiceImpl.java

@@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.CrawlerVideoMapper;
 import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.TitleAuditMapper;
+import com.tzld.piaoquan.longarticle.model.dto.AuditContentRequest;
 import com.tzld.piaoquan.longarticle.model.po.longarticle.*;
+import com.tzld.piaoquan.longarticle.service.remote.MatchService;
+import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
 import com.tzld.piaoquan.longarticle.utils.other.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -31,6 +34,9 @@ public class CrawlerVideoServiceImpl {
     @Autowired
     private TitleAuditMapper titleAuditMapper;
 
+    @Autowired
+    private MatchService matchService;
+
     private static final String default_user_id = "69637498";
 
     private static final Double NLP_SIMILARITY_THRESHOLD = 0.55;
@@ -104,25 +110,18 @@ public class CrawlerVideoServiceImpl {
 
 
     public boolean uploadCrawlerVideo(MatchVideo matchVideo) {
-        boolean b = existUploadCrawlerVideo(matchVideo.getContentId());
-        if (b) {
+        if (existUploadCrawlerVideo(matchVideo.getContentId())) {
             return true;
         }
         boolean pushRes = pushOss(matchVideo.getContentId());
         if (pushRes) {
-            try {
-                Random random = new Random();
-                int randomInt = random.nextInt(10) + 97;
-                // 将随机整数转换为字符
-                char auditAccount = (char) randomInt;
-                TitleAudit titleAudit = new TitleAudit();
-                titleAudit.setContentId(matchVideo.getContentId());
-                titleAudit.setFlowPoolLevel(matchVideo.getFlowPoolLevel());
-                titleAudit.setAuditAccount(String.valueOf(auditAccount));
-                titleAudit.setCreateTimestamp(System.currentTimeMillis());
-                titleAuditMapper.insertSelective(titleAudit);
-            } catch (Exception e) {
-                log.error("addCrawlerVideo add titleAudit error", e);
+            AuditContentRequest auditContentRequest = new AuditContentRequest();
+            auditContentRequest.setContentId(matchVideo.getContentId());
+            auditContentRequest.setFlowPoolLevel(matchVideo.getFlowPoolLevel());
+            boolean addAudit = matchService.addAudit(auditContentRequest);
+            if (!addAudit) {
+                LarkRobotUtil.sendMessage("添加审核文章失败 contentId=" + matchVideo.getContentId() +
+                        " flowPoolLevel=" + matchVideo.getFlowPoolLevel());
             }
         }
         return pushRes;

+ 3 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/MatchService.java

@@ -1,8 +1,11 @@
 package com.tzld.piaoquan.longarticle.service.remote;
 
+import com.tzld.piaoquan.longarticle.model.dto.AuditContentRequest;
 import com.tzld.piaoquan.longarticle.model.dto.MiniprogramCardRequest;
 
 public interface MatchService {
 
     Integer matchMiniprogramVideo(MiniprogramCardRequest request);
+
+    boolean addAudit(AuditContentRequest request);
 }

+ 22 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/impl/MatchServiceImpl.java

@@ -3,6 +3,7 @@ package com.tzld.piaoquan.longarticle.service.remote.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.longarticle.common.enums.MatchRequestStatusEnum;
+import com.tzld.piaoquan.longarticle.model.dto.AuditContentRequest;
 import com.tzld.piaoquan.longarticle.model.dto.MiniprogramCardRequest;
 import com.tzld.piaoquan.longarticle.service.remote.MatchService;
 import com.tzld.piaoquan.longarticle.utils.HttpClientUtil;
@@ -43,4 +44,25 @@ public class MatchServiceImpl implements MatchService {
         //0 异常情况
         return MatchRequestStatusEnum.HAS_EXCEPTION.getStatusCode();
     }
+
+    public boolean addAudit(AuditContentRequest request) {
+        String apiUrl = "http://101.37.174.139:80/articleVideoAudit/addAudit";
+        int retry = 0;
+        while (retry < 3) {
+            try {
+                log.info("AuditContentRequest request={}", request);
+                String res = HTTP_POOL_CLIENT_UTIL_DEFAULT.post(apiUrl, JSON.toJSONString(request));
+                JSONObject jsonObject = JSON.parseObject(res);
+                log.info("AuditContentRequest request={} res={}", request, res);
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    return true;
+                }
+            } catch (Exception e) {
+                log.error("addAudit error", e);
+            }
+            retry++;
+        }
+        return false;
+    }
 }