jyy
2021-09-03 3868b706ee3ee115a400d77abc3b69b83ea448c7
zq-erp/src/main/java/com/matrix/system/common/authority/DefaultAuthorityManager.java
@@ -35,6 +35,7 @@
    private static final int DEFAULT_2 = 2;
    public static final String USER_POWER_REDISKEY = "USER_POWER_";
    public static final String USER_POWER_REDISKEY_PC = "USER_POWER_PC";
    @Autowired
    SysFunctionService sysFunctionService;
@@ -78,24 +79,33 @@
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        Map<String, SysFunction> userFunction = WebUtil.getSessionAttribute(USERFUNCTION);
        // 企业管理员不校验按钮权限
        if (AppConstance.USER_TYPE_DEVELOPER.equals(user.getSuUserType())
                || AppConstance.USER_TYPE_SUPER.equals(user.getSuUserType())
                || AppConstance.USER_TYPE_ADMIN.equals(user.getSuUserType())) {
            return true;
        }
        String[] strs = matchStr.split("-");
        if (strs.length != DEFAULT_2) {
            throw new IllegalArgumentException("权限matchStr格式错误,需要fnCode:btnValue");
        }
        SysFunction fn = userFunction.get(strs[0].trim());
        // 功能是否存在
        if (fn == null) {
        if (userFunction == null) {
            return false;
        } else {
            return StringUtils.isContentSet(strs[1].trim(), fn.getRpfBns());
            String[] strs = matchStr.split("-");
            if (strs.length != DEFAULT_2) {
                throw new IllegalArgumentException("权限matchStr格式错误,需要fnCode:btnValue");
            }
            SysFunction fn = userFunction.get(strs[0].trim());
            // 功能是否存在
            if (fn == null) {
                return false;
            } else {
                return StringUtils.isContentSet(strs[1].trim(), fn.getRpfBns());
            }
        }
    }
    /**
@@ -112,8 +122,13 @@
            return true;
        }
        Map<String, SysFunction> userFunction = WebUtil.getSessionAttribute(USERFUNCTION);
        SysFunction fn = userFunction.get(fnCode);
        return fn == null ? false : true;
        if (userFunction == null) {
            return false;
        } else {
            SysFunction fn = userFunction.get(fnCode);
            return fn == null ? false : true;
        }
    }
    /**
@@ -140,7 +155,7 @@
        SysUsers sysUser = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        String redisKey = USER_POWER_REDISKEY + SecureUtil.md5(sysUser.getSuId()+"");
        String redisKey = USER_POWER_REDISKEY_PC + SecureUtil.md5(sysUser.getSuId() + "");
        String cachedValue = redisClient.getCachedValue(redisKey);
        if (StringUtils.isNotBlank(cachedValue)) {
            //从缓存中获取用户权限
@@ -168,11 +183,11 @@
            // 组装菜单
            assembleMenu(menuFunction, menuFunctionMap);
            Map<String ,Object> powerMap=new HashMap<>();
            Map<String, Object> powerMap = new HashMap<>();
            powerMap.put(USERFUNCTION, userFunction);
            powerMap.put(MENUSFUNCTION, menuFunction);
            powerMap.put(USER_URL_MAPPING, userUrlMapping);
            redisClient.saveValue(redisKey,JSONUtil.parseObj(powerMap,true));
            redisClient.saveValue(redisKey, JSONUtil.parseObj(powerMap, true));
        }