wangwei 7 年之前
父節點
當前提交
22933cf9c9

+ 8 - 3
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/RolePrivilegeController.java

@@ -28,6 +28,7 @@ import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeGroupBean;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeInfo;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.UpdateRolePrivilegeRelationsReq;
+import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
 import cn.com.qmth.examcloud.core.basic.dao.AppRepo;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.PrivilegeGroupRepo;
@@ -177,7 +178,7 @@ public class RolePrivilegeController extends ControllerSupport {
 		PrivilegeGroupEntity group = privilegeGroupRepo.findOne(groupId);
 		List<PrivilegeEntity> privilegeList = privilegeRepo
 				.findAllByGroupIdOrderByWeightDesc(groupId);
-		EleTreeNode rootNode = new EleTreeNode(-1L, group.getName());
+		EleTreeNode rootNode = new EleTreeNode(BasicConsts.ROOT_PRIVILEGE_ID, group.getName());
 		TreeUtil.convert2OneEleTreeNode(rootNode, privilegeList);
 
 		return rootNode;
@@ -211,7 +212,8 @@ public class RolePrivilegeController extends ControllerSupport {
 			throw new StatusException("B-012001", "非法请求");
 		}
 
-		rolePrivilegeService.updateRolePrivilegeRelations(rootOrgId, roleId, privilegeGroupId,privilegeIdSet);
+		rolePrivilegeService.updateRolePrivilegeRelations(rootOrgId, roleId, privilegeGroupId,
+				privilegeIdSet);
 	}
 
 	@ApiOperation(value = "增加权限")
@@ -227,7 +229,8 @@ public class RolePrivilegeController extends ControllerSupport {
 			throw new StatusException("B-020001", "权限组不存在");
 		}
 
-		if (null != privilege.getParentId()) {
+		if (BasicConsts.ROOT_PRIVILEGE_ID != privilege.getParentId()) {
+
 			PrivilegeEntity parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
 			if (null == parentPrivilege) {
 				throw new StatusException("B-020002", "父权限不存在");
@@ -235,6 +238,8 @@ public class RolePrivilegeController extends ControllerSupport {
 			if (!parentPrivilege.getGroupId().equals(privilege.getGroupId())) {
 				throw new StatusException("B-020003", "权限组错误");
 			}
+		} else {
+			privilege.setParentId(null);
 		}
 
 		PrivilegeEntity ret = privilegeRepo.save(privilege);

+ 17 - 0
examcloud-core-basic-base/src/main/java/cn/com/qmth/examcloud/core/basic/base/constants/BasicConsts.java

@@ -0,0 +1,17 @@
+package cn.com.qmth.examcloud.core.basic.base.constants;
+
+/**
+ * 常量
+ *
+ * @author WANGWEI
+ * @date 2018年6月20日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public class BasicConsts {
+
+	/**
+	 * 根虚拟权限ID
+	 */
+	public static final Long ROOT_PRIVILEGE_ID = -1L;
+
+}