mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-02 12:38:22 +08:00
合并develop分支,发布最新正式版
* art:证书类配置读取优化调整 * new:电商收付通二级商户进件 * art:微信服务商配置优化 * new:jsapi合单支付 * new:合单支付 * 🎨 #1733 微信支付服务商配置优化,增加服务商合单支付接口 * art:微信服务商配置优化 * new:jsapi合单支付 * new:合单支付 Co-authored-by: 曾浩 <epdcgsi@dingtalk.com> * 🎨 优化代码 * 🎨 优化重构并统一公众号和小程序的spring boot starter部分配置类和属性 * 🎨 优化企业微信消息发送接口代码,引入moco模拟测试组件,方便测试代码 * 🎨 #1722 企业微信增加互联企业发送应用消息的接口,并重构消息相关类的包结构 * 🎨 优化代码,使用java8自带的Base64类 * 🐛 #1738 修复企业微信创建用户接口自定义字段缺失的问题 * 🎨 升级依赖的Spring Boot版本为最新,并优化部分代码 * 🔖 发布 3.9.1.B 测试版本 * 🎨 #1743 企业微信获取客户群详情接口增加unionId属性 获取客户群详情对象中 增加 unionId属性 * new:电商收付通普通支付 * 🆕 #1744 微信支付增加电商收付通-普通支付相关接口 * new:电商收付通普通支付 Co-authored-by: 曾浩 <epdcgsi@dingtalk.com> * new:电商收付通支付回调处理 * new:电商收付通支付回调处理 * 🆕 #1749 微信支付增加电商收付通支付回调处理相关方法 * new:电商收付通支付回调处理 Co-authored-by: 曾浩 <epdcgsi@dingtalk.com> * 🎨 #1752 微信支付电商收付通二级商户进件时店铺信息增加小程序appid字段 * 🎨 优化部分代码 * 电商收付通支付调整 * 🎨 电商收付通支付接口调整 经测试小程序支付时不能使用服务商的appId签名,故增加方法返回微信接口返回的结果。 * 🎨 #1756 解决wx-java-open-spring-boot-starter中Redisson实现缺少database设置的问题 * 🎨 #1753 小程序直播部分接口代码优化重构,对照官方文档补充新增参数 * 🎨 #1747 微信支付分回调通知对象类增加缺失参数:回调摘要summary * 🆕 #1758 微信支付增加电商收付通服务商和二级商户余额查询接口 * 🆕 #1759 微信支付增加电商收付通请求分账接口 * 增加微信收付通请求分账接口 * 🆕 #1723 企业微信增加查询应用消息发送统计的接口 * 🔖 发布 3.9.2.B 测试版本 * 🆕 #1764 微信支付电商收付通增加请求分账回退接口 * 🐛 #1766 修复电商收付通请求分账结果类未添加相关注解的问题 * 微信收付通增加请求分账回退接口 * 修复请求分账结果未添加lombok注解 * fix:电商收付通回调通知测试 * 🆕 #1768 微信支付增加电商收付通完结分账和退款接口 * 微信收付通增加完结分账和退款接口 * 🆕 #1767 企业微信外部联系人增加修改客户备注信息的接口 * 🎨 优化部分代码 * 🎨 #1646 企业微信第三方应用(服务商)模块重构实现,并提供Router、Interceptor、Handler等接口 * 🎨 #1755 完善补充第三方平台小程序相关的部分错误码 * 🎨 优化企业微信群机器人发送消息的相关接口,提供无需提前设置webhookKey即可使用的重构方法 * 🆕 #1675 企业微信增加创建日历的接口,以及相关回调事件消息通知的支持 * 🔖 发布 3.9.3.B 测试版本 * new:电商收付通合单支付、普通支付查询 * new:电商收付通商户、平台提现 * fix:命名统一调整 * 🆕 #1772 电商收付通增加支付结果查询和提现的接口 * new:分账查询、退款通知 * new:修改结算账户、退款查询 * 🆕 #1775 微信支付电商收付通增加修改二级商户结算账户和退款查询的接口 * 🐛 #1777 XML工具类修复无法解析<ExtAttr><Item>这种节点数据的问题 * 🎨 WxMpMessageRouter增加构造方法 * 🎨 升级依赖jodd-http版本,并修复不兼容代码 * 🎨 优化GraalProcessor代码 * #1782 微信支付修复分账回退查询接口签名错误的问题 Co-authored-by: lmh <lmh@weiyian.com> * 🆕 #1774 企业微信增加系统审批事件推送的事件常量 * 🎨 优化代码 * 🎨 #1785 公众号 spring boot starter 模块增加接口自定义主机地址和redis sentinel的配置 * 🔖 发布 3.9.4.B 测试版本 * fix:字段错误 * 🆕 #1789 微信支付电商收付通增加下载账单的接口 * 🆕 #1793 企业微信添加应用管理的设置工作台自定义展示模块 Co-authored-by: sysong <sysong@chutianyun.gov.cn> * 🎨 优化公众号Spring Boot Starter的redisTemplate注入等代码 * 🎨 优化代码,提供toString方法,避免某些情况下出现的问题 * 🆕 #1675 企业微信增加更新、查询和删除日历的接口 * 🆕 #1686 微信公众号增加对话能力(原导购助手)部分接口,如添加顾问、获取顾问信息等 * 🆕 #1686 微信公众号增加对话能力(原导购助手)部分接口,如修改顾问、删除顾问、获取顾问列表等 * 🎨 #1797 企业微信配置客户联系「联系我」方式接口返回增加二维码链接字段 新增联系我二维码链接,仅在scene为2时返回 * 🎨 优化部分代码,重构OAuth2网页授权、网页登录等相关接口,方便接入open模块 * 🐛 修复字段错误 Co-authored-by: 曾浩 <epdcgsi@dingtalk.com> * 🆕 #1725 微信支付分增加免确认模式(预授权方式)相关接口支持 * 🆕 #1806 开放平台增加第三方平台代公众号实现复用公众号资料快速创建小程序的接口 * 🆕 微信开发平台模块增加OAuth2相关接口(网页授权、网页登录等)的实现 * 🎨 优化部分代码,明确出错信息 * 🔖 发布 3.9.5.B 测试版本 * 🆕 #1817 企业微信增加批量获取外部联系人详情的接口,同时修复外部联系人中listGroupChat参数失效问题 * 🎨 优化代码,实现序列化接口 * 🎨 #1820 优化更新getTicket方法,调整锁调用时机避免并发问题 * Fix:调整获取相关票据的锁处理时机 * Fix:更新票据,锁之后,再次检查是否有效,避免并发同时进入多次重置票据 Co-authored-by: weiwei.xing <weiwei.xing@nplusgroup.com> * Update CONTRIBUTING.md * 🆕 #1814 微信支付解析扫码支付回调通知增加签名类型的重载方法 * 🔖 发布 3.9.6.B 测试版本 * 🎨 重构部分包结构 * 🎨 #1827 微信支付分相关接口优化 1. 将原有请求模型类中一些基础数据类型改为对应的包装类,因为在用户没有显式set的情况下,这些基础数据类型序列化为json时也会以默认值的形式作为参数传到微信端,造成微信端返回错误。 2. 微信支付分相关的回调数据处理方法加上签名验证。 3. 增加方法授权/解除授权服务回调数据处理 * 🎨 #1832 微信支付电商收付通增加查询提现状态的接口 * 🐛 #1824 微信支付修复分账回退接口结果错误码解析错误的问题 * 🎨 #1834 微信会员卡基本信息类增加缺少字段 use_limit * 🐛 #1828 修复企业微信第三方应用消息路由相关方法参数错误的问题 * 🆕 #1831 生成小程序二维码的相关接口增加指定文件路径参数的重载方法 * 🔖 发布 3.9.7.B 测试版本 * 🎨 #1848 刷卡支付接口响应结果类增加服务商调用时的返回字段 * 🎨 增加点注释 * 🎨 #1849 企业微信外部联系人相关接口重构,优化重复代码,同时获取客户详情接口返回增加标签id字段 * 🎨 Update javadoc for WxMaQrcodeService.java * 🐛 #1852 修复个性化菜单clientPlatformType字段的反序列化问题 * 🎨 补充完善单元测试 * 🐛 #1856 【微信支付】修复电商收付通查询退款状态的接口地址 * 🎨 #1857 【企业微信】获取获取部门成员详情接口返回值增加第三方应用专有的open_userid字段 * 🔖 发布 3.9.8.B 测试版本 * 🎨 修复out_trade_no 字段命名不规范问题 Co-authored-by: vcpgfw <zhaopf@xtkg.com> * 📝 add more cases * 🐛 #1861【微信支付】支付分后付费项目请求类的amount属性改为Integer,允许为空 * 🐛 #1864 【微信支付】WxPayConfig类的hashCode和equals方法移除 verifier 字段 * 🆕 #1863 【小程序】增加删除直播间、编辑直播间、获取直播间推流地址、获取直播间分享二维码等接口 * 🎨 #1867【企业微信】优化完善第三方应用的接入代码 * 🆕 #1869 【小程序】增加管理直播间小助手的相关接口 * 🆕 #1868 【微信支付】增加通用上传图片接口,支持传入流和文件名参数 * 🎨 优化代码,部分类增加序列化接口实现 * 🎨 增加点单元测试示例代码 * 🔖 发布 3.9.9.B 测试版本 * ⬆️ 升级xstream版本 * ⬆️ Bump xstream Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.10-java7 to 1.4.13-java7. - [Release notes](https://github.com/x-stream/xstream/releases) - [Commits](https://github.com/x-stream/xstream/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * 🆕 #1873 【企业微信】第三方应用增加网页授权登陆获取访问用户身份和获取访问用户敏感信息的接口 * 🐛 修复字段错误问题 * 🐛 #1883【公众号】修复卡券导入code接口错误的返回类型 * 🎨 规范变量名 * 🆕 #1885 【微信支付】电商收付通增加资金账单下载的接口 * 🆕 #1866 【小程序】 增加提审素材上传接口请求执行器 * 🎨 重构规范小程序部分代码包结构 * 🎨 #1888【企业微信】补充完善OA审批回调事件消息部分字段缺失的问题 * 🆕 #1746: 【企业微信】第三方应用增加授权配置接口,同时增加向员工付款的接口 * 🎨 #1886 【小程序】创建直播间接口增加二维码地址字段 * 🔖 发布 4.0.0 正式版本 Co-authored-by: 曾浩 <epdcgsi@dingtalk.com> Co-authored-by: cloudX <epdcgsi@163.com> Co-authored-by: Boris <borisbao@users.noreply.github.com> Co-authored-by: f00lish <f00lish@qq.com> Co-authored-by: TomLiu <tomliuchangsha@hotmail.com> Co-authored-by: giveme0101 <xiajun94@qq.com> Co-authored-by: lmh <991564110@qq.com> Co-authored-by: lmh <lmh@weiyian.com> Co-authored-by: Dream2Land <346570926@qq.com> Co-authored-by: amhere <songshiyu555@163.com> Co-authored-by: sysong <sysong@chutianyun.gov.cn> Co-authored-by: 静宏 <acvrock.cn@gmail.com> Co-authored-by: spvycf <545997765@qq.com> Co-authored-by: alucardxh <alucardxh@163.com> Co-authored-by: jn老A <sytu_xww@163.com> Co-authored-by: weiwei.xing <weiwei.xing@nplusgroup.com> Co-authored-by: winter <winter4666@foxmail.com> Co-authored-by: gentryhuang <gentryhuang.xw@gmail.com> Co-authored-by: Kidwind <Kidwind@gmail.com> Co-authored-by: zacks <zacksleo@gmail.com> Co-authored-by: wcc1433 <37837522+wcc1433@users.noreply.github.com> Co-authored-by: Pancras <coder.zpf@gmail.com> Co-authored-by: vcpgfw <zhaopf@xtkg.com> Co-authored-by: JoeWoo <xjoewoo@gmail.com> Co-authored-by: 微同科技 <30375770+lipengjun92@users.noreply.github.com> Co-authored-by: xworks <jzqlin@gmail.com> Co-authored-by: GaoMinzhu <31923767+GaoMinzhu@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: huangxm129 <40385667+huangxm129@users.noreply.github.com> Co-authored-by: ly8388 <49558207+ly8388@users.noreply.github.com> Co-authored-by: yangyh22 <9944784+yangyh22@users.noreply.github.com> Co-authored-by: Gyv12345 <gyv12345@163.com> Co-authored-by: LinXiaoHuChong <louisquiet@gmail.com>
This commit is contained in:
@ -16,16 +16,23 @@
|
||||
wx.mp.token = @token
|
||||
wx.mp.aesKey = @aesKey
|
||||
# 存储配置redis(可选)
|
||||
wx.mp.config-storage.type = redis # 配置类型: memory(默认), redis, jedis, redistemplate
|
||||
wx.mp.config-storage.type = Jedis # 配置类型: Memory(默认), Jedis, RedisTemplate
|
||||
wx.mp.config-storage.key-prefix = wx # 相关redis前缀配置: wx(默认)
|
||||
wx.mp.config-storage.redis.host = 127.0.0.1
|
||||
wx.mp.config-storage.redis.port = 6379
|
||||
#单机和sentinel同时存在时,优先使用sentinel配置
|
||||
#wx.mp.config-storage.redis.sentinel-ips=127.0.0.1:16379,127.0.0.1:26379
|
||||
#wx.mp.config-storage.redis.sentinel-name=mymaster
|
||||
# http客户端配置
|
||||
wx.mp.config-storage.http-client-type=httpclient # http客户端类型: httpclient(默认), okhttp, joddhttp
|
||||
wx.mp.config-storage.http-client-type=httpclient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp
|
||||
wx.mp.config-storage.http-proxy-host=
|
||||
wx.mp.config-storage.http-proxy-port=
|
||||
wx.mp.config-storage.http-proxy-username=
|
||||
wx.mp.config-storage.http-proxy-password=
|
||||
# 公众号地址host配置
|
||||
#wx.mp.hosts.api-host=http://proxy.com/
|
||||
#wx.mp.hosts.open-host=http://proxy.com/
|
||||
#wx.mp.hosts.mp-host=http://proxy.com/
|
||||
```
|
||||
3. 自动注入的类型
|
||||
- `WxMpService`
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>3.9.0</version>
|
||||
<version>4.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -30,6 +30,16 @@
|
||||
<version>${spring.boot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jodd</groupId>
|
||||
<artifactId>jodd-http</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.config;
|
||||
|
||||
import com.binarywang.spring.starter.wxjava.mp.enums.HttpClientType;
|
||||
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
|
||||
import me.chanjar.weixin.common.api.WxOcrService;
|
||||
import me.chanjar.weixin.mp.api.*;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceJoddHttpImpl;
|
||||
@ -23,16 +23,21 @@ public class WxMpServiceAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public WxMpService wxMpService(WxMpConfigStorage configStorage, WxMpProperties wxMpProperties) {
|
||||
WxMpProperties.HttpClientType httpClientType = wxMpProperties.getConfigStorage().getHttpClientType();
|
||||
HttpClientType httpClientType = wxMpProperties.getConfigStorage().getHttpClientType();
|
||||
WxMpService wxMpService;
|
||||
if (httpClientType == WxMpProperties.HttpClientType.okhttp) {
|
||||
wxMpService = newWxMpServiceOkHttpImpl();
|
||||
} else if (httpClientType == WxMpProperties.HttpClientType.joddhttp) {
|
||||
wxMpService = newWxMpServiceJoddHttpImpl();
|
||||
} else if (httpClientType == WxMpProperties.HttpClientType.httpclient) {
|
||||
wxMpService = newWxMpServiceHttpClientImpl();
|
||||
} else {
|
||||
wxMpService = newWxMpServiceImpl();
|
||||
switch (httpClientType) {
|
||||
case OkHttp:
|
||||
wxMpService = newWxMpServiceOkHttpImpl();
|
||||
break;
|
||||
case JoddHttp:
|
||||
wxMpService = newWxMpServiceJoddHttpImpl();
|
||||
break;
|
||||
case HttpClient:
|
||||
wxMpService = newWxMpServiceHttpClientImpl();
|
||||
break;
|
||||
default:
|
||||
wxMpService = newWxMpServiceImpl();
|
||||
break;
|
||||
}
|
||||
|
||||
wxMpService.setWxMpConfigStorage(configStorage);
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.config;
|
||||
|
||||
import com.binarywang.spring.starter.wxjava.mp.enums.StorageType;
|
||||
import com.binarywang.spring.starter.wxjava.mp.properties.RedisProperties;
|
||||
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
|
||||
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
|
||||
import me.chanjar.weixin.common.redis.WxRedisOps;
|
||||
import me.chanjar.weixin.mp.bean.WxMpHostConfig;
|
||||
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
|
||||
@ -16,17 +21,21 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolAbstract;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisSentinelPool;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 微信公众号存储策略自动配置.
|
||||
*
|
||||
* @author someone
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class WxMpStorageAutoConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final WxMpProperties wxMpProperties;
|
||||
@ -40,41 +49,73 @@ public class WxMpStorageAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(WxMpConfigStorage.class)
|
||||
public WxMpConfigStorage wxMpConfigStorage() {
|
||||
WxMpProperties.StorageType type = wxMpProperties.getConfigStorage().getType();
|
||||
StorageType type = wxMpProperties.getConfigStorage().getType();
|
||||
WxMpConfigStorage config;
|
||||
if (type == WxMpProperties.StorageType.redis || type == WxMpProperties.StorageType.jedis) {
|
||||
config = wxMpInJedisConfigStorage();
|
||||
} else if (type == WxMpProperties.StorageType.redistemplate) {
|
||||
config = wxMpInRedisTemplateConfigStorage();
|
||||
} else {
|
||||
config = wxMpInMemoryConfigStorage();
|
||||
switch (type) {
|
||||
case Jedis:
|
||||
config = jedisConfigStorage();
|
||||
break;
|
||||
case RedisTemplate:
|
||||
config = redisTemplateConfigStorage();
|
||||
break;
|
||||
default:
|
||||
config = defaultConfigStorage();
|
||||
break;
|
||||
}
|
||||
// wx host config
|
||||
if (null != wxMpProperties.getHosts() && StringUtils.isNotEmpty(wxMpProperties.getHosts().getApiHost())) {
|
||||
WxMpHostConfig hostConfig = new WxMpHostConfig();
|
||||
hostConfig.setApiHost(wxMpProperties.getHosts().getApiHost());
|
||||
hostConfig.setMpHost(wxMpProperties.getHosts().getMpHost());
|
||||
hostConfig.setOpenHost(wxMpProperties.getHosts().getOpenHost());
|
||||
config.setHostConfig(hostConfig);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private WxMpConfigStorage wxMpInMemoryConfigStorage() {
|
||||
private WxMpConfigStorage defaultConfigStorage() {
|
||||
WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
|
||||
setWxMpInfo(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
private WxMpConfigStorage wxMpInJedisConfigStorage() {
|
||||
JedisPool jedisPool;
|
||||
private WxMpConfigStorage jedisConfigStorage() {
|
||||
JedisPoolAbstract jedisPool;
|
||||
if (StringUtils.isNotEmpty(redisHost) || StringUtils.isNotEmpty(redisHost2)) {
|
||||
jedisPool = getJedisPool();
|
||||
} else {
|
||||
jedisPool = applicationContext.getBean(JedisPool.class);
|
||||
}
|
||||
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
|
||||
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps, wxMpProperties.getConfigStorage().getKeyPrefix());
|
||||
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
|
||||
wxMpProperties.getConfigStorage().getKeyPrefix());
|
||||
setWxMpInfo(wxMpRedisConfig);
|
||||
return wxMpRedisConfig;
|
||||
}
|
||||
|
||||
private WxMpConfigStorage wxMpInRedisTemplateConfigStorage() {
|
||||
StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class);
|
||||
private WxMpConfigStorage redisTemplateConfigStorage() {
|
||||
StringRedisTemplate redisTemplate = null;
|
||||
try {
|
||||
redisTemplate = applicationContext.getBean(StringRedisTemplate.class);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
if (null == redisTemplate) {
|
||||
redisTemplate = (StringRedisTemplate) applicationContext.getBean("stringRedisTemplate");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (null == redisTemplate) {
|
||||
redisTemplate = (StringRedisTemplate) applicationContext.getBean("redisTemplate");
|
||||
}
|
||||
|
||||
WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
|
||||
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps, wxMpProperties.getConfigStorage().getKeyPrefix());
|
||||
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
|
||||
wxMpProperties.getConfigStorage().getKeyPrefix());
|
||||
|
||||
setWxMpInfo(wxMpRedisConfig);
|
||||
return wxMpRedisConfig;
|
||||
}
|
||||
@ -95,9 +136,9 @@ public class WxMpStorageAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private JedisPool getJedisPool() {
|
||||
private JedisPoolAbstract getJedisPool() {
|
||||
WxMpProperties.ConfigStorage storage = wxMpProperties.getConfigStorage();
|
||||
WxMpProperties.RedisProperties redis = storage.getRedis();
|
||||
RedisProperties redis = storage.getRedis();
|
||||
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
if (redis.getMaxActive() != null) {
|
||||
@ -114,6 +155,10 @@ public class WxMpStorageAutoConfiguration {
|
||||
}
|
||||
config.setTestOnBorrow(true);
|
||||
config.setTestWhileIdle(true);
|
||||
if (StringUtils.isNotEmpty(redis.getSentinelIps())) {
|
||||
Set<String> sentinels = Sets.newHashSet(redis.getSentinelIps().split(","));
|
||||
return new JedisSentinelPool(redis.getSentinelName(), sentinels);
|
||||
}
|
||||
|
||||
return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(),
|
||||
redis.getDatabase());
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.enums;
|
||||
|
||||
/**
|
||||
* httpclient类型.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-08-30
|
||||
*/
|
||||
public enum HttpClientType {
|
||||
/**
|
||||
* HttpClient.
|
||||
*/
|
||||
HttpClient,
|
||||
/**
|
||||
* OkHttp.
|
||||
*/
|
||||
OkHttp,
|
||||
/**
|
||||
* JoddHttp.
|
||||
*/
|
||||
JoddHttp,
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.enums;
|
||||
|
||||
/**
|
||||
* storage类型.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-08-30
|
||||
*/
|
||||
public enum StorageType {
|
||||
/**
|
||||
* 内存.
|
||||
*/
|
||||
Memory,
|
||||
/**
|
||||
* redis(JedisClient).
|
||||
*/
|
||||
Jedis,
|
||||
/**
|
||||
* redis(RedisTemplate).
|
||||
*/
|
||||
RedisTemplate
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class HostConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4172767630740346001L;
|
||||
|
||||
private String apiHost;
|
||||
|
||||
private String openHost;
|
||||
|
||||
private String mpHost;
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* redis 配置属性.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-08-30
|
||||
*/
|
||||
@Data
|
||||
public class RedisProperties implements Serializable {
|
||||
private static final long serialVersionUID = -5924815351660074401L;
|
||||
|
||||
/**
|
||||
* 主机地址.
|
||||
*/
|
||||
private String host = "127.0.0.1";
|
||||
|
||||
/**
|
||||
* 端口号.
|
||||
*/
|
||||
private int port = 6379;
|
||||
|
||||
/**
|
||||
* 密码.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 超时.
|
||||
*/
|
||||
private int timeout = 2000;
|
||||
|
||||
/**
|
||||
* 数据库.
|
||||
*/
|
||||
private int database = 0;
|
||||
|
||||
/**
|
||||
* sentinel ips
|
||||
*/
|
||||
private String sentinelIps;
|
||||
|
||||
/**
|
||||
* sentinel name
|
||||
*/
|
||||
private String sentinelName;
|
||||
|
||||
private Integer maxActive;
|
||||
private Integer maxIdle;
|
||||
private Integer maxWaitMillis;
|
||||
private Integer minIdle;
|
||||
}
|
||||
@ -1,12 +1,14 @@
|
||||
package com.binarywang.spring.starter.wxjava.mp.properties;
|
||||
|
||||
import com.binarywang.spring.starter.wxjava.mp.enums.HttpClientType;
|
||||
import com.binarywang.spring.starter.wxjava.mp.enums.StorageType;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static com.binarywang.spring.starter.wxjava.mp.enums.StorageType.Memory;
|
||||
import static com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties.PREFIX;
|
||||
import static com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties.StorageType.memory;
|
||||
|
||||
|
||||
/**
|
||||
@ -39,6 +41,11 @@ public class WxMpProperties {
|
||||
*/
|
||||
private String aesKey;
|
||||
|
||||
/**
|
||||
* 自定义host配置
|
||||
*/
|
||||
private HostConfig hosts;
|
||||
|
||||
/**
|
||||
* 存储策略
|
||||
*/
|
||||
@ -51,7 +58,7 @@ public class WxMpProperties {
|
||||
/**
|
||||
* 存储类型.
|
||||
*/
|
||||
private StorageType type = memory;
|
||||
private StorageType type = Memory;
|
||||
|
||||
/**
|
||||
* 指定key前缀.
|
||||
@ -66,7 +73,7 @@ public class WxMpProperties {
|
||||
/**
|
||||
* http客户端类型.
|
||||
*/
|
||||
private HttpClientType httpClientType = HttpClientType.httpclient;
|
||||
private HttpClientType httpClientType = HttpClientType.HttpClient;
|
||||
|
||||
/**
|
||||
* http代理主机.
|
||||
@ -90,73 +97,4 @@ public class WxMpProperties {
|
||||
|
||||
}
|
||||
|
||||
public enum StorageType {
|
||||
/**
|
||||
* 内存.
|
||||
*/
|
||||
memory,
|
||||
/**
|
||||
* jedis.
|
||||
*/
|
||||
redis,
|
||||
/**
|
||||
* redis(JedisClient).
|
||||
*/
|
||||
jedis,
|
||||
/**
|
||||
* redis(RedisTemplate).
|
||||
*/
|
||||
redistemplate
|
||||
}
|
||||
|
||||
public enum HttpClientType {
|
||||
/**
|
||||
* HttpClient.
|
||||
*/
|
||||
httpclient,
|
||||
/**
|
||||
* OkHttp.
|
||||
*/
|
||||
okhttp,
|
||||
/**
|
||||
* JoddHttp.
|
||||
*/
|
||||
joddhttp
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RedisProperties implements Serializable {
|
||||
private static final long serialVersionUID = -5924815351660074401L;
|
||||
|
||||
/**
|
||||
* 主机地址.
|
||||
*/
|
||||
private String host = "127.0.0.1";
|
||||
|
||||
/**
|
||||
* 端口号.
|
||||
*/
|
||||
private int port = 6379;
|
||||
|
||||
/**
|
||||
* 密码.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 超时.
|
||||
*/
|
||||
private int timeout = 2000;
|
||||
|
||||
/**
|
||||
* 数据库.
|
||||
*/
|
||||
private int database = 0;
|
||||
|
||||
private Integer maxActive;
|
||||
private Integer maxIdle;
|
||||
private Integer maxWaitMillis;
|
||||
private Integer minIdle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user