|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|