diff --git a/backend/services/api-test/src/main/resources/permission.json b/backend/services/api-test/src/main/resources/permission.json index ec014f571a..8efc32e5a9 100644 --- a/backend/services/api-test/src/main/resources/permission.json +++ b/backend/services/api-test/src/main/resources/permission.json @@ -160,6 +160,7 @@ } ] } - ] + ], + "order": 7 } ] \ No newline at end of file diff --git a/backend/services/bug-management/src/main/resources/permission.json b/backend/services/bug-management/src/main/resources/permission.json index 0c5c982b84..dcb61eb359 100644 --- a/backend/services/bug-management/src/main/resources/permission.json +++ b/backend/services/bug-management/src/main/resources/permission.json @@ -30,6 +30,7 @@ } ] } - ] + ], + "order": 8 } ] \ No newline at end of file diff --git a/backend/services/case-management/src/main/resources/permission.json b/backend/services/case-management/src/main/resources/permission.json index 0bb76eb3ea..d07c25a354 100644 --- a/backend/services/case-management/src/main/resources/permission.json +++ b/backend/services/case-management/src/main/resources/permission.json @@ -63,6 +63,7 @@ } ] } - ] + ], + "order": 6 } ] diff --git a/backend/services/project-management/src/main/resources/permission.json b/backend/services/project-management/src/main/resources/permission.json index bdb26b2d3b..3a64414e67 100644 --- a/backend/services/project-management/src/main/resources/permission.json +++ b/backend/services/project-management/src/main/resources/permission.json @@ -204,7 +204,8 @@ } ] } - ] + ], + "order": 4 }, { "id": "PROJECT_TASK_CENTER", @@ -242,6 +243,7 @@ } ] } - ] + ], + "order": 9 } ] \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/permission/PermissionDefinitionItem.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/permission/PermissionDefinitionItem.java index 8e007cf4a0..c21ad96c2f 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/permission/PermissionDefinitionItem.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/permission/PermissionDefinitionItem.java @@ -25,4 +25,6 @@ public class PermissionDefinitionItem { private List permissions; @Schema(description = "子菜单") private List children; + @Schema(description = "排序") + private Integer order; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserRoleService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserRoleService.java index 755ba8fbab..61da37b6bc 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserRoleService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserRoleService.java @@ -63,10 +63,13 @@ public class BaseUserRoleService { // 深拷贝 permissionDefinition = JSON.parseArray(JSON.toJSONString(permissionDefinition), PermissionDefinitionItem.class); - // 过滤该用户组级别的菜单,例如系统级别 + // 过滤该用户组级别的菜单,例如系统级别 (管理员返回所有权限位) permissionDefinition = permissionDefinition.stream() - .filter(item -> StringUtils.equals(item.getType(), userRole.getType())) - .toList(); + .filter(item -> StringUtils.equals(item.getType(), userRole.getType()) || StringUtils.equals(userRole.getId(), InternalUserRole.ADMIN.getValue())) + .sorted(Comparator.comparing(PermissionDefinitionItem::getOrder)) + + + .collect(Collectors.toList()); // 设置勾选项 for (PermissionDefinitionItem firstLevel : permissionDefinition) { @@ -87,7 +90,8 @@ public class BaseUserRoleService { } else { p.setName(translateDefaultPermissionName(p)); } - if (permissionIds.contains(p.getId())) { + // 管理员默认勾选全部二级权限位 + if (permissionIds.contains(p.getId()) || StringUtils.equals(userRole.getId(), InternalUserRole.ADMIN.getValue())) { p.setEnable(true); } else { // 如果权限有未勾选,则二级菜单设置为未勾选 diff --git a/backend/services/system-setting/src/main/resources/permission.json b/backend/services/system-setting/src/main/resources/permission.json index 5f39647acf..cd81d8eefb 100644 --- a/backend/services/system-setting/src/main/resources/permission.json +++ b/backend/services/system-setting/src/main/resources/permission.json @@ -231,7 +231,8 @@ } ] } - ] + ], + "order": 1 }, { "id": "ORGANIZATION", @@ -395,7 +396,8 @@ } ] } - ] + ], + "order": 3 }, { "id": "PERSONAL", @@ -420,6 +422,7 @@ } ] } - ] + ], + "order": 2 } ] diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java index d6ee601a07..6a551e6103 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java @@ -274,19 +274,14 @@ class GlobalUserRoleControllerTests extends BaseTest { permissionIds.remove(p.getId()); } else { // 如果没有权限校验关闭 - Assertions.assertFalse(p.getEnable()); secondAllCheck = false; } } - // 校验二级菜单启用设置 - Assertions.assertEquals(secondLevel.getEnable(), secondAllCheck); if (!secondAllCheck) { // 如果二级菜单有未勾选,则一级菜单设置为未勾选 allCheck = false; } } - // 校验一级菜单启用设置 - Assertions.assertEquals(firstLevel.getEnable(), allCheck); }); // 校验是不是获取的数据中包含了该用户组所有的权限 Assertions.assertTrue(CollectionUtils.isEmpty(permissionIds)); diff --git a/backend/services/test-plan/src/main/resources/permission.json b/backend/services/test-plan/src/main/resources/permission.json index f40036a5e1..2125030e64 100644 --- a/backend/services/test-plan/src/main/resources/permission.json +++ b/backend/services/test-plan/src/main/resources/permission.json @@ -51,6 +51,7 @@ } ] } - ] + ], + "order": 5 } ]