mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🐛 #1182 修复公众号spring-boot-starter jedis依赖丢失问题,并优化代码,方便直接注入子service对象
This commit is contained in:
parent
2eb0aa574c
commit
b0ff3f0e93
@ -38,6 +38,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>redis.clients</groupId>
|
<groupId>redis.clients</groupId>
|
||||||
<artifactId>jedis</artifactId>
|
<artifactId>jedis</artifactId>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package com.binarywang.spring.starter.wxjava.mp.config;
|
package com.binarywang.spring.starter.wxjava.mp.config;
|
||||||
|
|
||||||
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
|
import me.chanjar.weixin.mp.api.*;
|
||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@ -18,38 +14,118 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WxMpServiceAutoConfiguration {
|
public class WxMpServiceAutoConfiguration {
|
||||||
@Autowired
|
|
||||||
private ApplicationContext ctx;
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public WxMpService wxMpService(WxMpConfigStorage configStorage) {
|
public WxMpService wxMpService(WxMpConfigStorage configStorage) {
|
||||||
WxMpService wxMpService = new WxMpServiceImpl();
|
WxMpService wxMpService = new WxMpServiceImpl();
|
||||||
wxMpService.setWxMpConfigStorage(configStorage);
|
wxMpService.setWxMpConfigStorage(configStorage);
|
||||||
registerWxMpSubService(wxMpService);
|
|
||||||
return wxMpService;
|
return wxMpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConditionalOnBean(WxMpService.class)
|
@Bean
|
||||||
public Object registerWxMpSubService(WxMpService wxMpService) {
|
public WxMpKefuService wxMpKefuService(WxMpService wxMpService) {
|
||||||
ConfigurableListableBeanFactory factory = (ConfigurableListableBeanFactory) ctx.getAutowireCapableBeanFactory();
|
return wxMpService.getKefuService();
|
||||||
factory.registerSingleton("wxMpKefuService", wxMpService.getKefuService());
|
}
|
||||||
factory.registerSingleton("wxMpMaterialService", wxMpService.getMaterialService());
|
|
||||||
factory.registerSingleton("wxMpMenuService", wxMpService.getMenuService());
|
@Bean
|
||||||
factory.registerSingleton("wxMpUserService", wxMpService.getUserService());
|
public WxMpMaterialService wxMpMaterialService(WxMpService wxMpService) {
|
||||||
factory.registerSingleton("wxMpUserTagService", wxMpService.getUserTagService());
|
return wxMpService.getMaterialService();
|
||||||
factory.registerSingleton("wxMpQrcodeService", wxMpService.getQrcodeService());
|
}
|
||||||
factory.registerSingleton("wxMpCardService", wxMpService.getCardService());
|
|
||||||
factory.registerSingleton("wxMpDataCubeService", wxMpService.getDataCubeService());
|
@Bean
|
||||||
factory.registerSingleton("wxMpUserBlacklistService", wxMpService.getBlackListService());
|
public WxMpMenuService wxMpMenuService(WxMpService wxMpService) {
|
||||||
factory.registerSingleton("wxMpStoreService", wxMpService.getStoreService());
|
return wxMpService.getMenuService();
|
||||||
factory.registerSingleton("wxMpTemplateMsgService", wxMpService.getTemplateMsgService());
|
}
|
||||||
factory.registerSingleton("wxMpSubscribeMsgService", wxMpService.getSubscribeMsgService());
|
|
||||||
factory.registerSingleton("wxMpDeviceService", wxMpService.getDeviceService());
|
@Bean
|
||||||
factory.registerSingleton("wxMpShakeService", wxMpService.getShakeService());
|
public WxMpUserService wxMpUserService(WxMpService wxMpService) {
|
||||||
factory.registerSingleton("wxMpMemberCardService", wxMpService.getMemberCardService());
|
return wxMpService.getUserService();
|
||||||
factory.registerSingleton("wxMpMassMessageService", wxMpService.getMassMessageService());
|
}
|
||||||
return Boolean.TRUE;
|
|
||||||
|
@Bean
|
||||||
|
public WxMpUserTagService wxMpUserTagService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getUserTagService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpQrcodeService wxMpQrcodeService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getQrcodeService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpCardService wxMpCardService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getCardService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpDataCubeService wxMpDataCubeService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getDataCubeService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpUserBlacklistService wxMpUserBlacklistService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getBlackListService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpStoreService wxMpStoreService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getStoreService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpTemplateMsgService wxMpTemplateMsgService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getTemplateMsgService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpSubscribeMsgService wxMpSubscribeMsgService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getSubscribeMsgService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpDeviceService wxMpDeviceService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getDeviceService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpShakeService wxMpShakeService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getShakeService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpMemberCardService wxMpMemberCardService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getMemberCardService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpMassMessageService wxMpMassMessageService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getMassMessageService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpAiOpenService wxMpAiOpenService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getAiOpenService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpWifiService wxMpWifiService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getWifiService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpMarketingService wxMpMarketingService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getMarketingService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpCommentService wxMpCommentService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getCommentService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMpOcrService wxMpOcrService(WxMpService wxMpService) {
|
||||||
|
return wxMpService.getOcrService();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user