package com.ruoyi.common.config; import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; /** * Created by tao. * Date: 2023/3/21 15:00 * 描述: */ @Component public class WechatMpConfig { @Autowired private WechatAccountConfig accountConfig; /** * @author :tao * @date :Created in 2021/3/12 10:15 * @param: : * @return: WxMpService 对象 * 配置wxMpConfigStorage,返回 WxMpService 对象 */ @Bean public WxMpService wxMpService() { WxMpService wxMpService = new WxMpServiceImpl(); wxMpService.setWxMpConfigStorage(wxMpConfigStorage()); return wxMpService; } /** * @author :tao * @date :Created in 2021/3/12 10:20 * @param: : * @return: WxMpConfigStorage 对象 * 配置AppId、和AppSecret,获取WxMpConfigStorage 对象 */ @Bean public WxMpConfigStorage wxMpConfigStorage() { WxMpInMemoryConfigStorage wxMpConfigStorage = new WxMpInMemoryConfigStorage(); wxMpConfigStorage.setAppId(accountConfig.getMpAppId()); wxMpConfigStorage.setSecret(accountConfig.getMpAppSecret()); return wxMpConfigStorage; } }