Browse Source

根据ghId获取发布账号

wangyunpeng 2 months ago
parent
commit
c10b6aea11

+ 15 - 0
api-module/src/main/java/com/tzld/piaoquan/api/remote/AigcApiService.java

@@ -91,6 +91,21 @@ public class AigcApiService {
         return null;
     }
 
+    public String getDetailByGhId(String ghId) {
+        String url = aigcApiHost + "/publish/account/getDetailByGhId";
+        JSONObject params = new JSONObject();
+        params.put("id", ghId);
+        try {
+            String post = httpPoolClient.post(url, getAigcPostParam(params));
+            JSONObject res = JSONObject.parseObject(post);
+            JSONObject data = res.getJSONObject("data");
+            return data.getString("id");
+        } catch (Exception e) {
+            log.error("getAccountDetail error", e);
+        }
+        return null;
+    }
+
     public String createPublishPlan(String publishAccountId, String name) {
         String url = aigcApiHost + "/publish/plan/save";
         JSONObject params = getPublishPlanAddParam(publishAccountId, name);

+ 1 - 2
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformCooperateAccountServiceImpl.java

@@ -100,7 +100,7 @@ public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatfo
         account.setContentType(param.getContentType());
         account.setUpdateTimestamp(now);
         if (Objects.isNull(param.getId())) {
-            String externalId = redisUtils.get(param.getGhId());
+            String externalId = aigcApiService.getDetailByGhId(param.getGhId());
             if (StringUtils.hasText(externalId)) {
                 account.setExternalId(externalId);
             }
@@ -138,7 +138,6 @@ public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatfo
             JSONObject detail = aigcApiService.getAccountDetail(publishAccountId);
             String name = detail.getString("name");
             String ghId = detail.getString("ghId");
-            redisUtils.setValueWithExpire(ghId, publishAccountId, 6 * 60 * 60L);
             return GzhAuthResultVO.builder().name(name).ghId(ghId).build();
         }
         return null;