丁云鹏 10 달 전
부모
커밋
2fdb107517

+ 23 - 7
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/WxAccessTokenRemoteService.java

@@ -4,21 +4,19 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
-import com.google.common.reflect.TypeToken;
 import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
-import com.tzld.longarticle.recommend.server.util.JSONUtils;
 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.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.util.EntityUtils;
 import org.springframework.stereotype.Service;
 
-import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -48,7 +46,25 @@ public class WxAccessTokenRemoteService {
     }
 
     private String loadAccessToken(String gzhId) {
-        return "83_UKkuWGS175MX05L95rdaJ_8qyH_HsOs78UxXjQFeiFoifuHt35wbiXreE6E37tPbxm_ACeqySrft02uML4K0SAog5mrkbG1xwIeFoV0zKax8pTsb3ZSewBJXjct4jgTn76PS8ZJOtJ2soAyUSHZdAFDNCU";
+        try {
+
+            URIBuilder uriBuilder = new URIBuilder("http://aigc-api.cybertogether.net/aigc/publish/account/getAccessTokenByGhId");
+            uriBuilder.setParameter("gzhId", gzhId); // 假设需要传递gzhId参数
+            HttpGet httpGet = new HttpGet();
+            httpGet.setURI(uriBuilder.build());
+
+            CloseableHttpResponse response = client.execute(httpGet);
+            StatusLine statusLine = response.getStatusLine();
+            if (statusLine.getStatusCode() == 200) {
+                HttpEntity responseEntity = response.getEntity();
+                if (Objects.nonNull(responseEntity)) {
+                    return EntityUtils.toString(responseEntity, "UTF-8");
+                }
+            }
+        } catch (Exception e) {
+            log.error("get user error gzhId {} ", gzhId, e);
+        }
+        return null;
     }
 
 //    private String loadAccessToken(String gzhId) {