Просмотр исходного кода

fix cache

release_toaliyun_real
xiaohanzi 5 лет назад
Родитель
Сommit
5485ccf95c
3 измененных файлов: 59 добавлений и 9 удалений
  1. +57
    -0
      mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java
  2. +0
    -3
      mallinkCApi/src/main/java/com/iformall/controller/BaseController.java
  3. +2
    -6
      mallinkService/src/main/java/com/iformall/domain/po/base/BaseCUserEntity.java

+ 57
- 0
mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java Просмотреть файл

@@ -1,5 +1,8 @@
package com.iformall.config;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseCUserEntity;
@@ -64,6 +67,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>();

Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -81,6 +88,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>();

Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -98,6 +109,12 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxCUser> template = new RedisTemplate<String, WxCUser>();

Jackson2JsonRedisSerializer<WxCUser> j = new Jackson2JsonRedisSerializer<WxCUser>(WxCUser.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -115,6 +132,12 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>();

Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -132,6 +155,11 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>();

Jackson2JsonRedisSerializer<WxCUserBasicInfo> j = new Jackson2JsonRedisSerializer<WxCUserBasicInfo>(WxCUserBasicInfo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -149,6 +177,11 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>();

Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -166,6 +199,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, List<WxMall>> template = new RedisTemplate<String, List<WxMall>>();

Jackson2JsonRedisSerializer<List> j = new Jackson2JsonRedisSerializer<List>(List.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -183,6 +220,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxCouponCVo> template = new RedisTemplate<String, WxCouponCVo>();

Jackson2JsonRedisSerializer<WxCouponCVo> j = new Jackson2JsonRedisSerializer<WxCouponCVo>(WxCouponCVo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);
@@ -200,6 +241,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);
@@ -218,6 +263,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxBuser> template = new RedisTemplate();

Jackson2JsonRedisSerializer<WxBuser> j = new Jackson2JsonRedisSerializer(WxBuser.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);
@@ -236,6 +285,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxOrder> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<WxOrder> j = new Jackson2JsonRedisSerializer(WxOrder.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);
@@ -254,6 +307,10 @@ public class RedisConfig extends CachingConfigurerSupport {
RedisTemplate<String, WxAppinfo> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<WxAppinfo> j = new Jackson2JsonRedisSerializer(WxAppinfo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);


+ 0
- 3
mallinkCApi/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -57,9 +57,6 @@ public class BaseController {
@Autowired
private CUserTokenService cUserTokenService;
@Autowired
private CUserServiceFactory cuserFactory;
@Autowired
@Qualifier("cUserBasicInfoRedisTemplate")
RedisTemplate<String, WxCUserBasicInfo> cuserBasicInfoTemplate;


+ 2
- 6
mallinkService/src/main/java/com/iformall/domain/po/base/BaseCUserEntity.java Просмотреть файл

@@ -32,13 +32,9 @@ public class BaseCUserEntity extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime")
private Date expireTime;
@io.swagger.annotations.ApiModelProperty(value="真实对象如wxCUser,因为放到缓存之后,实体会变为map,索性就存map",name="realUser")
@io.swagger.annotations.ApiModelProperty(value="真实对象如wxCUser",name="realUser")
@TableField(exist = false)
private Map realUser;
public <T> T getObjectFromMap(Class<T> clazz) {
return JSONObject.parseObject(JSONObject.toJSONString(realUser), clazz);
}
private Object realUser;

/**
* 是否是会员


Загрузка…
Отмена
Сохранить