From 0c6be90e78c1f02a6ba20f219e7b3985af4aca91 Mon Sep 17 00:00:00 2001
From: 田源 <tianyuan@vci-tech.com>
Date: 星期三, 08 一月 2025 10:45:27 +0800
Subject: [PATCH] 按钮设计树结构添加判空不展示图标&&角色管理分配成员修改为行内展示
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/RightControlUtil.java | 69 +++++++++++++++++++++++-----------
1 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/RightControlUtil.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/RightControlUtil.java
index 7403ec3..896915e 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/RightControlUtil.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/RightControlUtil.java
@@ -1,6 +1,5 @@
package com.vci.web.util;
-import com.vci.client.common.objects.RoleObject;
-import com.vci.common.exception.VciException;
+
import com.vci.corba.common.PLException;
import com.vci.corba.framework.data.FunctionInfo;
import com.vci.corba.framework.data.RoleInfo;
@@ -10,15 +9,12 @@
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
@Slf4j
@Component
public class RightControlUtil {
-
@Resource
private PlatformClientUtil platformClientUtil;
@@ -26,11 +22,17 @@
// add by xchao 2012.09.20 缁熶竴褰掓暣绠$悊鍛樸�佸紑鍙戣�呯敤鎴峰垽鏂�
// 浠ヤ究灏嗘潵鏈夊彲鑳戒慨鏀圭鐞嗗憳銆佸紑鍙戣�呯敤鎴凤紝瀵逛簬鍒ゆ柇渚濈劧鏈夋晥
private static String userAdminEnum = "user.admin";
+
private String userNameAdmin = null;
+
private static String userDeveloperEnum = "user.developer";
+
private String userNameDeveloper = null;
+
private String userNameRoot = null;
+
private static String userRootEnum = "user.rooter";
+
public boolean isAdmin(String userName){
return userName.equals(getUserNameAdmin(userAdminEnum));
}
@@ -71,6 +73,7 @@
}
return userNameAdmin;
}
+
/**
* 鑾峰彇閰嶇疆鐨勫紑鍙戜汉鍛�
* @param key 閰嶇疆key
@@ -118,7 +121,7 @@
public boolean isThreeAdminCurUser() {
SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException();
try {
- RoleInfo[] roles = platformClientUtil.getFrameworkService().fetchRoleInfoByUserId(sessionInfo.getUserId());
+ RoleInfo[] roles = platformClientUtil.getFrameworkService().fetchRoleInfoByUserId(sessionInfo.getUserOid());
for (RoleInfo role : roles) {
if (role.name.equalsIgnoreCase("绯荤粺绠$悊鍛�")){
return true;
@@ -153,7 +156,6 @@
return roleRightByUserName;
}
-
/**
* 鑾峰彇褰撳墠鐢ㄦ埛鍏锋湁鏉冮檺鐨勬墍鏈夋ā鍧�
* @param parentId, 鐖舵ā鍧梚d
@@ -170,7 +172,7 @@
if (mapRight.containsKey(right.funcId)) {
lstRight = mapRight.get(right.funcId);
} else {
- lstRight = new ArrayList<RoleRightInfo>();
+ lstRight = new ArrayList<>();
}
lstRight.add(right);
mapRight.put(right.funcId, lstRight);
@@ -199,18 +201,8 @@
else{
if (lstRight.size() > 0)
isHasRight = true;
-// for (int j = 0; j < lstRight.size(); j++) {
-// long lRight = lstRight.get(j).getRightValue();
-// if (lRight != 0){
-// isHasRight = true;
-// //System.out.println(" === 鏈夋巿鏉�");
-//
-// break;
-// }
-// }
}
}
-
if (!isHasRight) {
continue;
}
@@ -229,9 +221,7 @@
return map;
}
-
public FunctionInfo[] getFunctionsByParentId(String parentId, String userName) {
-
FunctionInfo[] funcObjs = null;
try {
if(isDeveloper(userName)){
@@ -244,6 +234,40 @@
log.error(e.code, e.messages);
}
return funcObjs;
+ }
+
+ /**
+ * 鏍规嵁鐖朵富閿拰鐢ㄦ埛浠ュ強瑙掕壊淇℃伅鏉ヨ繑鍥炶彍鍗曟暟鎹�
+ * @param parentId
+ * @param userName
+ * @param userRoleRights
+ * @return
+ */
+ public List<FunctionInfo> getMenusByPIdAndPermission(String parentId, String userName,RoleRightInfo[] userRoleRights) {
+ Map<String, List<RoleRightInfo>> mapRight = new LinkedHashMap<String, List<RoleRightInfo>>();
+ for (int i = 0; i < userRoleRights.length; i++) {
+ RoleRightInfo right = userRoleRights[i];
+
+ List<RoleRightInfo> lstRight = null;
+ if (mapRight.containsKey(right.funcId)) {
+ lstRight = mapRight.get(right.funcId);
+ } else {
+ lstRight = new ArrayList<>();
+ }
+ lstRight.add(right);
+ mapRight.put(right.funcId, lstRight);
+ }
+ FunctionInfo[] functionInfos = this.getFunctionsByParentId(parentId, userName);
+ boolean isAllShow = isDeveloper(userName) || isAdmin(userName) || !isFunctionSwithOn();
+
+ List<FunctionInfo> functionInfoList = Arrays.stream(functionInfos).filter(menu -> {
+ // 鍙繑鍥炴湁鏁堜笖鏄彍鍗曠殑鑺傜偣
+ if ((menu.isValid && menu.functionType == 0) && (mapRight.containsKey(menu.id) || isAllShow)) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
+ return functionInfoList;
}
/**
@@ -264,4 +288,5 @@
return false;
}
+
}
--
Gitblit v1.9.3