Browse Source

视频审核自动通过

wangyunpeng 7 hours ago
parent
commit
fd18a7ed29

+ 56 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/aigc/AIGCArticleVideoAuditService.java

@@ -0,0 +1,56 @@
+package com.tzld.longarticle.recommend.server.remote.aigc;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.StatusLine;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+
+@Service
+@Slf4j
+public class AIGCArticleVideoAuditService {
+
+    private final CloseableHttpClient client = HttpPoolFactory.aigcPool();
+
+    private static String apiUrl = "http://aigc-api.cybertogether.net/aigc/produce/gzhArticleVideoAudit/auditArticleSys";
+
+    public void auditArticleSys(String contentId, Integer status) {
+        JSONObject params = new JSONObject();
+        params.put("contentId", contentId);
+        params.put("status", status);
+        // 准备请求参数
+        JSONObject payload = new JSONObject();
+        payload.put("params", params);
+        try {
+            HttpPost httpPost = new HttpPost(apiUrl);
+            StringEntity stringEntity = new StringEntity(payload.toJSONString(), StandardCharsets.UTF_8);
+            httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
+            httpPost.setEntity(stringEntity);
+            CloseableHttpResponse response = client.execute(httpPost);
+            StatusLine statusLine = response.getStatusLine();
+            if (statusLine.getStatusCode() == 200) {
+                HttpEntity responseEntity = response.getEntity();
+                if (Objects.nonNull(responseEntity)) {
+                    String responseBody = EntityUtils.toString(responseEntity, "UTF-8");
+                    JSONObject jsonObject = JSONObject.parseObject(responseBody);
+                    if (jsonObject.getInteger("code") == 0) {
+                        return;
+                    }
+                }
+            }
+        } catch (IOException e) {
+            log.error("auditArticleSys error", e);
+        }
+    }
+
+}

+ 6 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleVideoAuditService.java

@@ -14,6 +14,7 @@ import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRec
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
 import com.tzld.longarticle.recommend.server.model.param.videoAudit.*;
 import com.tzld.longarticle.recommend.server.model.vo.ArticleVideoAuditListVO;
+import com.tzld.longarticle.recommend.server.remote.aigc.AIGCArticleVideoAuditService;
 import com.tzld.longarticle.recommend.server.repository.aigc.ProducePlanExeRecordRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.*;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
@@ -61,6 +62,8 @@ public class ArticleVideoAuditService {
     private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private AIGCArticleVideoAuditService aigcArticleVideoAuditService;
 
     @Autowired
     private RedisTemplate<String, String> redisTemplate;
@@ -395,6 +398,9 @@ public class ArticleVideoAuditService {
         }
         item.setAuditAccount(auditAccount);
         titleAuditRepository.save(item);
+        if (status == ArticleVideoAuditStatusEnum.PASS.getCode()) {
+            aigcArticleVideoAuditService.auditArticleSys(param.getContentId(), status);
+        }
     }
 
     @XxlJob("articlePoolAuditQueueJob")