wangyunpeng 5 月之前
父节点
当前提交
98d8d361d0

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

@@ -50,7 +50,7 @@ public class WxAccessTokenRemoteService {
         return cache.getUnchecked(gzhId);
     }
 
-    private String loadAccessToken(String gzhId) {
+    public String loadAccessToken(String gzhId) {
         try {
 
             URIBuilder uriBuilder = new URIBuilder("http://aigc-api.cybertogether.net/aigc/publish/account/getAccessTokenByGhId");

+ 5 - 2
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/RecommendTest.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
+import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
@@ -65,6 +66,8 @@ public class RecommendTest {
     private PublishAccountRepository publishAccountRepository;
     @Autowired
     private AigcBaseMapper aigcBaseMapper;
+    @Autowired
+    private PublishContentMapper publishContentMapper;
 
 //    @Test
 //    void recall() {
@@ -852,11 +855,11 @@ public class RecommendTest {
         }).filter(Objects::nonNull).collect(Collectors.toList());
         List<PublishContentDTO> publishContents = new ArrayList<>();
         for (List<PublishContentParam> partitions : Lists.partition(publishContentParamList, 100)) {
-            publishContents.addAll(aigcBaseMapper.getPublishContentByTitle(partitions));
+            publishContents.addAll(publishContentMapper.getPublishContentByTitle(partitions));
         }
         List<String> publishContentIds = publishContents.stream().map(PublishContentDTO::getId).collect(Collectors.toList());
         for (List<String> partition : Lists.partition(publishContentIds, 500)) {
-            aigcBaseMapper.updatePublishContentSingleMiniProgram(partition);
+            publishContentMapper.updatePublishContentSingleMiniProgram(partition);
         }
     }
 }

+ 14 - 2
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/WxApiTest.java

@@ -1,18 +1,22 @@
 package com.tzld.longarticle.recommend.server;
 
-import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
+import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
 import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
 import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
 import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
+import com.tzld.longarticle.recommend.server.service.recommend.ArticleAuditService;
+import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.util.List;
 
 @SpringBootTest(classes = Application.class)
+@Slf4j
 public class WxApiTest {
 
     @Resource
@@ -23,13 +27,21 @@ public class WxApiTest {
     private WxAccessTokenRemoteService wxAccessTokenRemoteService;
     @Resource
     private WxArticleDeleteService wxArticleDeleteService;
+    @Resource
+    private PublishContentMapper publishContentMapper;
+    @Resource
+    private ArticleAuditService articleAuditService;
 
     @Test
     public void clearQuotaTest() {
         List<String> ghIds = longArticleBaseMapper.getDisAuditDeleteGhid();
         List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
         for (PublishAccount publishAccount : publishAccountList) {
-            String token = wxAccessTokenRemoteService.getAccessToken(publishAccount.getGhId());
+            String token = wxAccessTokenRemoteService.loadAccessToken(publishAccount.getGhId());
+            if(StringUtils.isEmpty(token)) {
+                log.error("token is null ghId:{}", publishAccount.getGhId());
+                continue;
+            }
             wxArticleDeleteService.clearQuota(token, publishAccount.getAppId());
         }
     }

+ 4 - 1
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/XxlJobTest.java

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server;
 import com.alibaba.fastjson.JSONObject;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
+import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleCategoryMapper;
 import com.tzld.longarticle.recommend.server.model.dto.CrawlerContent;
 import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
@@ -30,6 +31,8 @@ public class XxlJobTest {
     @Resource
     private AigcBaseMapper aigcBaseMapper;
     @Resource
+    private PublishContentMapper publishContentMapper;
+    @Resource
     private ArticleCategoryMapper articleCategoryMapper;
     @Resource
     private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
@@ -101,7 +104,7 @@ public class XxlJobTest {
 
     @Test
     public void getAccountTypeListTest() {
-        List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList(null);
+        List<PublishAccountTypeDTO> accountTypeList = publishContentMapper.getAccountTypeList(null);
         System.out.println(JSONObject.toJSONString(accountTypeList));
     }
 }