package com.tzld.longarticle.recommend.server; 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 private LongArticleBaseMapper longArticleBaseMapper; @Resource private PublishAccountRepository publishAccountRepository; @Resource private WxAccessTokenRemoteService wxAccessTokenRemoteService; @Resource private WxArticleDeleteService wxArticleDeleteService; @Resource private PublishContentMapper publishContentMapper; @Resource private ArticleAuditService articleAuditService; @Test public void clearQuotaTest() { List ghIds = longArticleBaseMapper.getDisAuditDeleteGhid(); List publishAccountList = publishAccountRepository.getAllByGhIdIn(ghIds); for (PublishAccount publishAccount : publishAccountList) { String token = wxAccessTokenRemoteService.loadAccessToken(publishAccount.getGhId()); if(StringUtils.isEmpty(token)) { log.error("token is null ghId:{}", publishAccount.getGhId()); continue; } wxArticleDeleteService.clearQuota(token, publishAccount.getAppId()); } } }