From c0e0761eec99d3642b6a1acdcdb5e2b51a481aaf Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Wed, 11 Dec 2024 20:49:28 +0800
Subject: [PATCH] 权限配置

---
 skjcmanager/skjcmanager-service/skjcmanager-system/src/main/java/cn/gistack/system/controller/RoleController.java |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/skjcmanager/skjcmanager-service/skjcmanager-system/src/main/java/cn/gistack/system/controller/RoleController.java b/skjcmanager/skjcmanager-service/skjcmanager-system/src/main/java/cn/gistack/system/controller/RoleController.java
index 28d04c2..9ee2fec 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-system/src/main/java/cn/gistack/system/controller/RoleController.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-system/src/main/java/cn/gistack/system/controller/RoleController.java
@@ -30,6 +30,7 @@
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.annotation.PreAuth;
 import org.springblade.core.secure.constant.AuthConstant;
+import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.constant.BladeConstant;
@@ -59,7 +60,7 @@
 @AllArgsConstructor
 @RequestMapping("/role")
 @Api(value = "角色", tags = "角色")
-@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
+//@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
 public class RoleController extends BladeController {
 
 	private final IRoleService roleService;
@@ -87,6 +88,10 @@
 	@ApiOperation(value = "列表", notes = "传入role")
 	public R<List<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser) {
 		QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class);
+		// 不是超级管理员,排除超级管理员查询
+		if (!AuthUtil.isAdministrator()){
+			queryWrapper.ne("ROLE_ALIAS", "administrator");
+		}
 		List<Role> list = roleService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper);
 		return R.data(RoleWrapper.build().listNodeVO(list));
 	}
@@ -102,6 +107,26 @@
 		return R.data(tree);
 	}
 
+	@GetMapping("/treeByParentId")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "树形结构", notes = "树形结构")
+	public R<List<RoleVO>> treeByParentId(String parentId) {
+		List<RoleVO> tree = roleService.treeByParentId(parentId);
+		return R.data(tree);
+	}
+
+	/**
+	 * 根据父级角色查询子角色
+	 * @param parentId
+	 * @return
+	 */
+	@GetMapping("/treeByParentIdNew")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "树形结构", notes = "树形结构")
+	public R<List<RoleVO>> treeByParentIdNew(String parentId) {
+		List<RoleVO> tree = roleService.treeByParentIdNew(parentId);
+		return R.data(tree);
+	}
 	/**
 	 * 获取指定角色树形结构
 	 */
@@ -145,6 +170,7 @@
 	@PostMapping("/grant")
 	@ApiOperationSupport(order = 7)
 	@ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合")
+//	@PreAuth(AuthConstant.HAS_ROLE_ADMIN)
 	public R grant(@RequestBody GrantVO grantVO) {
 		CacheUtil.clear(SYS_CACHE);
 		CacheUtil.clear(SYS_CACHE, Boolean.FALSE);

--
Gitblit v1.9.3