🎨 修复微信开发平台部分问题,并对企业微信新增多种 redis 存储实现支持

This commit is contained in:
Forever杨
2023-04-23 13:21:03 +08:00
committed by GitHub
parent e72991c0b5
commit e50457892d
19 changed files with 527 additions and 212 deletions

View File

@ -22,18 +22,14 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring.boot.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -1,10 +1,8 @@
package com.binarywang.spring.starter.wxjava.open.config.storage;
import com.binarywang.spring.starter.wxjava.open.properties.RedisProperties;
import com.binarywang.spring.starter.wxjava.open.properties.WxOpenProperties;
import com.binarywang.spring.starter.wxjava.open.properties.WxOpenRedisProperties;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
import me.chanjar.weixin.common.redis.WxRedisOps;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage;
@ -39,20 +37,19 @@ public class WxOpenInJedisConfigStorageConfiguration extends AbstractWxOpenConfi
}
private WxOpenInRedisConfigStorage getWxOpenInRedisConfigStorage() {
RedisProperties redisProperties = properties.getConfigStorage().getRedis();
WxOpenRedisProperties wxOpenRedisProperties = properties.getConfigStorage().getRedis();
JedisPool jedisPool;
if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) {
if (wxOpenRedisProperties != null && StringUtils.isNotEmpty(wxOpenRedisProperties.getHost())) {
jedisPool = getJedisPool();
} else {
jedisPool = applicationContext.getBean(JedisPool.class);
}
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
return new WxOpenInRedisConfigStorage(redisOps, properties.getConfigStorage().getKeyPrefix());
return new WxOpenInRedisConfigStorage(jedisPool, properties.getConfigStorage().getKeyPrefix());
}
private JedisPool getJedisPool() {
WxOpenProperties.ConfigStorage storage = properties.getConfigStorage();
RedisProperties redis = storage.getRedis();
WxOpenRedisProperties redis = storage.getRedis();
JedisPoolConfig config = new JedisPoolConfig();
if (redis.getMaxActive() != null) {

View File

@ -1,13 +1,11 @@
package com.binarywang.spring.starter.wxjava.open.config.storage;
import com.binarywang.spring.starter.wxjava.open.properties.RedisProperties;
import com.binarywang.spring.starter.wxjava.open.properties.WxOpenProperties;
import com.binarywang.spring.starter.wxjava.open.properties.WxOpenRedisProperties;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.redis.RedissonWxRedisOps;
import me.chanjar.weixin.common.redis.WxRedisOps;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInRedissonConfigStorage;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
@ -40,21 +38,20 @@ public class WxOpenInRedissonConfigStorageConfiguration extends AbstractWxOpenCo
return this.config(config, properties);
}
private WxOpenInRedisConfigStorage getWxOpenInRedissonConfigStorage() {
RedisProperties redisProperties = properties.getConfigStorage().getRedis();
private WxOpenInRedissonConfigStorage getWxOpenInRedissonConfigStorage() {
WxOpenRedisProperties wxOpenRedisProperties = properties.getConfigStorage().getRedis();
RedissonClient redissonClient;
if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) {
if (wxOpenRedisProperties != null && StringUtils.isNotEmpty(wxOpenRedisProperties.getHost())) {
redissonClient = getRedissonClient();
} else {
redissonClient = applicationContext.getBean(RedissonClient.class);
}
WxRedisOps redisOps = new RedissonWxRedisOps(redissonClient);
return new WxOpenInRedisConfigStorage(redisOps, properties.getConfigStorage().getKeyPrefix());
return new WxOpenInRedissonConfigStorage(redissonClient, properties.getConfigStorage().getKeyPrefix());
}
private RedissonClient getRedissonClient() {
WxOpenProperties.ConfigStorage storage = properties.getConfigStorage();
RedisProperties redis = storage.getRedis();
WxOpenRedisProperties redis = storage.getRedis();
Config config = new Config();
config.useSingleServer()

View File

@ -58,13 +58,13 @@ public class WxOpenProperties {
/**
* 指定key前缀.
*/
private String keyPrefix = "wx";
private String keyPrefix = "wx:open";
/**
* redis连接配置.
*/
@NestedConfigurationProperty
private RedisProperties redis = new RedisProperties();
private WxOpenRedisProperties redis = new WxOpenRedisProperties();
/**
* http客户端类型.

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
* @author someone
*/
@Data
public class RedisProperties implements Serializable {
public class WxOpenRedisProperties implements Serializable {
private static final long serialVersionUID = -5924815351660074401L;
/**