|
1 | 1 | package com.github.binarywang.demo.wx.mp.config;
|
2 | 2 |
|
| 3 | +import java.util.List; |
3 | 4 | import java.util.Map;
|
4 | 5 | import java.util.stream.Collectors;
|
5 | 6 |
|
@@ -80,20 +81,23 @@ public static Map<String, WxMpService> getMpServices() {
|
80 | 81 | @Bean
|
81 | 82 | public Object services() {
|
82 | 83 | // 代码里getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!!
|
83 |
| - mpServices = this.properties.getConfigs() |
84 |
| - .stream() |
85 |
| - .map(a -> { |
86 |
| - WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); |
87 |
| - configStorage.setAppId(a.getAppId()); |
88 |
| - configStorage.setSecret(a.getSecret()); |
89 |
| - configStorage.setToken(a.getToken()); |
90 |
| - configStorage.setAesKey(a.getAesKey()); |
91 |
| - |
92 |
| - WxMpService service = new WxMpServiceImpl(); |
93 |
| - service.setWxMpConfigStorage(configStorage); |
94 |
| - routers.put(a.getAppId(), this.newRouter(service)); |
95 |
| - return service; |
96 |
| - }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a)); |
| 84 | + final List<WxMpProperties.MpConfig> configs = this.properties.getConfigs(); |
| 85 | + if (configs == null) { |
| 86 | + throw new RuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!"); |
| 87 | + } |
| 88 | + |
| 89 | + mpServices = configs.stream().map(a -> { |
| 90 | + WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage(); |
| 91 | + configStorage.setAppId(a.getAppId()); |
| 92 | + configStorage.setSecret(a.getSecret()); |
| 93 | + configStorage.setToken(a.getToken()); |
| 94 | + configStorage.setAesKey(a.getAesKey()); |
| 95 | + |
| 96 | + WxMpService service = new WxMpServiceImpl(); |
| 97 | + service.setWxMpConfigStorage(configStorage); |
| 98 | + routers.put(a.getAppId(), this.newRouter(service)); |
| 99 | + return service; |
| 100 | + }).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o)); |
97 | 101 |
|
98 | 102 | return Boolean.TRUE;
|
99 | 103 | }
|
|
0 commit comments