Quellcode durchsuchen

Merge branch 'wyp/1219-contentRetry' of Server/long-article-recommend into master

wangyunpeng vor 6 Monaten
Ursprung
Commit
a5c446f763

+ 14 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/aigc/AIGCWaitingPublishContentService.java

@@ -29,7 +29,19 @@ public class AIGCWaitingPublishContentService {
 
 
     public List<Content> getAllContent(RecallParam param) {
-        List<Content> result = new ArrayList<>();
+        int retryTimes = 2;
+        while (retryTimes > 0) {
+            List<Content> result = post(param);
+            if (Objects.nonNull(result)) {
+                return result;
+            }
+            retryTimes--;
+        }
+        return new ArrayList<>();
+    }
+
+    public List<Content> post(RecallParam param) {
+        List<Content> result = null;
         JSONObject bodyParam = new JSONObject();
         JSONObject bodyParamParams = new JSONObject();
         bodyParamParams.put("accountId", param.getAccountId());
@@ -50,7 +62,7 @@ public class AIGCWaitingPublishContentService {
                     JSONObject jsonObject = JSONObject.parseObject(responseBody);
                     if (jsonObject.getInteger("code") == 0) {
                         JSONArray data = jsonObject.getJSONArray("data");
-                        result.addAll(JSONArray.parseArray(data.toJSONString(), Content.class));
+                        result = JSONArray.parseArray(data.toJSONString(), Content.class);
                     }
                 }
             }