|
1 | 1 | package com.binarywang.spring.starter.wxjava.mp.config;
|
2 | 2 |
|
3 |
| -import me.chanjar.weixin.mp.config.WxMpConfigStorage; |
4 |
| -import me.chanjar.weixin.mp.api.WxMpService; |
| 3 | +import me.chanjar.weixin.mp.api.*; |
5 | 4 | import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
6 |
| -import org.springframework.beans.factory.annotation.Autowired; |
7 |
| -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
8 |
| -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
| 5 | +import me.chanjar.weixin.mp.config.WxMpConfigStorage; |
9 | 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
10 |
| -import org.springframework.context.ApplicationContext; |
11 | 7 | import org.springframework.context.annotation.Bean;
|
12 | 8 | import org.springframework.context.annotation.Configuration;
|
13 | 9 |
|
|
18 | 14 | */
|
19 | 15 | @Configuration
|
20 | 16 | public class WxMpServiceAutoConfiguration {
|
21 |
| - @Autowired |
22 |
| - private ApplicationContext ctx; |
23 | 17 |
|
24 | 18 | @Bean
|
25 | 19 | @ConditionalOnMissingBean
|
26 | 20 | public WxMpService wxMpService(WxMpConfigStorage configStorage) {
|
27 | 21 | WxMpService wxMpService = new WxMpServiceImpl();
|
28 | 22 | wxMpService.setWxMpConfigStorage(configStorage);
|
29 |
| - registerWxMpSubService(wxMpService); |
30 | 23 | return wxMpService;
|
31 | 24 | }
|
32 | 25 |
|
33 |
| - @ConditionalOnBean(WxMpService.class) |
34 |
| - public Object registerWxMpSubService(WxMpService wxMpService) { |
35 |
| - ConfigurableListableBeanFactory factory = (ConfigurableListableBeanFactory) ctx.getAutowireCapableBeanFactory(); |
36 |
| - factory.registerSingleton("wxMpKefuService", wxMpService.getKefuService()); |
37 |
| - factory.registerSingleton("wxMpMaterialService", wxMpService.getMaterialService()); |
38 |
| - factory.registerSingleton("wxMpMenuService", wxMpService.getMenuService()); |
39 |
| - factory.registerSingleton("wxMpUserService", wxMpService.getUserService()); |
40 |
| - factory.registerSingleton("wxMpUserTagService", wxMpService.getUserTagService()); |
41 |
| - factory.registerSingleton("wxMpQrcodeService", wxMpService.getQrcodeService()); |
42 |
| - factory.registerSingleton("wxMpCardService", wxMpService.getCardService()); |
43 |
| - factory.registerSingleton("wxMpDataCubeService", wxMpService.getDataCubeService()); |
44 |
| - factory.registerSingleton("wxMpUserBlacklistService", wxMpService.getBlackListService()); |
45 |
| - factory.registerSingleton("wxMpStoreService", wxMpService.getStoreService()); |
46 |
| - factory.registerSingleton("wxMpTemplateMsgService", wxMpService.getTemplateMsgService()); |
47 |
| - factory.registerSingleton("wxMpSubscribeMsgService", wxMpService.getSubscribeMsgService()); |
48 |
| - factory.registerSingleton("wxMpDeviceService", wxMpService.getDeviceService()); |
49 |
| - factory.registerSingleton("wxMpShakeService", wxMpService.getShakeService()); |
50 |
| - factory.registerSingleton("wxMpMemberCardService", wxMpService.getMemberCardService()); |
51 |
| - factory.registerSingleton("wxMpMassMessageService", wxMpService.getMassMessageService()); |
52 |
| - return Boolean.TRUE; |
| 26 | + @Bean |
| 27 | + public WxMpKefuService wxMpKefuService(WxMpService wxMpService) { |
| 28 | + return wxMpService.getKefuService(); |
| 29 | + } |
| 30 | + |
| 31 | + @Bean |
| 32 | + public WxMpMaterialService wxMpMaterialService(WxMpService wxMpService) { |
| 33 | + return wxMpService.getMaterialService(); |
| 34 | + } |
| 35 | + |
| 36 | + @Bean |
| 37 | + public WxMpMenuService wxMpMenuService(WxMpService wxMpService) { |
| 38 | + return wxMpService.getMenuService(); |
| 39 | + } |
| 40 | + |
| 41 | + @Bean |
| 42 | + public WxMpUserService wxMpUserService(WxMpService wxMpService) { |
| 43 | + return wxMpService.getUserService(); |
| 44 | + } |
| 45 | + |
| 46 | + @Bean |
| 47 | + public WxMpUserTagService wxMpUserTagService(WxMpService wxMpService) { |
| 48 | + return wxMpService.getUserTagService(); |
| 49 | + } |
| 50 | + |
| 51 | + @Bean |
| 52 | + public WxMpQrcodeService wxMpQrcodeService(WxMpService wxMpService) { |
| 53 | + return wxMpService.getQrcodeService(); |
| 54 | + } |
| 55 | + |
| 56 | + @Bean |
| 57 | + public WxMpCardService wxMpCardService(WxMpService wxMpService) { |
| 58 | + return wxMpService.getCardService(); |
| 59 | + } |
| 60 | + |
| 61 | + @Bean |
| 62 | + public WxMpDataCubeService wxMpDataCubeService(WxMpService wxMpService) { |
| 63 | + return wxMpService.getDataCubeService(); |
| 64 | + } |
| 65 | + |
| 66 | + @Bean |
| 67 | + public WxMpUserBlacklistService wxMpUserBlacklistService(WxMpService wxMpService) { |
| 68 | + return wxMpService.getBlackListService(); |
| 69 | + } |
| 70 | + |
| 71 | + @Bean |
| 72 | + public WxMpStoreService wxMpStoreService(WxMpService wxMpService) { |
| 73 | + return wxMpService.getStoreService(); |
| 74 | + } |
| 75 | + |
| 76 | + @Bean |
| 77 | + public WxMpTemplateMsgService wxMpTemplateMsgService(WxMpService wxMpService) { |
| 78 | + return wxMpService.getTemplateMsgService(); |
| 79 | + } |
| 80 | + |
| 81 | + @Bean |
| 82 | + public WxMpSubscribeMsgService wxMpSubscribeMsgService(WxMpService wxMpService) { |
| 83 | + return wxMpService.getSubscribeMsgService(); |
| 84 | + } |
| 85 | + |
| 86 | + @Bean |
| 87 | + public WxMpDeviceService wxMpDeviceService(WxMpService wxMpService) { |
| 88 | + return wxMpService.getDeviceService(); |
| 89 | + } |
| 90 | + |
| 91 | + @Bean |
| 92 | + public WxMpShakeService wxMpShakeService(WxMpService wxMpService) { |
| 93 | + return wxMpService.getShakeService(); |
| 94 | + } |
| 95 | + |
| 96 | + @Bean |
| 97 | + public WxMpMemberCardService wxMpMemberCardService(WxMpService wxMpService) { |
| 98 | + return wxMpService.getMemberCardService(); |
| 99 | + } |
| 100 | + |
| 101 | + @Bean |
| 102 | + public WxMpMassMessageService wxMpMassMessageService(WxMpService wxMpService) { |
| 103 | + return wxMpService.getMassMessageService(); |
| 104 | + } |
| 105 | + |
| 106 | + @Bean |
| 107 | + public WxMpAiOpenService wxMpAiOpenService(WxMpService wxMpService) { |
| 108 | + return wxMpService.getAiOpenService(); |
| 109 | + } |
| 110 | + |
| 111 | + @Bean |
| 112 | + public WxMpWifiService wxMpWifiService(WxMpService wxMpService) { |
| 113 | + return wxMpService.getWifiService(); |
| 114 | + } |
| 115 | + |
| 116 | + @Bean |
| 117 | + public WxMpMarketingService wxMpMarketingService(WxMpService wxMpService) { |
| 118 | + return wxMpService.getMarketingService(); |
| 119 | + } |
| 120 | + |
| 121 | + @Bean |
| 122 | + public WxMpCommentService wxMpCommentService(WxMpService wxMpService) { |
| 123 | + return wxMpService.getCommentService(); |
| 124 | + } |
| 125 | + |
| 126 | + @Bean |
| 127 | + public WxMpOcrService wxMpOcrService(WxMpService wxMpService) { |
| 128 | + return wxMpService.getOcrService(); |
53 | 129 | }
|
54 | 130 |
|
55 | 131 | }
|
0 commit comments