WxApiTest.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.tzld.longarticle.recommend.server;
  2. import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
  3. import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
  4. import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
  5. import com.tzld.longarticle.recommend.server.remote.WxAccessTokenRemoteService;
  6. import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
  7. import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
  8. import com.tzld.longarticle.recommend.server.service.recommend.ArticleAuditService;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.junit.jupiter.api.Test;
  11. import org.springframework.boot.test.context.SpringBootTest;
  12. import org.springframework.util.StringUtils;
  13. import javax.annotation.Resource;
  14. import java.util.List;
  15. @SpringBootTest(classes = Application.class)
  16. @Slf4j
  17. public class WxApiTest {
  18. @Resource
  19. private LongArticleBaseMapper longArticleBaseMapper;
  20. @Resource
  21. private PublishAccountRepository publishAccountRepository;
  22. @Resource
  23. private WxAccessTokenRemoteService wxAccessTokenRemoteService;
  24. @Resource
  25. private WxArticleDeleteService wxArticleDeleteService;
  26. @Resource
  27. private PublishContentMapper publishContentMapper;
  28. @Resource
  29. private ArticleAuditService articleAuditService;
  30. @Test
  31. public void clearQuotaTest() {
  32. List<String> ghIds = longArticleBaseMapper.getDisAuditDeleteGhid();
  33. List<PublishAccount> publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds);
  34. for (PublishAccount publishAccount : publishAccountList) {
  35. String token = wxAccessTokenRemoteService.loadAccessToken(publishAccount.getGhId());
  36. if(StringUtils.isEmpty(token)) {
  37. log.error("token is null ghId:{}", publishAccount.getGhId());
  38. continue;
  39. }
  40. wxArticleDeleteService.clearQuota(token, publishAccount.getAppId());
  41. }
  42. }
  43. }