diff --git a/mallinkWechatOpen/src/main/java/com/iformall/config/RedisConfig.java b/mallinkWechatOpen/src/main/java/com/iformall/config/RedisConfig.java index 3ac538c1c..74c8be49d 100644 --- a/mallinkWechatOpen/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkWechatOpen/src/main/java/com/iformall/config/RedisConfig.java @@ -1,5 +1,7 @@ package com.iformall.config; +import com.iformall.domain.po.PushLimit; +import com.iformall.domain.po.WxScoreRules; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -10,6 +12,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.cache.RedisCacheConfiguration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + import java.time.Duration; import java.util.HashMap; import java.util.HashSet; @@ -68,4 +74,38 @@ public class RedisConfig extends CachingConfigurerSupport { return cacheManager; } + @Bean("pushLimitRedisTemplate") + public RedisTemplate getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PushLimit.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + + @Bean("scoreRuleRedisTemplate") + public RedisTemplate getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxScoreRules.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + } diff --git a/mallinkWechatOpen/src/main/resources/application-dev.yml b/mallinkWechatOpen/src/main/resources/application-dev.yml index 35e73ad19..ed0040cc7 100644 --- a/mallinkWechatOpen/src/main/resources/application-dev.yml +++ b/mallinkWechatOpen/src/main/resources/application-dev.yml @@ -87,4 +87,4 @@ logging: level: tk.mybatis: debug com.iformall.mapper: debug - path: ./logs/w + path: ./logs/o diff --git a/mallinkWechatOpen/src/main/resources/application-prod.yml b/mallinkWechatOpen/src/main/resources/application-prod.yml index 4116a5a84..7eead9053 100644 --- a/mallinkWechatOpen/src/main/resources/application-prod.yml +++ b/mallinkWechatOpen/src/main/resources/application-prod.yml @@ -81,4 +81,4 @@ logging: level: tk.mybatis: debug com.iformall: debug - path: ./logs/w \ No newline at end of file + path: ./logs/o \ No newline at end of file diff --git a/mallinkWechatOpen/src/main/resources/application-test.yml b/mallinkWechatOpen/src/main/resources/application-test.yml index eded76dcf..ab6d58017 100644 --- a/mallinkWechatOpen/src/main/resources/application-test.yml +++ b/mallinkWechatOpen/src/main/resources/application-test.yml @@ -81,4 +81,4 @@ logging: level: tk.mybatis: debug com.iformall: debug - path: ./logs/w \ No newline at end of file + path: ./logs/o \ No newline at end of file diff --git a/mallinkWechatOpen/src/main/resources/application.yml b/mallinkWechatOpen/src/main/resources/application.yml index 515f3613f..7b015c725 100644 --- a/mallinkWechatOpen/src/main/resources/application.yml +++ b/mallinkWechatOpen/src/main/resources/application.yml @@ -1,7 +1,7 @@ server: port: 6060 servlet: - context-path: / + context-path: /O spring: application: