From 6a2f2d1425fb8a7b00f1c7809f1762b676c2d0fa Mon Sep 17 00:00:00 2001 From: jishenghua <752718920@qq.com> Date: Wed, 2 Apr 2025 14:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B6=85=E7=AE=A1=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E8=8E=B7=E5=8F=96=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/FunctionController.java | 12 +++--- .../com/jsh/erp/service/FunctionService.java | 37 +++++++++---------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java index 0e5e2c307..f1b1378d6 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java @@ -170,11 +170,13 @@ public class FunctionController extends BaseController { if(list.size()>0) { approvalFlag = list.get(0).getMultiLevelApprovalFlag(); } + List dataList = functionService.getRoleFunction(pNumber); if (dataList.size() != 0) { + User userInfo = userService.getCurrentUser(); //获取当前用户所属的租户所拥有的功能id的map Map funIdMap = functionService.getCurrentTenantFunIdMap(); - dataArray = getMenuByFunction(dataList, fc, approvalFlag, funIdMap); + dataArray = getMenuByFunction(dataList, fc, approvalFlag, funIdMap, userInfo); //增加首页菜单项 JSONObject homeItem = new JSONObject(); homeItem.put("id", 0); @@ -190,11 +192,11 @@ public class FunctionController extends BaseController { return dataArray; } - public JSONArray getMenuByFunction(List dataList, String fc, String approvalFlag, Map funIdMap) throws Exception { + public JSONArray getMenuByFunction(List dataList, String fc, String approvalFlag, Map funIdMap, User userInfo) throws Exception { JSONArray dataArray = new JSONArray(); for (Function function : dataList) { - //如果funIdMap有值(说明不是租户)需要校验,防止分配下级用户的功能权限,大于租户的权限 - if(funIdMap == null || funIdMap.get(function.getId())!=null) { + //如果不是超管也不是租户就需要校验,防止分配下级用户的功能权限,大于租户的权限 + if("admin".equals(userInfo.getLoginName()) || userInfo.getId().equals(userInfo.getTenantId()) || funIdMap.get(function.getId())!=null) { //如果关闭多级审核,遇到任务审核菜单直接跳过 if("0".equals(approvalFlag) && "/workflow".equals(function.getUrl())) { continue; @@ -207,7 +209,7 @@ public class FunctionController extends BaseController { item.put("url", function.getUrl()); item.put("component", function.getComponent()); if (newList.size()>0) { - JSONArray childrenArr = getMenuByFunction(newList, fc, approvalFlag, funIdMap); + JSONArray childrenArr = getMenuByFunction(newList, fc, approvalFlag, funIdMap, userInfo); if(childrenArr.size()>0) { item.put("children", childrenArr); dataArray.add(item); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/FunctionService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/FunctionService.java index 8afe7773e..8074d47b0 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/FunctionService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/FunctionService.java @@ -242,28 +242,25 @@ public class FunctionService { Long roleId = 0L; String fc = ""; User userInfo = userService.getCurrentUser(); - //只返回非租户的map,如果是租户就返回空数组 - if(!userInfo.getId().equals(userInfo.getTenantId())) { - //获取当前用户所有的角色id - List roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole"); - if(roleList!=null && roleList.size()>0){ - String value = roleList.get(0).getValue(); - if(StringUtil.isNotEmpty(value)){ - String roleIdStr = value.replace("[", "").replace("]", ""); - roleId = Long.parseLong(roleIdStr); - } - } - //当前用户所拥有的功能列表,格式如:[1][2][5] - List funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions"); - if(funList!=null && funList.size()>0){ - fc = funList.get(0).getValue(); - } - if(StringUtil.isNotEmpty(fc)) { - fc = fc.substring(1, fc.length() - 1); - fc = fc.replace("][",","); - funIdList = StringUtil.strToLongList(fc); + //获取当前用户所有的角色id + List roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole"); + if(roleList!=null && roleList.size()>0){ + String value = roleList.get(0).getValue(); + if(StringUtil.isNotEmpty(value)){ + String roleIdStr = value.replace("[", "").replace("]", ""); + roleId = Long.parseLong(roleIdStr); } } + //当前用户所拥有的功能列表,格式如:[1][2][5] + List funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions"); + if(funList!=null && funList.size()>0){ + fc = funList.get(0).getValue(); + } + if(StringUtil.isNotEmpty(fc)) { + fc = fc.substring(1, fc.length() - 1); + fc = fc.replace("][",","); + funIdList = StringUtil.strToLongList(fc); + } return funIdList; }