48 lines
1.5 KiB
Java
48 lines
1.5 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.boot.context.properties.EnableConfigurationProperties;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* @author zeekling [lingzhaohui@zeekling.cn]
|
|
* @version 1.0
|
|
* @apiNote
|
|
* @since 2020-03-18
|
|
*/
|
|
@AllArgsConstructor
|
|
@Configuration
|
|
public class WeChatBeans {
|
|
|
|
@Resource
|
|
private WeXinConfigure weXinConfigure;
|
|
|
|
@Bean
|
|
public WxMpService wxMpService() {
|
|
WxMpService service = new WxMpServiceImpl();
|
|
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
|
|
configStorage.setAppId(weXinConfigure.getAppId());
|
|
configStorage.setSecret(weXinConfigure.getSecret());
|
|
configStorage.setToken(weXinConfigure.getToken());
|
|
configStorage.setAesKey(weXinConfigure.getAesKey());
|
|
Map<String, WxMpConfigStorage> configStorageMap = new HashMap<>();
|
|
configStorageMap.put(weXinConfigure.getAppId(), configStorage);
|
|
service.setMultiConfigStorages(configStorageMap);
|
|
return service;
|
|
}
|
|
|
|
|
|
|
|
}
|