fix(项目管理): 补充用户组名称长度校验
--bug=1034856 --user=宋昌昌 【项目管理】-添加用户组,名称超过 255,提示信息不友好 https://www.tapd.cn/55049933/s/1456508
This commit is contained in:
parent
ce9537644d
commit
c75aa0bb13
|
@ -10,18 +10,20 @@ import io.metersphere.project.request.ProjectUserRoleRequest;
|
||||||
import io.metersphere.project.service.ProjectUserRoleLogService;
|
import io.metersphere.project.service.ProjectUserRoleLogService;
|
||||||
import io.metersphere.project.service.ProjectUserRoleService;
|
import io.metersphere.project.service.ProjectUserRoleService;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.system.dto.permission.PermissionDefinitionItem;
|
|
||||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
|
||||||
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.system.utils.PageUtils;
|
|
||||||
import io.metersphere.system.utils.Pager;
|
|
||||||
import io.metersphere.system.domain.User;
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.domain.UserRole;
|
import io.metersphere.system.domain.UserRole;
|
||||||
|
import io.metersphere.system.dto.permission.PermissionDefinitionItem;
|
||||||
|
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
||||||
|
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||||
import io.metersphere.system.log.annotation.Log;
|
import io.metersphere.system.log.annotation.Log;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.service.UserRoleService;
|
import io.metersphere.system.service.UserRoleService;
|
||||||
|
import io.metersphere.system.utils.PageUtils;
|
||||||
|
import io.metersphere.system.utils.Pager;
|
||||||
import io.metersphere.system.utils.SessionUtils;
|
import io.metersphere.system.utils.SessionUtils;
|
||||||
|
import io.metersphere.validation.groups.Created;
|
||||||
|
import io.metersphere.validation.groups.Updated;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
@ -57,7 +59,7 @@ public class ProjectUserRoleController {
|
||||||
@Operation(summary = "项目管理-项目与权限-用户组-添加用户组")
|
@Operation(summary = "项目管理-项目与权限-用户组-添加用户组")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_GROUP_ADD)
|
@RequiresPermissions(PermissionConstants.PROJECT_GROUP_ADD)
|
||||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = ProjectUserRoleLogService.class)
|
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = ProjectUserRoleLogService.class)
|
||||||
public UserRole add(@Validated @RequestBody ProjectUserRoleEditRequest request) {
|
public UserRole add(@Validated({Created.class}) @RequestBody ProjectUserRoleEditRequest request) {
|
||||||
UserRole userRole = new UserRole();
|
UserRole userRole = new UserRole();
|
||||||
userRole.setCreateUser(SessionUtils.getUserId());
|
userRole.setCreateUser(SessionUtils.getUserId());
|
||||||
BeanUtils.copyBean(userRole, request);
|
BeanUtils.copyBean(userRole, request);
|
||||||
|
@ -68,7 +70,7 @@ public class ProjectUserRoleController {
|
||||||
@Operation(summary = "项目管理-项目与权限-用户组-修改用户组")
|
@Operation(summary = "项目管理-项目与权限-用户组-修改用户组")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_GROUP_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_GROUP_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = ProjectUserRoleLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = ProjectUserRoleLogService.class)
|
||||||
public UserRole update(@Validated @RequestBody ProjectUserRoleEditRequest request) {
|
public UserRole update(@Validated({Updated.class}) @RequestBody ProjectUserRoleEditRequest request) {
|
||||||
UserRole userRole = new UserRole();
|
UserRole userRole = new UserRole();
|
||||||
BeanUtils.copyBean(userRole, request);
|
BeanUtils.copyBean(userRole, request);
|
||||||
return projectUserRoleService.update(userRole);
|
return projectUserRoleService.update(userRole);
|
||||||
|
|
|
@ -8,14 +8,14 @@ import io.metersphere.project.request.ProjectUserRoleRequest;
|
||||||
import io.metersphere.sdk.constants.InternalUserRole;
|
import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.utils.Pager;
|
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.domain.User;
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
|
||||||
|
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
||||||
import io.metersphere.system.service.BaseUserRolePermissionService;
|
import io.metersphere.system.service.BaseUserRolePermissionService;
|
||||||
|
import io.metersphere.system.utils.Pager;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -149,14 +149,20 @@ public class ProjectUserRoleControllerTests extends BaseTest {
|
||||||
ProjectUserRoleEditRequest request = new ProjectUserRoleEditRequest();
|
ProjectUserRoleEditRequest request = new ProjectUserRoleEditRequest();
|
||||||
// 用户组不存在
|
// 用户组不存在
|
||||||
request.setId("default-pro-role-id-10");
|
request.setId("default-pro-role-id-10");
|
||||||
|
request.setName("default-pro-role-x");
|
||||||
|
request.setScopeId("default-project-2");
|
||||||
this.requestPost(PROJECT_USER_ROLE_UPDATE, request, status().is5xxServerError());
|
this.requestPost(PROJECT_USER_ROLE_UPDATE, request, status().is5xxServerError());
|
||||||
// 非项目下用户组异常
|
// 非项目下用户组异常
|
||||||
request = new ProjectUserRoleEditRequest();
|
request = new ProjectUserRoleEditRequest();
|
||||||
request.setId(InternalUserRole.ADMIN.getValue());
|
request.setId(InternalUserRole.ADMIN.getValue());
|
||||||
|
request.setName("default-pro-role-x");
|
||||||
|
request.setScopeId("default-project-2");
|
||||||
this.requestPost(PROJECT_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_PROJECT_USER_ROLE_PERMISSION.getCode()));
|
this.requestPost(PROJECT_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_PROJECT_USER_ROLE_PERMISSION.getCode()));
|
||||||
// 非全局用户组异常
|
// 非全局用户组异常
|
||||||
request = new ProjectUserRoleEditRequest();
|
request = new ProjectUserRoleEditRequest();
|
||||||
request.setId(InternalUserRole.PROJECT_ADMIN.getValue());
|
request.setId(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
|
request.setName("default-pro-role-x");
|
||||||
|
request.setScopeId("default-project-2");
|
||||||
this.requestPost(PROJECT_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_GLOBAL_USER_ROLE_PERMISSION.getCode()));
|
this.requestPost(PROJECT_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_GLOBAL_USER_ROLE_PERMISSION.getCode()));
|
||||||
// 用户组名称已存在
|
// 用户组名称已存在
|
||||||
request = new ProjectUserRoleEditRequest();
|
request = new ProjectUserRoleEditRequest();
|
||||||
|
|
|
@ -3,23 +3,25 @@ package io.metersphere.system.controller;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.system.dto.permission.PermissionDefinitionItem;
|
|
||||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
|
||||||
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.system.utils.PageUtils;
|
|
||||||
import io.metersphere.system.utils.Pager;
|
|
||||||
import io.metersphere.system.domain.User;
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.domain.UserRole;
|
import io.metersphere.system.domain.UserRole;
|
||||||
import io.metersphere.system.log.annotation.Log;
|
import io.metersphere.system.dto.permission.PermissionDefinitionItem;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleMemberEditRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleMemberEditRequest;
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleMemberRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleMemberRequest;
|
||||||
|
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
||||||
|
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||||
|
import io.metersphere.system.log.annotation.Log;
|
||||||
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.service.OrganizationUserRoleLogService;
|
import io.metersphere.system.service.OrganizationUserRoleLogService;
|
||||||
import io.metersphere.system.service.OrganizationUserRoleService;
|
import io.metersphere.system.service.OrganizationUserRoleService;
|
||||||
import io.metersphere.system.service.UserRoleService;
|
import io.metersphere.system.service.UserRoleService;
|
||||||
|
import io.metersphere.system.utils.PageUtils;
|
||||||
|
import io.metersphere.system.utils.Pager;
|
||||||
import io.metersphere.system.utils.SessionUtils;
|
import io.metersphere.system.utils.SessionUtils;
|
||||||
|
import io.metersphere.validation.groups.Created;
|
||||||
|
import io.metersphere.validation.groups.Updated;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
@ -57,7 +59,7 @@ public class OrganizationUserRoleController {
|
||||||
@Operation(summary = "系统设置-组织-用户组-添加用户组")
|
@Operation(summary = "系统设置-组织-用户组-添加用户组")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_USER_ROLE_READ_ADD)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_USER_ROLE_READ_ADD)
|
||||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = OrganizationUserRoleLogService.class)
|
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = OrganizationUserRoleLogService.class)
|
||||||
public UserRole add(@Validated @RequestBody OrganizationUserRoleEditRequest request) {
|
public UserRole add(@Validated({Created.class}) @RequestBody OrganizationUserRoleEditRequest request) {
|
||||||
UserRole userRole = new UserRole();
|
UserRole userRole = new UserRole();
|
||||||
userRole.setCreateUser(SessionUtils.getUserId());
|
userRole.setCreateUser(SessionUtils.getUserId());
|
||||||
BeanUtils.copyBean(userRole, request);
|
BeanUtils.copyBean(userRole, request);
|
||||||
|
@ -68,7 +70,7 @@ public class OrganizationUserRoleController {
|
||||||
@Operation(summary = "系统设置-组织-用户组-修改用户组")
|
@Operation(summary = "系统设置-组织-用户组-修改用户组")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_USER_ROLE_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_USER_ROLE_READ_UPDATE)
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = OrganizationUserRoleLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = OrganizationUserRoleLogService.class)
|
||||||
public UserRole update(@Validated @RequestBody OrganizationUserRoleEditRequest request) {
|
public UserRole update(@Validated({Updated.class}) @RequestBody OrganizationUserRoleEditRequest request) {
|
||||||
UserRole userRole = new UserRole();
|
UserRole userRole = new UserRole();
|
||||||
BeanUtils.copyBean(userRole, request);
|
BeanUtils.copyBean(userRole, request);
|
||||||
return organizationUserRoleService.update(userRole);
|
return organizationUserRoleService.update(userRole);
|
||||||
|
|
|
@ -3,9 +3,7 @@ package io.metersphere.system.controller;
|
||||||
import io.metersphere.sdk.constants.InternalUserRole;
|
import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.utils.Pager;
|
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.domain.User;
|
import io.metersphere.system.domain.User;
|
||||||
|
@ -14,8 +12,10 @@ import io.metersphere.system.dto.OrganizationDTO;
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleEditRequest;
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleMemberEditRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleMemberEditRequest;
|
||||||
import io.metersphere.system.dto.request.OrganizationUserRoleMemberRequest;
|
import io.metersphere.system.dto.request.OrganizationUserRoleMemberRequest;
|
||||||
|
import io.metersphere.system.dto.sdk.request.PermissionSettingUpdateRequest;
|
||||||
import io.metersphere.system.service.BaseUserRolePermissionService;
|
import io.metersphere.system.service.BaseUserRolePermissionService;
|
||||||
import io.metersphere.system.service.OrganizationService;
|
import io.metersphere.system.service.OrganizationService;
|
||||||
|
import io.metersphere.system.utils.Pager;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -118,14 +118,20 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
||||||
OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest();
|
OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest();
|
||||||
// 用户组不存在
|
// 用户组不存在
|
||||||
request.setId("default-org-role-id-10");
|
request.setId("default-org-role-id-10");
|
||||||
|
request.setName("default-org-role-x");
|
||||||
|
request.setScopeId("default-organization-2");
|
||||||
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().is5xxServerError());
|
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().is5xxServerError());
|
||||||
// 非组织下用户组异常
|
// 非组织下用户组异常
|
||||||
request = new OrganizationUserRoleEditRequest();
|
request = new OrganizationUserRoleEditRequest();
|
||||||
request.setId(InternalUserRole.ADMIN.getValue());
|
request.setId(InternalUserRole.ADMIN.getValue());
|
||||||
|
request.setName("default-org-role-x");
|
||||||
|
request.setScopeId("default-organization-2");
|
||||||
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_ORG_USER_ROLE_PERMISSION.getCode()));
|
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_ORG_USER_ROLE_PERMISSION.getCode()));
|
||||||
// 非内置用户组异常
|
// 非内置用户组异常
|
||||||
request = new OrganizationUserRoleEditRequest();
|
request = new OrganizationUserRoleEditRequest();
|
||||||
request.setId(InternalUserRole.ORG_ADMIN.getValue());
|
request.setId(InternalUserRole.ORG_ADMIN.getValue());
|
||||||
|
request.setName("default-org-role-x");
|
||||||
|
request.setScopeId("default-organization-2");
|
||||||
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_GLOBAL_USER_ROLE_PERMISSION.getCode()));
|
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request).andExpect(jsonPath("$.code").value(NO_GLOBAL_USER_ROLE_PERMISSION.getCode()));
|
||||||
// 用户组名称已存在
|
// 用户组名称已存在
|
||||||
request = new OrganizationUserRoleEditRequest();
|
request = new OrganizationUserRoleEditRequest();
|
||||||
|
|
Loading…
Reference in New Issue