Skip to content

Commit

Permalink
🎨 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Nov 28, 2021
1 parent daae431 commit cc6bc22
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* 微信公众号存储策略自动配置.
*
* @author someone
* @author Luo
*/
@Slf4j
@Configuration
Expand All @@ -40,12 +40,6 @@ public class WxMpStorageAutoConfiguration {

private final WxMpProperties wxMpProperties;

@Value("${wx.mp.config-storage.redis.host:")
private String redisHost;

@Value("${wx.mp.configStorage.redis.host:")
private String redisHost2;

@Bean
@ConditionalOnMissingBean(WxMpConfigStorage.class)
public WxMpConfigStorage wxMpConfigStorage() {
Expand Down Expand Up @@ -81,14 +75,15 @@ private WxMpConfigStorage defaultConfigStorage() {

private WxMpConfigStorage jedisConfigStorage() {
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();
} else {
jedisPool = applicationContext.getBean(JedisPool.class);
}
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
wxMpProperties.getConfigStorage().getKeyPrefix());
wxMpProperties.getConfigStorage().getKeyPrefix());
setWxMpInfo(wxMpRedisConfig);
return wxMpRedisConfig;
}
Expand All @@ -114,7 +109,7 @@ private WxMpConfigStorage redisTemplateConfigStorage() {

WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps,
wxMpProperties.getConfigStorage().getKeyPrefix());
wxMpProperties.getConfigStorage().getKeyPrefix());

setWxMpInfo(wxMpRedisConfig);
return wxMpRedisConfig;
Expand Down Expand Up @@ -160,6 +155,6 @@ private JedisPoolAbstract getJedisPool() {
}

return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(),
redis.getDatabase());
redis.getDatabase());
}
}

0 comments on commit cc6bc22

Please sign in to comment.