From 58032b964fa5dee3924847943548093af6dcb098 Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Thu, 28 Oct 2021 10:32:24 +0800 Subject: [PATCH] Merge branch 'score_shop' into api_score_meger --- zq-erp/src/main/java/com/matrix/system/app/authority/AppAuthorityManager.java | 32 ++++++++------------------------ 1 files changed, 8 insertions(+), 24 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/app/authority/AppAuthorityManager.java b/zq-erp/src/main/java/com/matrix/system/app/authority/AppAuthorityManager.java index c481134..fb84dee 100644 --- a/zq-erp/src/main/java/com/matrix/system/app/authority/AppAuthorityManager.java +++ b/zq-erp/src/main/java/com/matrix/system/app/authority/AppAuthorityManager.java @@ -1,10 +1,6 @@ package com.matrix.system.app.authority; import cn.hutool.crypto.SecureUtil; -import cn.hutool.json.JSONArray; -import cn.hutool.json.JSONObject; -import cn.hutool.json.JSONUtil; -import com.matrix.component.redis.RedisClient; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.StringUtils; @@ -15,6 +11,7 @@ import com.matrix.system.common.bean.SysFunction; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.common.init.LocalCache; import com.matrix.system.common.service.SysFunctionService; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +33,6 @@ private static final int DEFAULT_2 = 2; - @Autowired - RedisClient redisClient; @Autowired SysFunctionService sysFunctionService; @@ -103,22 +98,13 @@ String redisKey = USER_POWER_REDISKEY_APP + SecureUtil.md5(user.getSuId()+""); - String cachedValue = redisClient.getCachedValue(redisKey); - if (StringUtils.isNotBlank(cachedValue)) { - //从缓存中获取用户权限 - JSONObject powerMap = JSONUtil.parseObj(cachedValue); - String userFunctionMapStr = powerMap.get(USERFUNCTION).toString(); - JSONObject userFunctionMap = JSONUtil.parseObj(userFunctionMapStr); - Set<String> userFunctionMapKeys = userFunctionMap.keySet(); - userFunctionMapKeys.forEach(key -> { - userFunction.put(key, userFunctionMap.get(key, SysFunction.class)); - }); + Map<String, Object> cachePowerMap = LocalCache.get(redisKey); + if (Objects.nonNull(cachePowerMap)) { - String userUrlMappingListStr = powerMap.get(USER_URL_MAPPING).toString(); - JSONArray userUrlMappingArray = JSONUtil.parseArray(userUrlMappingListStr); - for (int i = 0; i < userUrlMappingArray.size(); i++) { - userUrlMapping.add(userUrlMappingArray.get(i, String.class)); - } + userFunction = (Map<String, SysFunction>) cachePowerMap.get(USERFUNCTION); + + userUrlMapping = (List<String>) cachePowerMap.get(USER_URL_MAPPING); + } else { // 获取用户所有权限 getUserFunction(user,userFunction, userUrlMapping); @@ -126,11 +112,9 @@ Map<String ,Object> powerMap=new HashMap<>(); powerMap.put(USERFUNCTION, userFunction); powerMap.put(USER_URL_MAPPING, userUrlMapping); - redisClient.saveValue(redisKey,JSONUtil.parseObj(powerMap,true)); + LocalCache.save(redisKey,powerMap); } - - // TODO 这里的用户权限应该放到redis缓存中,在拦截器中做权限拦截 WebUtil.setSessionAttribute(USERFUNCTION, userFunction); WebUtil.setSessionAttribute(USER_URL_MAPPING, userUrlMapping); result.putInMap(USERFUNCTION, userFunction); -- Gitblit v1.9.1