From 119cad5d7686bd97393fa45bbaddd62b22e34e32 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Fri, 2 Feb 2024 14:36:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=E7=A4=BE=E5=8C=BA=E7=89=88=E5=B9=B6=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemOrganizationController.java | 68 ++++++- .../system/service/OrganizationService.java | 166 ++++++++++++++++++ .../service/SystemOrganizationLogService.java | 143 +++++++++++++++ .../SystemOrganizationControllerTests.java | 101 +++++++++-- 4 files changed, 457 insertions(+), 21 deletions(-) create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemOrganizationLogService.java diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java index 20f4fec87d..2a479e90b7 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java @@ -6,18 +6,19 @@ import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.system.dto.OrganizationDTO; import io.metersphere.system.dto.ProjectDTO; -import io.metersphere.system.dto.request.OrganizationMemberRequest; -import io.metersphere.system.dto.request.OrganizationProjectRequest; -import io.metersphere.system.dto.request.OrganizationRequest; -import io.metersphere.system.dto.request.ProjectRequest; +import io.metersphere.system.dto.request.*; import io.metersphere.system.dto.sdk.OptionDTO; 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.OrganizationService; +import io.metersphere.system.service.SystemOrganizationLogService; import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.UserService; import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; +import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -56,6 +57,65 @@ public class SystemOrganizationController { return PageUtils.setPageInfo(page, organizationService.list(request)); } + @PostMapping("/update") + @Operation(summary = "系统设置-系统-组织与项目-组织-修改组织") + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE) + @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#organizationEditRequest)", msClass = SystemOrganizationLogService.class) + public void update(@Validated({Updated.class}) @RequestBody OrganizationEditRequest organizationEditRequest) { + OrganizationDTO organizationDTO = new OrganizationDTO(); + BeanUtils.copyBean(organizationDTO, organizationEditRequest); + organizationDTO.setUpdateUser(SessionUtils.getUserId()); + organizationService.update(organizationDTO); + } + + @PostMapping("/rename") + @Operation(summary = "系统设置-系统-组织与项目-组织-修改组织名称") + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE) + @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateNameLog(#organizationEditRequest)", msClass = SystemOrganizationLogService.class) + public void rename(@Validated({Updated.class}) @RequestBody OrganizationNameEditRequest organizationEditRequest) { + OrganizationDTO organizationDTO = new OrganizationDTO(); + BeanUtils.copyBean(organizationDTO, organizationEditRequest); + organizationDTO.setUpdateUser(SessionUtils.getUserId()); + organizationService.updateName(organizationDTO); + } + + @GetMapping("/delete/{id}") + @Operation(summary = "系统设置-系统-组织与项目-组织-删除组织") + @Parameter(name = "id", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_DELETE) + @Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = SystemOrganizationLogService.class) + public void delete(@PathVariable String id) { + OrganizationDeleteRequest organizationDeleteRequest = new OrganizationDeleteRequest(); + organizationDeleteRequest.setOrganizationId(id); + organizationDeleteRequest.setDeleteUserId(SessionUtils.getUserId()); + organizationService.delete(organizationDeleteRequest); + } + + @GetMapping("/recover/{id}") + @Operation(summary = "系统设置-系统-组织与项目-组织-恢复组织") + @Parameter(name = "id", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_RECOVER) + @Log(type = OperationLogType.RECOVER, expression = "#msClass.recoverLog(#id)", msClass = SystemOrganizationLogService.class) + public void recover(@PathVariable String id) { + organizationService.recover(id); + } + + @GetMapping("/enable/{id}") + @Operation(summary = "系统设置-系统-组织与项目-组织-启用组织") + @Parameter(name = "id", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE) + public void enable(@PathVariable String id) { + organizationService.enable(id); + } + + @GetMapping("/disable/{id}") + @Operation(summary = "系统设置-系统-组织与项目-组织-结束组织") + @Parameter(name = "id", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE) + public void disable(@PathVariable String id) { + organizationService.disable(id); + } + @PostMapping("/option/all") @Operation(summary = "系统设置-系统-组织与项目-组织-获取系统所有组织下拉选项") @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java index 731c6f2c24..cf7496cbd6 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java @@ -78,6 +78,7 @@ public class OrganizationService { private static final String ADD_MEMBER_PATH = "/system/organization/add-member"; private static final String REMOVE_MEMBER_PATH = "/system/organization/remove-member"; public static final Integer DEFAULT_REMAIN_DAY_COUNT = 30; + private static final Long DEFAULT_ORGANIZATION_NUM = 100001L; /** * 分页获取系统下组织列表 @@ -104,6 +105,102 @@ public class OrganizationService { return organizations.stream().map(o -> new OptionDTO(o.getId(), o.getName())).toList(); } + /** + * 更新组织名称 + * @param organizationDTO 组织请求参数 + */ + public void updateName(OrganizationDTO organizationDTO) { + checkOrganizationNotExist(organizationDTO.getId()); + checkOrganizationExist(organizationDTO); + organizationDTO.setUpdateTime(System.currentTimeMillis()); + organizationDTO.setCreateUser(null); + organizationDTO.setCreateTime(null); + organizationMapper.updateByPrimaryKeySelective(organizationDTO); + } + + /** + * 更新组织 + * @param organizationDTO 组织请求参数 + */ + public void update(OrganizationDTO organizationDTO) { + checkOrganizationNotExist(organizationDTO.getId()); + checkOrganizationExist(organizationDTO); + organizationDTO.setUpdateTime(System.currentTimeMillis()); + organizationDTO.setCreateUser(null); + organizationDTO.setCreateTime(null); + organizationMapper.updateByPrimaryKeySelective(organizationDTO); + + // 新增的组织管理员ID + List addOrgAdmins = organizationDTO.getUserIds(); + // 旧的组织管理员ID + List oldOrgAdmins = getOrgAdminIds(organizationDTO.getId()); + if (CollectionUtils.isNotEmpty(addOrgAdmins)) { + // 需要新增组织管理员ID + List addIds = addOrgAdmins.stream().filter(addOrgAdmin -> !oldOrgAdmins.contains(addOrgAdmin)).toList(); + // 需要删除的组织管理员ID + List deleteIds = oldOrgAdmins.stream().filter(oldOrgAdmin -> !addOrgAdmins.contains(oldOrgAdmin)).toList(); + // 添加组织管理员 + if (CollectionUtils.isNotEmpty(addIds)) { + addIds.forEach(userId -> { + // 添加组织管理员 + createAdmin(userId, organizationDTO.getId(), organizationDTO.getUpdateUser()); + }); + } + // 删除组织管理员 + if (CollectionUtils.isNotEmpty(deleteIds)) { + UserRoleRelationExample deleteExample = new UserRoleRelationExample(); + deleteExample.createCriteria().andSourceIdEqualTo(organizationDTO.getId()).andRoleIdEqualTo(InternalUserRole.ORG_ADMIN.getValue()).andUserIdIn(deleteIds); + userRoleRelationMapper.deleteByExample(deleteExample); + } + } else { + // 前端传入的组织管理员ID为空,删除所有组织管理员 + if (CollectionUtils.isNotEmpty(oldOrgAdmins)) { + UserRoleRelationExample example = new UserRoleRelationExample(); + example.createCriteria().andSourceIdEqualTo(organizationDTO.getId()).andRoleIdEqualTo(InternalUserRole.ORG_ADMIN.getValue()); + userRoleRelationMapper.deleteByExample(example); + } + } + } + + /** + * 删除组织 + * @param organizationDeleteRequest 组织删除参数 + */ + public void delete(OrganizationDeleteRequest organizationDeleteRequest) { + // 默认组织不允许删除 + checkOrgDefault(organizationDeleteRequest.getOrganizationId()); + checkOrganizationNotExist(organizationDeleteRequest.getOrganizationId()); + organizationDeleteRequest.setDeleteTime(System.currentTimeMillis()); + extOrganizationMapper.delete(organizationDeleteRequest); + } + + /** + * 恢复组织 + * @param id 组织ID + */ + public void recover(String id) { + checkOrganizationNotExist(id); + extOrganizationMapper.recover(id); + } + + /** + * 开启组织 + * @param id 组织ID + */ + public void enable(String id) { + checkOrganizationNotExist(id); + extOrganizationMapper.updateEnable(id, Boolean.TRUE); + } + + /** + * 结束组织 + * @param id 组织ID + */ + public void disable(String id) { + checkOrganizationNotExist(id); + extOrganizationMapper.updateEnable(id, Boolean.FALSE); + } + /** * 分页获取组织成员列表 * @@ -935,4 +1032,73 @@ public class OrganizationService { int remainDayCount = DEFAULT_REMAIN_DAY_COUNT - (int) remainDays; return remainDayCount > 0 ? remainDayCount : 1; } + + /** + * 校验组织不存在 + * + * @param id 组织ID + */ + private void checkOrganizationNotExist(String id) { + if (organizationMapper.selectByPrimaryKey(id) == null) { + throw new MSException(Translator.get("organization_not_exist")); + } + } + + /** + * 校验组织存在 + * + * @param organizationDTO 组织DTO + */ + private void checkOrganizationExist(OrganizationDTO organizationDTO) { + OrganizationExample example = new OrganizationExample(); + OrganizationExample.Criteria criteria = example.createCriteria(); + criteria.andNameEqualTo(organizationDTO.getName()).andIdNotEqualTo(organizationDTO.getId()); + if (organizationMapper.countByExample(example) > 0) { + throw new MSException(Translator.get("organization_name_already_exists")); + } + } + + /** + * 获取组织下所有管理员ID + * + * @param organizationId 组织ID + * @return 管理员ID集合 + */ + public List getOrgAdminIds(String organizationId) { + UserRoleRelationExample example = new UserRoleRelationExample(); + example.createCriteria().andSourceIdEqualTo(organizationId).andRoleIdEqualTo(InternalUserRole.ORG_ADMIN.getValue()); + List userRoleRelations = userRoleRelationMapper.selectByExample(example); + return userRoleRelations.stream().map(UserRoleRelation::getUserId).toList(); + } + + /** + * 成员添加组织管理员 + * + * @param memberId 成员ID + * @param organizationId 组织ID + * @param createUser 创建用户 + */ + public void createAdmin(String memberId, String organizationId, String createUser) { + UserRoleRelation orgAdmin = new UserRoleRelation(); + orgAdmin.setId(IDGenerator.nextStr()); + orgAdmin.setUserId(memberId); + orgAdmin.setRoleId(InternalUserRole.ORG_ADMIN.getValue()); + orgAdmin.setSourceId(organizationId); + orgAdmin.setCreateTime(System.currentTimeMillis()); + orgAdmin.setCreateUser(createUser); + orgAdmin.setOrganizationId(organizationId); + userRoleRelationMapper.insertSelective(orgAdmin); + } + + /** + * 校验组织是否为默认组织 + * + * @param id 组织ID + */ + private void checkOrgDefault(String id) { + Organization organization = organizationMapper.selectByPrimaryKey(id); + if (organization.getNum().equals(DEFAULT_ORGANIZATION_NUM)) { + throw new MSException(Translator.get("default_organization_not_allow_delete")); + } + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemOrganizationLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemOrganizationLogService.java new file mode 100644 index 0000000000..1cf5048682 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemOrganizationLogService.java @@ -0,0 +1,143 @@ +package io.metersphere.system.service; + +import io.metersphere.sdk.constants.HttpMethodConstants; +import io.metersphere.sdk.constants.OperationLogConstants; +import io.metersphere.sdk.util.JSON; +import io.metersphere.system.domain.Organization; +import io.metersphere.system.domain.User; +import io.metersphere.system.domain.UserExample; +import io.metersphere.system.dto.request.OrganizationEditRequest; +import io.metersphere.system.dto.request.OrganizationNameEditRequest; +import io.metersphere.system.log.constants.OperationLogModule; +import io.metersphere.system.log.constants.OperationLogType; +import io.metersphere.system.log.dto.LogDTO; +import io.metersphere.system.mapper.OrganizationMapper; +import io.metersphere.system.mapper.UserMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Transactional(rollbackFor = Exception.class) +public class SystemOrganizationLogService { + + @Resource + private UserMapper userMapper; + @Resource + private OrganizationMapper organizationMapper; + @Resource + private OrganizationService organizationService; + + /** + * 更新组织 + * + * @param request 接口请求参数 + * @return 日志详情 + */ + public LogDTO updateNameLog(OrganizationNameEditRequest request) { + Organization organization = organizationMapper.selectByPrimaryKey(request.getId()); + if (organization != null) { + LogDTO dto = new LogDTO( + OperationLogConstants.SYSTEM, + OperationLogConstants.SYSTEM, + request.getId(), + null, + OperationLogType.UPDATE.name(), + OperationLogModule.SETTING_SYSTEM_ORGANIZATION, + organization.getName()); + dto.setPath("/system/organization/update"); + dto.setMethod(HttpMethodConstants.POST.name()); + return dto; + } + return null; + } + + /** + * 更新组织 + * + * @param request 接口请求参数 + * @return 日志详情 + */ + public LogDTO updateLog(OrganizationEditRequest request) { + Organization organization = organizationMapper.selectByPrimaryKey(request.getId()); + if (organization != null) { + LogDTO dto = new LogDTO( + OperationLogConstants.SYSTEM, + OperationLogConstants.SYSTEM, + request.getId(), + null, + OperationLogType.UPDATE.name(), + OperationLogModule.SETTING_SYSTEM_ORGANIZATION, + organization.getName()); + dto.setPath("/system/organization/update"); + dto.setMethod(HttpMethodConstants.POST.name()); + // 新增的组织管理员ID + List newUserIds = request.getUserIds(); + UserExample example = new UserExample(); + example.createCriteria().andIdIn(newUserIds); + List newOrgUsers = userMapper.selectByExample(example); + // 旧的组织管理员ID + List oldUserIds = organizationService.getOrgAdminIds(request.getId()); + example.clear(); + example.createCriteria().andIdIn(oldUserIds); + List oldOrgUsers = userMapper.selectByExample(example); + dto.setOriginalValue(JSON.toJSONBytes(oldOrgUsers)); + dto.setModifiedValue(JSON.toJSONBytes(newOrgUsers)); + return dto; + } + return null; + } + + + /** + * 删除组织 + * + * @param id 接口请求参数 + * @return 日志详情 + */ + public LogDTO deleteLog(String id) { + Organization organization = organizationMapper.selectByPrimaryKey(id); + if (organization != null) { + LogDTO dto = new LogDTO( + OperationLogConstants.SYSTEM, + OperationLogConstants.SYSTEM, + id, + null, + OperationLogType.DELETE.name(), + OperationLogModule.SETTING_SYSTEM_ORGANIZATION, + organization.getName()); + dto.setPath("/system/organization/delete"); + dto.setMethod(HttpMethodConstants.GET.name()); + dto.setOriginalValue(JSON.toJSONBytes(organization)); + return dto; + } + return null; + } + + /** + * 恢复组织 + * + * @param id 接口请求参数 + * @return 日志详情 + */ + public LogDTO recoverLog(String id) { + Organization organization = organizationMapper.selectByPrimaryKey(id); + if (organization != null) { + LogDTO dto = new LogDTO( + OperationLogConstants.SYSTEM, + OperationLogConstants.SYSTEM, + id, + null, + OperationLogType.RECOVER.name(), + OperationLogModule.SETTING_SYSTEM_ORGANIZATION, + organization.getName()); + dto.setPath("/system/organization/recover"); + dto.setMethod(HttpMethodConstants.GET.name()); + dto.setOriginalValue(JSON.toJSONBytes(organization)); + return dto; + } + return null; + } +} diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemOrganizationControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemOrganizationControllerTests.java index 0cebef3d68..0bf30b6b62 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemOrganizationControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemOrganizationControllerTests.java @@ -7,9 +7,7 @@ import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.dto.OrganizationDTO; import io.metersphere.system.dto.ProjectDTO; -import io.metersphere.system.dto.request.OrganizationMemberRequest; -import io.metersphere.system.dto.request.OrganizationRequest; -import io.metersphere.system.dto.request.ProjectRequest; +import io.metersphere.system.dto.request.*; import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.utils.Pager; @@ -41,6 +39,12 @@ public class SystemOrganizationControllerTests extends BaseTest{ private MockMvc mockMvc; public static final String ORGANIZATION_LIST = "/system/organization/list"; + public static final String ORGANIZATION_UPDATE = "/system/organization/update"; + public static final String ORGANIZATION_RENAME = "/system/organization/rename"; + public static final String ORGANIZATION_DELETE = "/system/organization/delete"; + public static final String ORGANIZATION_RECOVER = "/system/organization/recover"; + public static final String ORGANIZATION_ENABLE = "/system/organization/enable"; + public static final String ORGANIZATION_DISABLE = "/system/organization/disable"; public static final String ORGANIZATION_LIST_OPTION_ALL = "/system/organization/option/all"; public static final String ORGANIZATION_DEFAULT = "/system/organization/default"; public static final String ORGANIZATION_LIST_MEMBER = "/system/organization/list-member"; @@ -132,6 +136,69 @@ public class SystemOrganizationControllerTests extends BaseTest{ @Test @Order(3) + public void testUpdateOrganizationSuccess() throws Exception { + OrganizationEditRequest request = new OrganizationEditRequest(); + request.setId("default-organization-5"); + request.setName("default-5"); + request.setUserIds(List.of("user-id1", "user-id2")); + this.requestPost(ORGANIZATION_UPDATE, request).andExpect(status().isOk()); + request.setUserIds(List.of("user-id1")); + this.requestPost(ORGANIZATION_UPDATE, request).andExpect(status().isOk()); + request.setUserIds(List.of()); + this.requestPost(ORGANIZATION_UPDATE, request).andExpect(status().isOk()); + this.requestPost(ORGANIZATION_UPDATE, request).andExpect(status().isOk()); + } + + @Test + @Order(4) + public void testUpdateOrganizationError() throws Exception { + OrganizationEditRequest request = new OrganizationEditRequest(); + request.setName("default-4"); + // 组织不存在 + request.setId("default-organization-x"); + this.requestPost(ORGANIZATION_UPDATE, request).andExpect(status().is5xxServerError()); + // 组织存在, 但是名称重复 + request.setId("default-organization-5"); + this.requestPost(ORGANIZATION_UPDATE, request).andExpect(status().is5xxServerError()); + } + + @Test + @Order(5) + public void testOrganizationRename() throws Exception { + OrganizationNameEditRequest request = new OrganizationNameEditRequest(); + request.setName("default-x"); + request.setId("default-organization-5"); + this.requestPost(ORGANIZATION_RENAME, request).andExpect(status().isOk()); + } + + @Test + @Order(6) + public void testDeleteOrganization() throws Exception { + this.requestGetWithOk(ORGANIZATION_DELETE + "/default-organization-5"); + // 删除默认组织 + this.requestGet(ORGANIZATION_DELETE + "/100001").andExpect(status().is5xxServerError()); + } + + @Test + @Order(7) + public void testRecoverOrganization() throws Exception { + this.requestGetWithOk(ORGANIZATION_RECOVER + "/default-organization-5"); + } + + @Test + @Order(8) + public void testDisableOrganization() throws Exception { + this.requestGetWithOk(ORGANIZATION_DISABLE + "/default-organization-5"); + } + + @Test + @Order(9) + public void testEnableOrganization() throws Exception { + this.requestGetWithOk(ORGANIZATION_ENABLE + "/default-organization-5"); + } + + @Test + @Order(10) public void testListAllOrganizationSuccess() throws Exception { MvcResult mvcResult = this.responsePost(ORGANIZATION_LIST_OPTION_ALL, null); // 获取返回值 @@ -144,13 +211,13 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(4) + @Order(11) public void testListAllOrganizationError() throws Exception { this.requestGet(ORGANIZATION_LIST_OPTION_ALL, status().isMethodNotAllowed()); } @Test - @Order(5) + @Order(12) public void testListOrganizationMemberSuccess() throws Exception { OrganizationRequest organizationRequest = new OrganizationRequest(); organizationRequest.setCurrent(1); @@ -193,7 +260,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(6) + @Order(13) public void testListOrganizationMemberError() throws Exception { // 页码有误 OrganizationRequest organizationRequest = new OrganizationRequest(); @@ -213,7 +280,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ @Test - @Order(7) + @Order(14) public void testAddOrganizationMemberSuccess() throws Exception { OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest(); organizationMemberRequest.setOrganizationId("default-organization-3"); @@ -251,7 +318,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(8) + @Order(15) public void testAddOrganizationMemberSuccessWithRepeatUser() throws Exception { OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest(); organizationMemberRequest.setOrganizationId("default-organization-3"); @@ -284,7 +351,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(9) + @Order(16) public void testAddOrganizationMemberError() throws Exception { // 成员选择为空 OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest(); @@ -309,7 +376,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(10) + @Order(17) public void testRemoveOrganizationMemberSuccess() throws Exception { this.requestGet(ORGANIZATION_REMOVE_MEMBER + "/default-organization-3/admin", status().isOk()); // 日志校验 @@ -319,14 +386,14 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(11) + @Order(17) public void testRemoveOrganizationMemberError() throws Exception { // 组织不存在 this.requestGet(ORGANIZATION_REMOVE_MEMBER + "/default-organization-x/admin-x", status().is5xxServerError()); } @Test - @Order(12) + @Order(19) public void testGetOrganizationProjectSuccess() throws Exception { ProjectRequest projectRequest = new ProjectRequest(); projectRequest.setCurrent(1); @@ -363,7 +430,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(13) + @Order(20) public void testGetOrganizationProjectError() throws Exception { // 页码有误 ProjectRequest projectRequest = new ProjectRequest(); @@ -380,7 +447,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(14) + @Order(21) public void testGetDefaultOrganizationSuccess() throws Exception { MvcResult mvcResult = this.responseGet(SystemOrganizationControllerTests.ORGANIZATION_DEFAULT); // 获取返回值 @@ -399,13 +466,13 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(15) + @Order(22) public void testGetDefaultOrganizationError() throws Exception { this.requestPost(ORGANIZATION_DEFAULT, null, status().isMethodNotAllowed()); } @Test - @Order(16) + @Order(23) public void testGetOrganizationMemberOption() throws Exception { MvcResult mvcResult = this.responseGet(SystemOrganizationControllerTests.ORGANIZATION_MEMBER_OPTION + "/default-organization-2"); // 获取返回值 @@ -419,7 +486,7 @@ public class SystemOrganizationControllerTests extends BaseTest{ } @Test - @Order(17) + @Order(24) public void testGetTotal() throws Exception { // 组织不存在 MvcResult mvcResult = this.responseGet(SystemOrganizationControllerTests.ORGANIZATION_TOTAL + "?organizationId=default-organization-2");