fix(系统设置): 获取用户组权限配置,没有翻译
--task=1012267 --user=陈建星 用户组管理-后台 https://www.tapd.cn/55049933/s/1401476
This commit is contained in:
parent
c814fa697d
commit
9ab2a11af9
|
@ -12,13 +12,6 @@ public class PermissionConstants {
|
|||
public static final String SYSTEM_USER_ROLE_DELETE = "SYSTEM_USER_ROLE:READ+DELETE";
|
||||
/*------ end: SYSTEM_USER_ROLE ------*/
|
||||
|
||||
/*------ start: SYSTEM_USER_ROLE_RELATION ------*/
|
||||
public static final String SYSTEM_USER_ROLE_RELATION_READ = "SYSTEM_USER_ROLE_RELATION_READ:READ";
|
||||
public static final String SYSTEM_USER_ROLE_RELATION_ADD = "SYSTEM_USER_ROLE_RELATION_READ:READ+ADD";
|
||||
public static final String SYSTEM_USER_ROLE_RELATION_UPDATE = "SYSTEM_USER_ROLE_RELATION_READ:READ+UPDATE";
|
||||
public static final String SYSTEM_USER_ROLE_RELATION_DELETE = "SYSTEM_USER_ROLE_RELATION_READ:READ+DELETE";
|
||||
/*------ end: SYSTEM_USER_ROLE_RELATION ------*/
|
||||
|
||||
/*------ start: SYSTEM_ORGANIZATION_PROJECT ------*/
|
||||
public static final String SYSTEM_ORGANIZATION_PROJECT_READ = "SYSTEM_ORGANIZATION_PROJECT:READ";
|
||||
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_ADD = "SYSTEM_ORGANIZATION_PROJECT:READ+ADD";
|
||||
|
@ -78,7 +71,7 @@ public class PermissionConstants {
|
|||
public static final String SYSTEM_PARAMETER_SETTING_DISPLAY_READ = "SYSTEM_PARAMETER_SETTING_DISPLAY:READ";
|
||||
public static final String SYSTEM_PARAMETER_SETTING_DISPLAY_READ_UPDATE = "SYSTEM_PARAMETER_SETTING_DISPLAY:READ+UPDATE";
|
||||
public static final String SYSTEM_PARAMETER_SETTING_AUTH_READ = "SYSTEM_PARAMETER_SETTING_AUTH:READ";
|
||||
public static final String SYSTEM_PARAMETER_SETTING_AUTH_READ_CREAT = "SYSTEM_PARAMETER_SETTING_AUTH:READ+CREAT";
|
||||
public static final String SYSTEM_PARAMETER_SETTING_AUTH_READ_ADD = "SYSTEM_PARAMETER_SETTING_AUTH:READ+ADD";
|
||||
public static final String SYSTEM_PARAMETER_SETTING_AUTH_READ_UPDATE = "SYSTEM_PARAMETER_SETTING_AUTH:READ+UPDATE";
|
||||
public static final String SYSTEM_PARAMETER_SETTING_AUTH_READ_DELETE = "SYSTEM_PARAMETER_SETTING_AUTH:READ+DELETE";
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ import io.metersphere.sdk.dto.Permission;
|
|||
import io.metersphere.sdk.dto.PermissionDefinitionItem;
|
||||
import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.PermissionCache;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.UserRole;
|
||||
import io.metersphere.system.domain.UserRoleExample;
|
||||
import io.metersphere.system.mapper.UserRoleMapper;
|
||||
|
@ -15,10 +17,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import static io.metersphere.sdk.controller.handler.result.CommonResultCode.INTERNAL_USER_ROLE_PERMISSION;
|
||||
|
||||
|
@ -48,22 +47,33 @@ public class BaseUserRoleService {
|
|||
Set<String> permissionIds = baseUserRolePermissionService.getPermissionIdSetByRoleId(userRole.getId());
|
||||
// 获取所有的权限
|
||||
List<PermissionDefinitionItem> permissionDefinition = permissionCache.getPermissionDefinition();
|
||||
// 深拷贝
|
||||
permissionDefinition = JSON.parseArray(JSON.toJSONString(permissionDefinition), PermissionDefinitionItem.class);
|
||||
|
||||
// 过滤该用户组级别的菜单,例如系统级别
|
||||
permissionDefinition = permissionDefinition.stream()
|
||||
.filter(item -> StringUtils.equals(item.getType(), userRole.getType()))
|
||||
.toList();
|
||||
|
||||
// 设置勾选项
|
||||
permissionDefinition.forEach(firstLevel -> {
|
||||
for (PermissionDefinitionItem firstLevel : permissionDefinition) {
|
||||
List<PermissionDefinitionItem> children = firstLevel.getChildren();
|
||||
boolean allCheck = true;
|
||||
firstLevel.setName(Translator.get(firstLevel.getName()));
|
||||
for (PermissionDefinitionItem secondLevel : children) {
|
||||
List<Permission> permissions = secondLevel.getPermissions();
|
||||
secondLevel.setName(Translator.get(secondLevel.getName()));
|
||||
if (CollectionUtils.isEmpty(permissions)) {
|
||||
continue;
|
||||
}
|
||||
boolean secondAllCheck = true;
|
||||
for (Permission p : permissions) {
|
||||
if (StringUtils.isNotBlank(p.getName())) {
|
||||
// 有 name 字段翻译 name 字段
|
||||
p.setName(Translator.get(p.getName()));
|
||||
} else {
|
||||
p.setName(translateDefaultPermissionName(p));
|
||||
}
|
||||
if (permissionIds.contains(p.getId())) {
|
||||
p.setEnable(true);
|
||||
} else {
|
||||
|
@ -79,11 +89,29 @@ public class BaseUserRoleService {
|
|||
}
|
||||
}
|
||||
firstLevel.setEnable(allCheck);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return permissionDefinition;
|
||||
}
|
||||
|
||||
private String translateDefaultPermissionName(Permission p) {
|
||||
if (StringUtils.isNotBlank(p.getName())) {
|
||||
p.getName();
|
||||
}
|
||||
String[] idSplit = p.getId().split(":");
|
||||
String permissionKey = idSplit[idSplit.length - 1];
|
||||
Map<String, String> translationMap = new HashMap<>(){{
|
||||
put("READ", "permission.read");
|
||||
put("READ+ADD", "permission.add");
|
||||
put("READ+UPDATE", "permission.edit");
|
||||
put("READ+DELETE", "permission.delete");
|
||||
put("READ+IMPORT", "permission.import");
|
||||
put("READ+RECOVER", "permission.recover");
|
||||
}};
|
||||
return Translator.get(translationMap.get(permissionKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新单个用户组的配置项
|
||||
* @param request
|
||||
|
|
|
@ -416,4 +416,14 @@ project=Project
|
|||
add=Add
|
||||
delete=Delete
|
||||
update=Update
|
||||
project_is_not_exist=Project is not exist
|
||||
project_is_not_exist=Project is not exist
|
||||
#permission
|
||||
permission.system.name=System
|
||||
permission.org.name=Organization
|
||||
permission.project.name=Project
|
||||
permission.read=Read
|
||||
permission.add=Create
|
||||
permission.edit=Update
|
||||
permission.delete=Delete
|
||||
permission.import=Import
|
||||
permission.recover=Recover
|
|
@ -415,3 +415,14 @@ add=添加
|
|||
delete=删除
|
||||
update=更新
|
||||
project_is_not_exist=项目不存在
|
||||
|
||||
#permission
|
||||
permission.system.name=系统
|
||||
permission.org.name=组织
|
||||
permission.project.name=项目
|
||||
permission.read=查询
|
||||
permission.add=创建
|
||||
permission.edit=修改
|
||||
permission.delete=删除
|
||||
permission.import=导入
|
||||
permission.recover=恢复
|
|
@ -413,4 +413,15 @@ project=項目
|
|||
add=添加
|
||||
delete=删除
|
||||
update=更新
|
||||
project_is_not_exist=項目不存在
|
||||
project_is_not_exist=項目不存在
|
||||
|
||||
#permission
|
||||
permission.system.name=系統
|
||||
permission.org.name=組織
|
||||
permission.project.name=項目
|
||||
permission.read=查詢
|
||||
permission.add=創建
|
||||
permission.edit=修改
|
||||
permission.delete=刪除
|
||||
permission.import=導入
|
||||
permission.recover=恢復
|
|
@ -163,15 +163,27 @@ plugin.create_user.not_blank=createUser cannot be empty
|
|||
plugin.create_user.length_range=createUser length must be between {min} and {max}
|
||||
plugin.scenario.not_blank=scenario cannot be empty
|
||||
plugin.scenario.length_range=scenario length must be between {min} and {max}
|
||||
permission.system_plugin.name=Plugin
|
||||
permission.system_plugin.read=READ
|
||||
permission.system_plugin.add=CREATE
|
||||
permission.system_plugin.edit=UPDATE
|
||||
permission.system_plugin.delete=DELETE
|
||||
plugin.exist=plugin name or filename already exists
|
||||
plugin.type.exist=plugin type already exists
|
||||
plugin.script.exist=duplicate script id
|
||||
plugin.script.format=malformed script
|
||||
# permission
|
||||
permission.system_plugin.name=Plugin
|
||||
permission.system_organization_project.name=Organization Project
|
||||
permission.system_user_role.name=User role
|
||||
permission.system_test_resource_pool.name=Resource pool
|
||||
permission.system_parameter_setting.name=Parameter setting
|
||||
permission.system_parameter_setting_base.read=Base parameter setting read
|
||||
permission.system_parameter_setting_base.update=Base parameter setting update
|
||||
permission.system_parameter_setting_display.read=Display parameter setting read
|
||||
permission.system_parameter_setting_display.update=Display parameter setting update
|
||||
permission.system_parameter_setting_auth.read=Auth parameter setting read
|
||||
permission.system_parameter_setting_auth.add=Auth parameter setting create
|
||||
permission.system_parameter_setting_auth.update=Auth parameter setting update
|
||||
permission.system_parameter_setting_auth.delete=Auth parameter setting delete
|
||||
permission.organization_user_role.name=User group
|
||||
permission.organization_member.name=User
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -162,12 +162,26 @@ plugin.create_user.not_blank=创建人不能为空
|
|||
plugin.create_user.length_range=创建人长度必须在{min}和{max}之间
|
||||
plugin.scenario.not_blank=插件使用场景PAI/PLATFORM不能为空
|
||||
plugin.scenario.length_range=插件使用场景PAI/PLATFORM长度必须在{min}和{max}之间
|
||||
permission.system_plugin.name=插件
|
||||
permission.system_plugin.read=查看插件
|
||||
permission.system_plugin.add=创建插件
|
||||
permission.system_plugin.edit=更新插件
|
||||
permission.system_plugin.delete=删除插件
|
||||
plugin.exist=插件名称或文件名已存在
|
||||
plugin.type.exist=插件类型已存在
|
||||
plugin.script.exist=脚本id重复
|
||||
plugin.script.format=脚本格式错误
|
||||
plugin.script.format=脚本格式错误
|
||||
# permission
|
||||
permission.system_plugin.name=插件
|
||||
permission.system_organization_project.name=组织与项目
|
||||
permission.system_user_role.name=用户组
|
||||
permission.system_test_resource_pool.name=资源池
|
||||
permission.system_parameter_setting.name=参数设置
|
||||
permission.system_parameter_setting_base.read=基础设置-查询
|
||||
permission.system_parameter_setting_base.update=基础设置-编辑
|
||||
permission.system_parameter_setting_display.read=界面设置-查询
|
||||
permission.system_parameter_setting_display.update=界面设置-编辑
|
||||
permission.system_parameter_setting_auth.read=认证设置-查询
|
||||
permission.system_parameter_setting_auth.add=认证设置-创建
|
||||
permission.system_parameter_setting_auth.update=认证设置-编辑
|
||||
permission.system_parameter_setting_auth.delete=认证设置-删除
|
||||
permission.organization_user_role.name=用户组
|
||||
permission.organization_member.name=用户
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -162,13 +162,24 @@ plugin.create_user.not_blank=创建人不能為空
|
|||
plugin.create_user.length_range=创建人長度必須在{min}和{max}之间
|
||||
plugin.scenario.not_blank=插件使用场景PAI/PLATFORM不能為空
|
||||
plugin.scenario.length_range=插件使用场景PAI/PLATFORM長度必須在{min}和{max}之间
|
||||
permission.system_plugin.name=插件
|
||||
permission.system_plugin.read=查看插件
|
||||
permission.system_plugin.add=創建插件
|
||||
permission.system_plugin.edit=更新插件
|
||||
permission.system_plugin.delete=刪除插件
|
||||
plugin.exist=插件名稱或文件名已存在
|
||||
plugin.type.exist=插件類型已存在
|
||||
plugin.script.exist=腳本id重複
|
||||
plugin.script.format=腳本格式錯誤
|
||||
# permission
|
||||
permission.system_plugin.name=插件
|
||||
permission.system_organization_project.name=組織與項目
|
||||
permission.system_user_role.name=用戶組
|
||||
permission.system_test_resource_pool.name=資源池
|
||||
permission.system_parameter_setting.name=參數設置
|
||||
permission.system_parameter_setting_base.read=基礎設置-查詢
|
||||
permission.system_parameter_setting_base.update=基礎設置-編輯
|
||||
permission.system_parameter_setting_display.read=界面設置-查詢
|
||||
permission.system_parameter_setting_display.update=界面設置-編輯
|
||||
permission.system_parameter_setting_auth.read=認證設置-查詢
|
||||
permission.system_parameter_setting_auth.add=認證設置-創建
|
||||
permission.system_parameter_setting_auth.update=認證設置-編輯
|
||||
permission.system_parameter_setting_auth.delete=認證設置-刪除
|
||||
permission.organization_user_role.name=用戶組
|
||||
permission.organization_member.name=用戶
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class AuthSourceController {
|
|||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增认证设置")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_PARAMETER_SETTING_AUTH_READ_CREAT)
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_PARAMETER_SETTING_AUTH_READ_ADD)
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#authSource)", msClass = AuthSourceLogService.class)
|
||||
public AuthSource add(@Validated @RequestBody AuthSourceRequest authSource) {
|
||||
return authSourceService.addAuthSource(authSource);
|
||||
|
|
|
@ -9,24 +9,19 @@
|
|||
"name": "permission.system_organization_project.name",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ",
|
||||
"name": "permission.system_organization_project.read"
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+ADD",
|
||||
"name": "permission.system_organization_project.add"
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE",
|
||||
"name": "permission.system_organization_project.update"
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+DELETE",
|
||||
"name": "permission.system_organization_project.delete"
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+DELETE"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER",
|
||||
"name": "permission.system_organization_project.recover"
|
||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -35,20 +30,16 @@
|
|||
"name": "permission.system_user_role.name",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "SYSTEM_USER_ROLE:READ",
|
||||
"name": "permission.system_user_role.read"
|
||||
"id": "SYSTEM_USER_ROLE:READ"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_USER_ROLE:READ+ADD",
|
||||
"name": "permission.system_user_role.add"
|
||||
"id": "SYSTEM_USER_ROLE:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_USER_ROLE:READ+UPDATE",
|
||||
"name": "permission.system_user_role.update"
|
||||
"id": "SYSTEM_USER_ROLE:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_USER_ROLE:READ+DELETE",
|
||||
"name": "permission.system_user_role.delete"
|
||||
"id": "SYSTEM_USER_ROLE:READ+DELETE"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -57,42 +48,36 @@
|
|||
"name": "permission.system_test_resource_pool.name",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ",
|
||||
"name": "permission.system_test_resource_pool.read"
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+ADD",
|
||||
"name": "permission.system_test_resource_pool.add"
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+UPDATE",
|
||||
"name": "permission.system_test_resource_pool.update"
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+DELETE",
|
||||
"name": "permission.system_test_resource_pool.delete"
|
||||
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+DELETE"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ",
|
||||
"name": "permission.system_plugin.read",
|
||||
"resourceId": "SYSTEM_PLUGIN"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ+ADD",
|
||||
"name": "permission.system_plugin.add",
|
||||
"resourceId": "SYSTEM_PLUGIN"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ+UPDATE",
|
||||
"name": "permission.system_plugin.edit",
|
||||
"resourceId": "SYSTEM_PLUGIN"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ+DELETE",
|
||||
"name": "permission.system_plugin.delete",
|
||||
"resourceId": "SYSTEM_PLUGIN"
|
||||
"id": "SYSTEM_PLUGIN",
|
||||
"name": "permission.system_plugin.name",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PLUGIN:READ+DELETE"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PARAMETER_SETTING",
|
||||
|
@ -119,8 +104,8 @@
|
|||
"name": "permission.system_parameter_setting_auth.read"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PARAMETER_SETTING_AUTH:READ+CREAT",
|
||||
"name": "permission.system_parameter_setting_auth.creat"
|
||||
"id": "SYSTEM_PARAMETER_SETTING_AUTH:READ+ADD",
|
||||
"name": "permission.system_parameter_setting_auth.add"
|
||||
},
|
||||
{
|
||||
"id": "SYSTEM_PARAMETER_SETTING_AUTH:READ+UPDATE",
|
||||
|
@ -144,20 +129,16 @@
|
|||
"name": "permission.organization_user_role.name",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "ORGANIZATION_USER_ROLE:READ",
|
||||
"name": "permission.organization_user_role.read"
|
||||
"id": "ORGANIZATION_USER_ROLE:READ"
|
||||
},
|
||||
{
|
||||
"id": "ORGANIZATION_USER_ROLE:READ+ADD",
|
||||
"name": "permission.organization_user_role.add"
|
||||
"id": "ORGANIZATION_USER_ROLE:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "ORGANIZATION_USER_ROLE:READ+UPDATE",
|
||||
"name": "permission.organization_user_role.update"
|
||||
"id": "ORGANIZATION_USER_ROLE:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "ORGANIZATION_USER_ROLE:READ+DELETE",
|
||||
"name": "permission.organization_user_role.delete"
|
||||
"id": "ORGANIZATION_USER_ROLE:READ+DELETE"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -166,20 +147,16 @@
|
|||
"name": "permission.organization_member.name",
|
||||
"permissions": [
|
||||
{
|
||||
"id": "ORGANIZATION_MEMBER:READ",
|
||||
"name": "permission.organization_member.read"
|
||||
"id": "ORGANIZATION_MEMBER:READ"
|
||||
},
|
||||
{
|
||||
"id": "ORGANIZATION_MEMBER:READ+ADD",
|
||||
"name": "permission.organization_member.add"
|
||||
"id": "ORGANIZATION_MEMBER:READ+ADD"
|
||||
},
|
||||
{
|
||||
"id": "ORGANIZATION_MEMBER:READ+UPDATE",
|
||||
"name": "permission.organization_member.update"
|
||||
"id": "ORGANIZATION_MEMBER:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "ORGANIZATION_MEMBER:READ+DELETE",
|
||||
"name": "permission.organization_member.delete"
|
||||
"id": "ORGANIZATION_MEMBER:READ+DELETE"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class AuthSourceControllerTests extends BaseTest {
|
|||
this.requestPost(AUTH_SOURCE_ADD, authSource);
|
||||
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_PARAMETER_SETTING_AUTH_READ_CREAT, AUTH_SOURCE_ADD, authSource);
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_PARAMETER_SETTING_AUTH_READ_ADD, AUTH_SOURCE_ADD, authSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue