From b0ff3f0e93e70961e49e76c32378529722e24bb0 Mon Sep 17 00:00:00 2001 From: Mario Luo Date: Thu, 29 Aug 2019 09:10:04 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20#1182=20=E4=BF=AE=E5=A4=8D=E5=85=AC?= =?UTF-8?q?=E4=BC=97=E5=8F=B7spring-boot-starter=20jedis=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=96=B9=E4=BE=BF=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=B3=A8=E5=85=A5=E5=AD=90service=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wx-java-mp-spring-boot-starter/pom.xml | 1 + .../config/WxMpServiceAutoConfiguration.java | 134 ++++++++++++++---- 2 files changed, 106 insertions(+), 29 deletions(-) diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml b/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml index 296c67c13a..da66b5e744 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml @@ -38,6 +38,7 @@ redis.clients jedis + compile org.projectlombok diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpServiceAutoConfiguration.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpServiceAutoConfiguration.java index c39402ac72..7d96226733 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpServiceAutoConfiguration.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpServiceAutoConfiguration.java @@ -1,13 +1,9 @@ package com.binarywang.spring.starter.wxjava.mp.config; -import me.chanjar.weixin.mp.config.WxMpConfigStorage; -import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.api.*; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import me.chanjar.weixin.mp.config.WxMpConfigStorage; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -18,38 +14,118 @@ */ @Configuration public class WxMpServiceAutoConfiguration { - @Autowired - private ApplicationContext ctx; @Bean @ConditionalOnMissingBean public WxMpService wxMpService(WxMpConfigStorage configStorage) { WxMpService wxMpService = new WxMpServiceImpl(); wxMpService.setWxMpConfigStorage(configStorage); - registerWxMpSubService(wxMpService); return wxMpService; } - @ConditionalOnBean(WxMpService.class) - public Object registerWxMpSubService(WxMpService wxMpService) { - ConfigurableListableBeanFactory factory = (ConfigurableListableBeanFactory) ctx.getAutowireCapableBeanFactory(); - factory.registerSingleton("wxMpKefuService", wxMpService.getKefuService()); - factory.registerSingleton("wxMpMaterialService", wxMpService.getMaterialService()); - factory.registerSingleton("wxMpMenuService", wxMpService.getMenuService()); - factory.registerSingleton("wxMpUserService", wxMpService.getUserService()); - factory.registerSingleton("wxMpUserTagService", wxMpService.getUserTagService()); - factory.registerSingleton("wxMpQrcodeService", wxMpService.getQrcodeService()); - factory.registerSingleton("wxMpCardService", wxMpService.getCardService()); - factory.registerSingleton("wxMpDataCubeService", wxMpService.getDataCubeService()); - factory.registerSingleton("wxMpUserBlacklistService", wxMpService.getBlackListService()); - factory.registerSingleton("wxMpStoreService", wxMpService.getStoreService()); - factory.registerSingleton("wxMpTemplateMsgService", wxMpService.getTemplateMsgService()); - factory.registerSingleton("wxMpSubscribeMsgService", wxMpService.getSubscribeMsgService()); - factory.registerSingleton("wxMpDeviceService", wxMpService.getDeviceService()); - factory.registerSingleton("wxMpShakeService", wxMpService.getShakeService()); - factory.registerSingleton("wxMpMemberCardService", wxMpService.getMemberCardService()); - factory.registerSingleton("wxMpMassMessageService", wxMpService.getMassMessageService()); - return Boolean.TRUE; + @Bean + public WxMpKefuService wxMpKefuService(WxMpService wxMpService) { + return wxMpService.getKefuService(); + } + + @Bean + public WxMpMaterialService wxMpMaterialService(WxMpService wxMpService) { + return wxMpService.getMaterialService(); + } + + @Bean + public WxMpMenuService wxMpMenuService(WxMpService wxMpService) { + return wxMpService.getMenuService(); + } + + @Bean + public WxMpUserService wxMpUserService(WxMpService wxMpService) { + return wxMpService.getUserService(); + } + + @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(); } }