mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 18:46:10 +08:00 
			
		
		
		
	🎨 #1521 微信小程序 spring-boot-starter 增加一些新特性
This commit is contained in:
		| @ -1,13 +1,13 @@ | ||||
| package com.binarywang.spring.starter.wxjava.mp.config; | ||||
|  | ||||
| import com.binarywang.spring.starter.wxjava.mp.extend.RedisTemplateWxMpRedisOps; | ||||
| import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| 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.config.WxMpConfigStorage; | ||||
| import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; | ||||
| import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; | ||||
| import me.chanjar.weixin.mp.config.redis.JedisWxMpRedisOps; | ||||
| import me.chanjar.weixin.mp.config.redis.WxMpRedisOps; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||||
| @ -65,7 +65,7 @@ public class WxMpStorageAutoConfiguration { | ||||
|     } else { | ||||
|       jedisPool = applicationContext.getBean(JedisPool.class); | ||||
|     } | ||||
|     WxMpRedisOps redisOps = new JedisWxMpRedisOps(jedisPool); | ||||
|     WxRedisOps redisOps = new JedisWxRedisOps(jedisPool); | ||||
|     WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps, wxMpProperties.getConfigStorage().getKeyPrefix()); | ||||
|     setWxMpInfo(wxMpRedisConfig); | ||||
|     return wxMpRedisConfig; | ||||
| @ -73,7 +73,7 @@ public class WxMpStorageAutoConfiguration { | ||||
|  | ||||
|   private WxMpConfigStorage wxMpInRedisTemplateConfigStorage() { | ||||
|     StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class); | ||||
|     WxMpRedisOps redisOps = new RedisTemplateWxMpRedisOps(redisTemplate); | ||||
|     WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate); | ||||
|     WxMpRedisConfigImpl wxMpRedisConfig = new WxMpRedisConfigImpl(redisOps, wxMpProperties.getConfigStorage().getKeyPrefix()); | ||||
|     setWxMpInfo(wxMpRedisConfig); | ||||
|     return wxMpRedisConfig; | ||||
|  | ||||
| @ -1,40 +0,0 @@ | ||||
| package com.binarywang.spring.starter.wxjava.mp.extend; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import me.chanjar.weixin.mp.config.redis.BaseWxMpRedisOps; | ||||
| import org.springframework.data.redis.core.StringRedisTemplate; | ||||
|  | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.concurrent.locks.Lock; | ||||
| import java.util.concurrent.locks.ReentrantLock; | ||||
|  | ||||
| @RequiredArgsConstructor | ||||
| public class RedisTemplateWxMpRedisOps extends BaseWxMpRedisOps { | ||||
|  | ||||
|   private final StringRedisTemplate redisTemplate; | ||||
|  | ||||
|   @Override | ||||
|   public String getValue(String key) { | ||||
|     return redisTemplate.opsForValue().get(key); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void setValue(String key, String value, int expire, TimeUnit timeUnit) { | ||||
|     redisTemplate.opsForValue().set(key, value, expire, timeUnit); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public Long getExpire(String key) { | ||||
|     return redisTemplate.getExpire(key); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void expire(String key, int expire, TimeUnit timeUnit) { | ||||
|     redisTemplate.expire(key, expire, timeUnit); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public Lock getLock(String key) { | ||||
|     return new ReentrantLock(); | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Mario Luo
					Mario Luo