mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:19:19 +08:00
fix: getSystemPermissionTree 返回全量权限树(整个平台)
- 之前错误地过滤了 id=100 的系统管理模块 - system 意为系统平台,而非系统管理模块 - 现在和 getPermissionTree 完全等价
This commit is contained in:
+1
-1
@@ -112,7 +112,7 @@ public class PermissionController {
|
||||
return ApiResponse.success(tree);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取系统权限树", description = "只返回系统管理模块下的权限(平台超管专用)")
|
||||
@Operation(summary = "获取系统权限树", description = "返回全量权限树(整个平台的权限,用于平台超管管理)")
|
||||
@GetMapping("/system/tree")
|
||||
@RequirePermission(value = "system:permission:read", description = "获取系统权限树", allowSuper = true)
|
||||
public ApiResponse<List<PermissionVO>> getSystemPermissionTree() {
|
||||
|
||||
+2
-20
@@ -240,26 +240,8 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
||||
|
||||
@Override
|
||||
public List<PermissionVO> getSystemPermissionTree() {
|
||||
List<PermissionPO> all = permissionMapper.selectAllForTree();
|
||||
List<PermissionVO> allVO = all.stream().map(this::convertToVO).collect(Collectors.toList());
|
||||
|
||||
// 按 parent_id 分组
|
||||
Map<Long, List<PermissionVO>> byParent = allVO.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
vo -> vo.getParentId() != null ? vo.getParentId() : 0L,
|
||||
Collectors.toList()));
|
||||
|
||||
// 根节点是 id=100 系统管理模块
|
||||
List<PermissionVO> root = byParent.getOrDefault(0L, Collections.emptyList());
|
||||
List<PermissionVO> systemRoot = root.stream()
|
||||
.filter(n -> n.getId() != null && n.getId() == 100)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 递归构建子树(复用已有的 buildChildrenRecursive 方法)
|
||||
for (PermissionVO node : systemRoot) {
|
||||
buildChildrenRecursive(node, byParent);
|
||||
}
|
||||
return systemRoot;
|
||||
// 返回全量权限树(整个平台的权限)
|
||||
return getPermissionTree();
|
||||
}
|
||||
|
||||
private PermissionVO convertToVO(PermissionPO po) {
|
||||
|
||||
Reference in New Issue
Block a user