From a98228c5e829bff75969b51a37652d7dbd6bee7e Mon Sep 17 00:00:00 2001
From: chenjiantian <214228265@qq.com>
Date: 星期二, 18 一月 2022 16:24:41 +0800
Subject: [PATCH] 权限管理
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java
index 04f943a..266d379 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java
@@ -4,6 +4,7 @@
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
+import com.sandu.common.enums.RoleLevelStatus;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.execption.EntityExistException;
import com.sandu.common.service.impl.BaseServiceImpl;
@@ -83,7 +84,7 @@
Role role = new Role();
role.setName(param.getName());
role.setRemark(param.getRemark());
- role.setLevel(2);
+ role.setLevel(RoleLevelStatus.COMMON.getCode());
if(!save(role)){
throw new BusinessException("娣诲姞瑙掕壊澶辫触");
}
@@ -101,6 +102,7 @@
}
assertLevels(role.getLevel());
Role update = new Role();
+ update.setId(roleId);
update.setName(param.getName());
update.setRemark(param.getRemark());
if(!updateById(update)){
@@ -113,8 +115,12 @@
}
-
- private int assertLevels(Integer level) {
+ /**
+ * 鍒ゆ柇褰撳墠瑙掕壊鑳戒笉鑳芥搷浣滅洰鏍囩敤鎴� 涓嶈鐨勮瘽鐩存帴鎶涘嚭寮傚父
+ * @param roleLevel 鐩爣鐢ㄦ埛鐨勬渶澶ц鑹�
+ * @return
+ */
+ public int assertLevels(Integer roleLevel) {
Long userId = SecurityUtils.getUserId();
List<Role> roles = listByAdminId(userId);
if(CollectionUtil.isEmpty(roles)){
@@ -122,9 +128,9 @@
}
List<Integer> levels = roles.stream().map(Role::getLevel).collect(Collectors.toList());
int min = Collections.min(levels);
- if (level != null) {
- if (level < min) {
- throw new BusinessException("鏉冮檺涓嶈冻锛屼綘鐨勮鑹茬骇鍒細" + min + "锛屼綆浜庢搷浣滅殑瑙掕壊绾у埆锛�" + level);
+ if (roleLevel != null) {
+ if (roleLevel < min) {
+ throw new BusinessException("鏉冮檺涓嶈冻锛屼綘鐨勮鑹茬骇鍒細" + min + "锛屼綆浜庢搷浣滅殑瑙掕壊绾у埆锛�" + roleLevel);
}
}
return min;
--
Gitblit v1.9.3