mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-29 17:48:50 +08:00
🎨 优化代码
This commit is contained in:
@ -30,7 +30,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* 微信公众号存储策略自动配置.
|
* 微信公众号存储策略自动配置.
|
||||||
*
|
*
|
||||||
* @author someone
|
* @author Luo
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
@ -40,12 +40,6 @@ public class WxMpStorageAutoConfiguration {
|
|||||||
|
|
||||||
private final WxMpProperties wxMpProperties;
|
private final WxMpProperties wxMpProperties;
|
||||||
|
|
||||||
@Value("${wx.mp.config-storage.redis.host:")
|
|
||||||
private String redisHost;
|
|
||||||
|
|
||||||
@Value("${wx.mp.configStorage.redis.host:")
|
|
||||||
private String redisHost2;
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(WxMpConfigStorage.class)
|
@ConditionalOnMissingBean(WxMpConfigStorage.class)
|
||||||
public WxMpConfigStorage wxMpConfigStorage() {
|
public WxMpConfigStorage wxMpConfigStorage() {
|
||||||
@ -81,14 +75,15 @@ public class WxMpStorageAutoConfiguration {
|
|||||||
|
|
||||||
private WxMpConfigStorage jedisConfigStorage() {
|
private WxMpConfigStorage jedisConfigStorage() {
|
||||||
JedisPoolAbstract jedisPool;
|
JedisPoolAbstract jedisPool;
|
||||||
if (StringUtils.isNotEmpty(redisHost) || StringUtils.isNotEmpty(redisHost2)) {
|
if (wxMpProperties.getConfigStorage() != null && wxMpProperties.getConfigStorage().getRedis() != null
|
||||||
|
&& StringUtils.isNotEmpty(wxMpProperties.getConfigStorage().getRedis().getHost())) {
|
||||||
jedisPool = getJedisPool();
|
jedisPool = getJedisPool();
|
||||||
} else {
|
} else {
|
||||||
jedisPool = applicationContext.getBean(JedisPool.class);
|
jedisPool = applicationContext.getBean(JedisPool.class);
|
||||||
}
|
}
|
||||||
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
|
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
|
||||||
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
|
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
|
||||||
wxMpProperties.getConfigStorage().getKeyPrefix());
|
wxMpProperties.getConfigStorage().getKeyPrefix());
|
||||||
setWxMpInfo(wxMpRedisConfig);
|
setWxMpInfo(wxMpRedisConfig);
|
||||||
return wxMpRedisConfig;
|
return wxMpRedisConfig;
|
||||||
}
|
}
|
||||||
@ -114,7 +109,7 @@ public class WxMpStorageAutoConfiguration {
|
|||||||
|
|
||||||
WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
|
WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
|
||||||
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
|
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
|
||||||
wxMpProperties.getConfigStorage().getKeyPrefix());
|
wxMpProperties.getConfigStorage().getKeyPrefix());
|
||||||
|
|
||||||
setWxMpInfo(wxMpRedisConfig);
|
setWxMpInfo(wxMpRedisConfig);
|
||||||
return wxMpRedisConfig;
|
return wxMpRedisConfig;
|
||||||
@ -160,6 +155,6 @@ public class WxMpStorageAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(),
|
return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(),
|
||||||
redis.getDatabase());
|
redis.getDatabase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user