瀏覽代碼

增加封面上传重试

xueyiming 4 月之前
父節點
當前提交
25d8219922

+ 18 - 14
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/impl/AigcServiceImpl.java

@@ -168,21 +168,25 @@ public class AigcServiceImpl implements AigcService {
         if (StringUtils.isEmpty(coverUrl) || StringUtils.isEmpty(publishContentId)) {
             return null;
         }
-        String apiUrl = "http://aigc-api.cybertogether.net/aigc//publish/LongArticleSystem/uploadMiniprogramCover";
-        try {
-            JSONObject param = new JSONObject();
-            param.put("coverUrl", coverUrl);
-            param.put("publishContentId", publishContentId);
-            String res = HTTP_POOL_CLIENT_UTIL_DEFAULT.post(apiUrl, JSONObject.toJSONString(param));
-            JSONObject jsonObject = JSON.parseObject(res);
-            Integer code = jsonObject.getInteger("code");
-            if (code == 0) {
-                JSONObject data = jsonObject.getJSONObject("data");
-                return data.getString("wxUrl");
+        int retey = 0;
+        while (retey < 3) {
+            String apiUrl = "http://aigc-api.cybertogether.net/aigc//publish/LongArticleSystem/uploadMiniprogramCover";
+            try {
+                JSONObject param = new JSONObject();
+                param.put("coverUrl", coverUrl);
+                param.put("publishContentId", publishContentId);
+                log.info("pushCover param={}", param);
+                String res = HTTP_POOL_CLIENT_UTIL_DEFAULT.post(apiUrl, JSONObject.toJSONString(param));
+                JSONObject jsonObject = JSON.parseObject(res);
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    return data.getString("wxUrl");
+                }
+            } catch (Exception e) {
+                log.error("pushCover error", e);
             }
-            return null;
-        } catch (Exception e) {
-            log.error("pushCover error", e);
+            retey++;
         }
         return null;
     }