| @@ -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()); | ||||
| @@ -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 | ||||
| @@ -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); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -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); | |||||
| } | } | ||||
| } | } | ||||
| @@ -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); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||