Przeglądaj źródła

fix cache

release_toaliyun_real
xiaohanzi 5 lat temu
rodzic
commit
7a53a505f7
5 zmienionych plików z 47 dodań i 18 usunięć
  1. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/BaseController.java
  2. +1
    -4
      mallinkService/src/main/java/com/iformall/domain/po/base/BaseCUserEntity.java
  3. +3
    -9
      mallinkService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java
  4. +1
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxLevelConfigServiceImpl.java
  5. +41
    -1
      mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java

+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/BaseController.java Wyświetl plik

@@ -133,7 +133,7 @@ public class BaseController {
if (baseuser.getRealUser() == null) { if (baseuser.getRealUser() == null) {
throw new MallinkException(ErrorCode.USER_IS_EMPTY); throw new MallinkException(ErrorCode.USER_IS_EMPTY);
} }
WxCUser user = baseuser.getRealUserObject(WxCUser.class);
WxCUser user = RedisCacheUtils.getFieldObject(baseuser, "realUser", WxCUser.class);
TenantEntity tenantEntity = getTenantInfo(); TenantEntity tenantEntity = getTenantInfo();
if (user.getTenantId() == null) { if (user.getTenantId() == null) {
user.setTenantId(tenantEntity.getTenantId()); user.setTenantId(tenantEntity.getTenantId());


+ 1
- 4
mallinkService/src/main/java/com/iformall/domain/po/base/BaseCUserEntity.java Wyświetl plik

@@ -3,6 +3,7 @@ package com.iformall.domain.po.base;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.iformall.domain.po.WxCUser;
import com.iformall.utils.Constant; import com.iformall.utils.Constant;
import com.iformall.utils.UserUtil; import com.iformall.utils.UserUtil;
import lombok.Data; import lombok.Data;
@@ -37,10 +38,6 @@ public class BaseCUserEntity extends TenantEntity {
@TableField(exist = false) @TableField(exist = false)
private Object realUser; private Object realUser;
public <T> T getRealUserObject(Class<T> clazz) {
return JSON.parseObject(JSON.toJSONString(realUser), clazz);
}

/** /**
* 是否是会员 * 是否是会员
* @return * @return


+ 3
- 9
mallinkService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java Wyświetl plik

@@ -162,18 +162,12 @@ public class WxAppinfoServiceImpl implements WxAppinfoService {
WxAppinfo record = this.getById(id); WxAppinfo record = this.getById(id);
if(record != null){ if(record != null){
String key1 = Constant.appinfoPrev + record.getAppId(); String key1 = Constant.appinfoPrev + record.getAppId();
if(wxAppinfoRedisTemplate.hasKey(key1)){
wxAppinfoRedisTemplate.delete(key1);
}
RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key1);
String key2 = Constant.appinfoPrev + record.getId(); String key2 = Constant.appinfoPrev + record.getId();
if(wxAppinfoRedisTemplate.hasKey(key2)){
wxAppinfoRedisTemplate.delete(key2);
}
RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key2);
String key3 = Constant.appinfoPrev + record.getTenantId() String key3 = Constant.appinfoPrev + record.getTenantId()
+ "-" + record.getPlat() + "-" + record.getType(); + "-" + record.getPlat() + "-" + record.getType();
if(wxAppinfoRedisTemplate.hasKey(key3)){
wxAppinfoRedisTemplate.delete(key3);
}
RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key3);
} }
} }
} }

+ 1
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxLevelConfigServiceImpl.java Wyświetl plik

@@ -240,8 +240,6 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService {


private void deleteRedis(String tenantId){ private void deleteRedis(String tenantId){
String key1 = Constant.levelConfigPrev + tenantId; String key1 = Constant.levelConfigPrev + tenantId;
if(wxLevelConfigListRedisTemplate.hasKey(key1)){
wxLevelConfigListRedisTemplate.delete(key1);
}
RedisCacheUtils.removeCache(wxLevelConfigListRedisTemplate, key1);
} }
} }

+ 41
- 1
mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java Wyświetl plik

@@ -9,6 +9,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;


import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;


public class RedisCacheUtils { public class RedisCacheUtils {
@@ -97,10 +98,49 @@ public class RedisCacheUtils {
return null; return null;
} }
public static <T> T getFieldObject(Object o,String property,Class<T> clazz) {
String json = JSON.toJSONString(o);
JSONObject jsonObject = JSON.parseObject(json);
Object p = jsonObject.get(property);
if (null != p ) {
return parseJson(JSON.toJSONString(p), clazz);
}
return null;
}
public static <T> List<T> getListFieldObject(Object o,String property,Class<T> clazz) {
String json = JSON.toJSONString(o);
JSONObject jsonObject = JSON.parseObject(json);
Object p = jsonObject.get(property);
if (null != p ) {
return parseListJson(JSON.toJSONString(p), clazz);
}
return null;
}
public static <T> Set<T> getSetFieldObject(Object o,String property,Class<T> clazz) {
String json = JSON.toJSONString(o);
JSONObject jsonObject = JSON.parseObject(json);
Object p = jsonObject.get(property);
if (null != p ) {
return parseSetJson(JSON.toJSONString(p), clazz);
}
return null;
}
public static Map getMapFieldObject(Object o,String property) {
String json = JSON.toJSONString(o);
JSONObject jsonObject = JSON.parseObject(json);
Object p = jsonObject.get(property);
if (null != p ) {
return parseJson(JSON.toJSONString(p), Map.class);
}
return null;
}
public static void removeCache(RedisTemplate<String, Object> template,String key) { public static void removeCache(RedisTemplate<String, Object> template,String key) {
if (template.hasKey(key)) { if (template.hasKey(key)) {
template.delete(key); template.delete(key);
} }
} }
} }

Ładowanie…
Anuluj
Zapisz