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

fix cache

release_toaliyun_real
xiaohanzi 5 лет назад
Родитель
Сommit
7a53a505f7
5 измененных файлов: 47 добавлений и 18 удалений
  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 Просмотреть файл

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


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

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

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


+ 3
- 9
mallinkService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java Просмотреть файл

@@ -162,18 +162,12 @@ public class WxAppinfoServiceImpl implements WxAppinfoService {
WxAppinfo record = this.getById(id);
if(record != null){
String key1 = Constant.appinfoPrev + record.getAppId();
if(wxAppinfoRedisTemplate.hasKey(key1)){
wxAppinfoRedisTemplate.delete(key1);
}
RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key1);
String key2 = Constant.appinfoPrev + record.getId();
if(wxAppinfoRedisTemplate.hasKey(key2)){
wxAppinfoRedisTemplate.delete(key2);
}
RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key2);
String key3 = Constant.appinfoPrev + record.getTenantId()
+ "-" + 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 Просмотреть файл

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

private void deleteRedis(String 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 Просмотреть файл

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

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

public class RedisCacheUtils {
@@ -97,10 +98,49 @@ public class RedisCacheUtils {
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) {
if (template.hasKey(key)) {
template.delete(key);
}
}
}

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