45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
package com.zeekling.solo.wechat.conf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
|
|
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @author zeekling [lingzhaohui@zeekling.cn]
|
|
* @version 1.0
|
|
* @apiNote
|
|
* @since 2020-03-18
|
|
*/
|
|
@AllArgsConstructor
|
|
@Configuration
|
|
public class WeChatBeans {
|
|
|
|
@Resource
|
|
private WeChatConfigure weChatConfigure;
|
|
|
|
@Bean
|
|
public WxMpService wxMpService() {
|
|
WxMpService service = new WxMpServiceImpl();
|
|
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
|
|
configStorage.setAppId(weChatConfigure.getAppId());
|
|
configStorage.setSecret(weChatConfigure.getSecret());
|
|
configStorage.setToken(weChatConfigure.getToken());
|
|
configStorage.setAesKey(weChatConfigure.getAesKey());
|
|
Map<String, WxMpConfigStorage> configStorageMap = new HashMap<>();
|
|
configStorageMap.put(weChatConfigure.getAppId(), configStorage);
|
|
service.setMultiConfigStorages(configStorageMap);
|
|
return service;
|
|
}
|
|
|
|
|
|
|
|
}
|