jhprjv2/ruoyi-common/src/main/java/com/ruoyi/common/config/WechatMpConfig.java

55 lines
1.6 KiB
Java
Raw Normal View History

2024-03-31 23:31:38 +08:00
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
* AppIdAppSecretWxMpConfigStorage
*/
@Bean
public WxMpConfigStorage wxMpConfigStorage() {
WxMpInMemoryConfigStorage wxMpConfigStorage = new WxMpInMemoryConfigStorage();
wxMpConfigStorage.setAppId(accountConfig.getMpAppId());
wxMpConfigStorage.setSecret(accountConfig.getMpAppSecret());
2024-04-03 01:46:39 +08:00
wxMpConfigStorage.setToken(accountConfig.getMyToken());
wxMpConfigStorage.setAccessToken(accountConfig.getMyAccessToken());
2024-03-31 23:31:38 +08:00
return wxMpConfigStorage;
}
}