From 2ec6a0fe11230f9aa1955d3631b3e7ccf32447c2 Mon Sep 17 00:00:00 2001 From: foreveryang321 <453190450@qq.com> Date: Tue, 30 Jan 2024 10:20:31 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#3225=E3=80=90=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E3=80=91=E5=A4=9A=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E9=85=8D=E7=BD=AEstarter=E5=A2=9E=E5=8A=A0=20http=20?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E9=85=8D=E7=BD=AE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.md | 3 +- .../WxCpMultiAutoConfiguration.java | 8 +-- .../WxCpMultiServicesAutoConfiguration.java | 15 ++-- .../services/AbstractWxCpConfiguration.java | 71 ++++++++++++------- .../services/WxCpInJedisConfiguration.java | 6 +- .../services/WxCpInMemoryConfiguration.java | 6 +- .../WxCpInRedisTemplateConfiguration.java | 6 +- .../services/WxCpInRedissonConfiguration.java | 6 +- .../cp/properties/WxCpMultiProperties.java | 25 ++++++- .../properties/WxCpMultiRedisProperties.java | 2 + ...perties.java => WxCpSingleProperties.java} | 5 +- 11 files changed, 97 insertions(+), 56 deletions(-) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/{autoconfigure => configuration}/WxCpMultiServicesAutoConfiguration.java (51%) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/{autoconfigure => configuration}/services/AbstractWxCpConfiguration.java (61%) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/{autoconfigure => configuration}/services/WxCpInJedisConfiguration.java (92%) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/{autoconfigure => configuration}/services/WxCpInMemoryConfiguration.java (82%) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/{autoconfigure => configuration}/services/WxCpInRedisTemplateConfiguration.java (87%) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/{autoconfigure => configuration}/services/WxCpInRedissonConfiguration.java (91%) rename spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/{CorpProperties.java => WxCpSingleProperties.java} (82%) diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md index 6b1ddaeb3..e3ea7bf0f 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/README.md @@ -42,6 +42,8 @@ ## ConfigStorage 配置(选填) wx.cp.config-storage.type=memory # 配置类型: memory(默认), jedis, redisson, redistemplate ## http 客户端配置(选填) + ## # http客户端类型: http_client(默认), ok_http, jodd_http + wx.cp.config-storage.http-client-type=http_client wx.cp.config-storage.http-proxy-host= wx.cp.config-storage.http-proxy-port= wx.cp.config-storage.http-proxy-username= @@ -57,7 +59,6 @@ ```java import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; -import com.binarywang.spring.starter.wxjava.cp.service.WxCpServices; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpUserService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java index 8977b214b..40a6d9048 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiAutoConfiguration.java @@ -1,7 +1,6 @@ package com.binarywang.spring.starter.wxjava.cp.autoconfigure; -import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import com.binarywang.spring.starter.wxjava.cp.configuration.WxCpMultiServicesAutoConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -12,9 +11,6 @@ import org.springframework.context.annotation.Import; * created on 2023/10/16 */ @Configuration -@EnableConfigurationProperties(WxCpMultiProperties.class) -@Import({ - WxCpMultiServicesAutoConfiguration.class -}) +@Import(WxCpMultiServicesAutoConfiguration.class) public class WxCpMultiAutoConfiguration { } diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiServicesAutoConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/WxCpMultiServicesAutoConfiguration.java similarity index 51% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiServicesAutoConfiguration.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/WxCpMultiServicesAutoConfiguration.java index 743888cad..12a494730 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/WxCpMultiServicesAutoConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/WxCpMultiServicesAutoConfiguration.java @@ -1,10 +1,11 @@ -package com.binarywang.spring.starter.wxjava.cp.autoconfigure; +package com.binarywang.spring.starter.wxjava.cp.configuration; -import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInJedisConfiguration; -import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInMemoryConfiguration; -import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInRedisTemplateConfiguration; -import com.binarywang.spring.starter.wxjava.cp.autoconfigure.services.WxCpInRedissonConfiguration; -import lombok.RequiredArgsConstructor; +import com.binarywang.spring.starter.wxjava.cp.configuration.services.WxCpInJedisConfiguration; +import com.binarywang.spring.starter.wxjava.cp.configuration.services.WxCpInMemoryConfiguration; +import com.binarywang.spring.starter.wxjava.cp.configuration.services.WxCpInRedisTemplateConfiguration; +import com.binarywang.spring.starter.wxjava.cp.configuration.services.WxCpInRedissonConfiguration; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -15,7 +16,7 @@ import org.springframework.context.annotation.Import; * created on 2023/10/16 */ @Configuration -@RequiredArgsConstructor +@EnableConfigurationProperties(WxCpMultiProperties.class) @Import({ WxCpInJedisConfiguration.class, WxCpInMemoryConfiguration.class, diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/AbstractWxCpConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java similarity index 61% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/AbstractWxCpConfiguration.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java index ec45ceaa2..ec8aaa4f2 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/AbstractWxCpConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java @@ -1,13 +1,16 @@ -package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; +package com.binarywang.spring.starter.wxjava.cp.configuration.services; -import com.binarywang.spring.starter.wxjava.cp.properties.CorpProperties; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; +import com.binarywang.spring.starter.wxjava.cp.properties.WxCpSingleProperties; import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServicesImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.api.impl.WxCpServiceApacheHttpClientImpl; import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; +import me.chanjar.weixin.cp.api.impl.WxCpServiceJoddHttpImpl; +import me.chanjar.weixin.cp.api.impl.WxCpServiceOkHttpImpl; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; import org.apache.commons.lang3.StringUtils; @@ -28,8 +31,8 @@ import java.util.stream.Collectors; @Slf4j public abstract class AbstractWxCpConfiguration { - protected WxCpMultiServices configWxCpServices(WxCpMultiProperties wxCpMultiProperties) { - Map corps = wxCpMultiProperties.getCorps(); + protected WxCpMultiServices wxCpMultiServices(WxCpMultiProperties wxCpMultiProperties) { + Map corps = wxCpMultiProperties.getCorps(); if (corps == null || corps.isEmpty()) { log.warn("企业微信应用参数未配置,通过 WxCpMultiServices#getWxCpService(\"tenantId\")获取实例将返回空"); return new WxCpMultiServicesImpl(); @@ -39,13 +42,13 @@ public abstract class AbstractWxCpConfiguration { * * 查看 {@link me.chanjar.weixin.cp.config.impl.AbstractWxCpInRedisConfigImpl#setAgentId(Integer)} */ - Collection corpList = corps.values(); + Collection corpList = corps.values(); if (corpList.size() > 1) { // 先按 corpId 分组统计 - Map> corpsMap = corpList.stream() - .collect(Collectors.groupingBy(CorpProperties::getCorpId)); - Set>> entries = corpsMap.entrySet(); - for (Map.Entry> entry : entries) { + Map> corpsMap = corpList.stream() + .collect(Collectors.groupingBy(WxCpSingleProperties::getCorpId)); + Set>> entries = corpsMap.entrySet(); + for (Map.Entry> entry : entries) { String corpId = entry.getKey(); // 校验每个企业下,agentId 是否唯一 boolean multi = entry.getValue().stream() @@ -59,14 +62,14 @@ public abstract class AbstractWxCpConfiguration { } WxCpMultiServicesImpl services = new WxCpMultiServicesImpl(); - Set> entries = corps.entrySet(); - for (Map.Entry entry : entries) { + Set> entries = corps.entrySet(); + for (Map.Entry entry : entries) { String tenantId = entry.getKey(); - CorpProperties corpProperties = entry.getValue(); - WxCpDefaultConfigImpl storage = this.configWxCpDefaultConfigImpl(wxCpMultiProperties); - this.configCorp(storage, corpProperties); + WxCpSingleProperties wxCpSingleProperties = entry.getValue(); + WxCpDefaultConfigImpl storage = this.wxCpConfigStorage(wxCpMultiProperties); + this.configCorp(storage, wxCpSingleProperties); this.configHttp(storage, wxCpMultiProperties.getConfigStorage()); - WxCpService wxCpService = this.configWxCpService(storage, wxCpMultiProperties.getConfigStorage()); + WxCpService wxCpService = this.wxCpService(storage, wxCpMultiProperties.getConfigStorage()); services.addWxCpService(tenantId, wxCpService); } return services; @@ -78,12 +81,26 @@ public abstract class AbstractWxCpConfiguration { * @param wxCpMultiProperties 参数 * @return WxCpDefaultConfigImpl */ - protected abstract WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties); + protected abstract WxCpDefaultConfigImpl wxCpConfigStorage(WxCpMultiProperties wxCpMultiProperties); - private WxCpService configWxCpService(WxCpConfigStorage wxCpConfigStorage, WxCpMultiProperties.ConfigStorage storage) { - WxCpService wxCpService = new WxCpServiceImpl(); + private WxCpService wxCpService(WxCpConfigStorage wxCpConfigStorage, WxCpMultiProperties.ConfigStorage storage) { + WxCpMultiProperties.HttpClientType httpClientType = storage.getHttpClientType(); + WxCpService wxCpService; + switch (httpClientType) { + case OK_HTTP: + wxCpService = new WxCpServiceOkHttpImpl(); + break; + case JODD_HTTP: + wxCpService = new WxCpServiceJoddHttpImpl(); + break; + case HTTP_CLIENT: + wxCpService = new WxCpServiceApacheHttpClientImpl(); + break; + default: + wxCpService = new WxCpServiceImpl(); + break; + } wxCpService.setWxCpConfigStorage(wxCpConfigStorage); - int maxRetryTimes = storage.getMaxRetryTimes(); if (maxRetryTimes < 0) { maxRetryTimes = 0; @@ -97,15 +114,15 @@ public abstract class AbstractWxCpConfiguration { return wxCpService; } - private void configCorp(WxCpDefaultConfigImpl config, CorpProperties corpProperties) { - String corpId = corpProperties.getCorpId(); - String corpSecret = corpProperties.getCorpSecret(); - Integer agentId = corpProperties.getAgentId(); - String token = corpProperties.getToken(); - String aesKey = corpProperties.getAesKey(); + private void configCorp(WxCpDefaultConfigImpl config, WxCpSingleProperties wxCpSingleProperties) { + String corpId = wxCpSingleProperties.getCorpId(); + String corpSecret = wxCpSingleProperties.getCorpSecret(); + Integer agentId = wxCpSingleProperties.getAgentId(); + String token = wxCpSingleProperties.getToken(); + String aesKey = wxCpSingleProperties.getAesKey(); // 企业微信,私钥,会话存档路径 - String msgAuditPriKey = corpProperties.getMsgAuditPriKey(); - String msgAuditLibPath = corpProperties.getMsgAuditLibPath(); + String msgAuditPriKey = wxCpSingleProperties.getMsgAuditPriKey(); + String msgAuditLibPath = wxCpSingleProperties.getMsgAuditLibPath(); config.setCorpId(corpId); config.setCorpSecret(corpSecret); diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInJedisConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInJedisConfiguration.java similarity index 92% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInJedisConfiguration.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInJedisConfiguration.java index 3e49a5024..e03647cb6 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInJedisConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInJedisConfiguration.java @@ -1,4 +1,4 @@ -package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; +package com.binarywang.spring.starter.wxjava.cp.configuration.services; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiRedisProperties; @@ -31,11 +31,11 @@ public class WxCpInJedisConfiguration extends AbstractWxCpConfiguration { @Bean public WxCpMultiServices wxCpMultiServices() { - return this.configWxCpServices(wxCpMultiProperties); + return this.wxCpMultiServices(wxCpMultiProperties); } @Override - protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + protected WxCpDefaultConfigImpl wxCpConfigStorage(WxCpMultiProperties wxCpMultiProperties) { return this.configRedis(wxCpMultiProperties); } diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInMemoryConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInMemoryConfiguration.java similarity index 82% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInMemoryConfiguration.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInMemoryConfiguration.java index dd0946fc5..29593667e 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInMemoryConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInMemoryConfiguration.java @@ -1,4 +1,4 @@ -package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; +package com.binarywang.spring.starter.wxjava.cp.configuration.services; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; @@ -24,11 +24,11 @@ public class WxCpInMemoryConfiguration extends AbstractWxCpConfiguration { @Bean public WxCpMultiServices wxCpMultiServices() { - return this.configWxCpServices(wxCpMultiProperties); + return this.wxCpMultiServices(wxCpMultiProperties); } @Override - protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + protected WxCpDefaultConfigImpl wxCpConfigStorage(WxCpMultiProperties wxCpMultiProperties) { return this.configInMemory(); } diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedisTemplateConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInRedisTemplateConfiguration.java similarity index 87% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedisTemplateConfiguration.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInRedisTemplateConfiguration.java index 103956fed..374c5cdfb 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedisTemplateConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInRedisTemplateConfiguration.java @@ -1,4 +1,4 @@ -package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; +package com.binarywang.spring.starter.wxjava.cp.configuration.services; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; import com.binarywang.spring.starter.wxjava.cp.service.WxCpMultiServices; @@ -28,11 +28,11 @@ public class WxCpInRedisTemplateConfiguration extends AbstractWxCpConfiguration @Bean public WxCpMultiServices wxCpMultiServices() { - return this.configWxCpServices(wxCpMultiProperties); + return this.wxCpMultiServices(wxCpMultiProperties); } @Override - protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + protected WxCpDefaultConfigImpl wxCpConfigStorage(WxCpMultiProperties wxCpMultiProperties) { return this.configRedisTemplate(wxCpMultiProperties); } diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedissonConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInRedissonConfiguration.java similarity index 91% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedissonConfiguration.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInRedissonConfiguration.java index b8fc3a83a..c0753a44a 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/autoconfigure/services/WxCpInRedissonConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/WxCpInRedissonConfiguration.java @@ -1,4 +1,4 @@ -package com.binarywang.spring.starter.wxjava.cp.autoconfigure.services; +package com.binarywang.spring.starter.wxjava.cp.configuration.services; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiProperties; import com.binarywang.spring.starter.wxjava.cp.properties.WxCpMultiRedisProperties; @@ -33,11 +33,11 @@ public class WxCpInRedissonConfiguration extends AbstractWxCpConfiguration { @Bean public WxCpMultiServices wxCpMultiServices() { - return this.configWxCpServices(wxCpMultiProperties); + return this.wxCpMultiServices(wxCpMultiProperties); } @Override - protected WxCpDefaultConfigImpl configWxCpDefaultConfigImpl(WxCpMultiProperties wxCpMultiProperties) { + protected WxCpDefaultConfigImpl wxCpConfigStorage(WxCpMultiProperties wxCpMultiProperties) { return this.configRedisson(wxCpMultiProperties); } diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java index 2d2b418ad..ab694a30b 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiProperties.java @@ -18,10 +18,11 @@ import java.util.Map; @Data @NoArgsConstructor @ConfigurationProperties(prefix = WxCpMultiProperties.PREFIX) -public class WxCpMultiProperties { +public class WxCpMultiProperties implements Serializable { + private static final long serialVersionUID = -1569510477055668503L; public static final String PREFIX = "wx.cp"; - private Map corps = new HashMap<>(); + private Map corps = new HashMap<>(); /** * 配置存储策略,默认内存 @@ -48,6 +49,11 @@ public class WxCpMultiProperties { @NestedConfigurationProperty private WxCpMultiRedisProperties redis = new WxCpMultiRedisProperties(); + /** + * http客户端类型. + */ + private HttpClientType httpClientType = HttpClientType.HTTP_CLIENT; + /** * http代理主机 */ @@ -105,4 +111,19 @@ public class WxCpMultiProperties { */ redistemplate } + + public enum HttpClientType { + /** + * HttpClient + */ + HTTP_CLIENT, + /** + * OkHttp + */ + OK_HTTP, + /** + * JoddHttp + */ + JODD_HTTP + } } diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java index e684333ae..ea1f257c4 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpMultiRedisProperties.java @@ -1,6 +1,7 @@ package com.binarywang.spring.starter.wxjava.cp.properties; import lombok.Data; +import lombok.NoArgsConstructor; import java.io.Serializable; @@ -11,6 +12,7 @@ import java.io.Serializable; * created on 2023/10/16 */ @Data +@NoArgsConstructor public class WxCpMultiRedisProperties implements Serializable { private static final long serialVersionUID = -5924815351660074401L; diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/CorpProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java similarity index 82% rename from spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/CorpProperties.java rename to spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java index 354078d05..ec1b97899 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/CorpProperties.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java @@ -3,6 +3,8 @@ package com.binarywang.spring.starter.wxjava.cp.properties; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + /** * 企业微信企业相关配置属性 * @@ -11,7 +13,8 @@ import lombok.NoArgsConstructor; */ @Data @NoArgsConstructor -public class CorpProperties { +public class WxCpSingleProperties implements Serializable { + private static final long serialVersionUID = -7502823825007859418L; /** * 微信企业号 corpId */