From f3e8fc208ba0cb98d79ae9d18ff32569d4cbcf98 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 25 Oct 2023 17:50:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{UserExtend.java => UserExtendDTO.java} | 2 +- .../controller/ProjectMemberController.java | 6 +- .../controller/ProjectUserRoleController.java | 14 +-- .../dto/environment/common/CommonParams.java | 4 +- .../dto/environment/script/ScriptContent.java | 17 ++-- .../mapper/ExtProjectMemberMapper.java | 4 +- .../project/mapper/ExtProjectMemberMapper.xml | 2 +- .../project/service/ProjectMemberService.java | 8 +- .../EnvironmentControllerTests.java | 18 ++-- .../OrganizationProjectController.java | 10 +-- .../OrganizationUserRoleController.java | 14 +-- .../SystemOrganizationController.java | 12 +-- .../controller/SystemProjectController.java | 4 +- .../io/metersphere/system/dto/ProjectDTO.java | 4 +- .../system/mapper/ExtOrganizationMapper.java | 4 +- .../system/mapper/ExtOrganizationMapper.xml | 2 +- .../system/mapper/ExtSystemProjectMapper.java | 12 +-- .../system/mapper/ExtSystemProjectMapper.xml | 8 +- .../system/mapper/ExtUserMapper.java | 4 +- .../system/mapper/ExtUserMapper.xml | 2 +- .../system/service/CommonProjectService.java | 86 ++++++++++--------- .../service/OrganizationProjectService.java | 8 +- .../system/service/OrganizationService.java | 4 +- .../system/service/SystemProjectService.java | 4 +- .../system/service/UserRoleService.java | 24 +++--- .../system/service/UserService.java | 3 +- .../OrganizationProjectControllerTests.java | 21 ++--- .../SystemOrganizationControllerTests.java | 32 +++---- .../SystemProjectControllerTests.java | 19 ++-- 29 files changed, 180 insertions(+), 172 deletions(-) rename backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/{UserExtend.java => UserExtendDTO.java} (93%) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/UserExtend.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/UserExtendDTO.java similarity index 93% rename from backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/UserExtend.java rename to backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/UserExtendDTO.java index 92286edeb2..d59e0d8863 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/UserExtend.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/UserExtendDTO.java @@ -12,7 +12,7 @@ import java.io.Serializable; */ @Data @EqualsAndHashCode(callSuper = false) -public class UserExtend extends User implements Serializable { +public class UserExtendDTO extends User implements Serializable { private static final long serialVersionUID = 1L; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java index e1707eb013..1a36b7b9ca 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java @@ -10,10 +10,10 @@ import io.metersphere.project.request.ProjectMemberRequest; import io.metersphere.project.service.ProjectMemberService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.OptionDTO; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.system.utils.SessionUtils; -import io.metersphere.sdk.dto.UserExtend; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -48,8 +48,8 @@ public class ProjectMemberController { @GetMapping("/get-member/option/{projectId}") @Operation(summary = "项目管理-成员-获取成员下拉选项") @RequiresPermissions(PermissionConstants.PROJECT_USER_READ) - public List getMemberOption(@PathVariable String projectId, - @Schema(description = "查询关键字,根据邮箱和用户名查询") + public List getMemberOption(@PathVariable String projectId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") @RequestParam(value = "keyword", required = false) String keyword) { return projectMemberService.getMemberOption(projectId, keyword); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectUserRoleController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectUserRoleController.java index f694977b30..38e9b379e5 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectUserRoleController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectUserRoleController.java @@ -11,17 +11,17 @@ import io.metersphere.project.service.ProjectUserRoleLogService; import io.metersphere.project.service.ProjectUserRoleService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.PermissionDefinitionItem; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest; -import io.metersphere.system.log.annotation.Log; -import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; -import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.domain.User; import io.metersphere.system.domain.UserRole; +import io.metersphere.system.log.annotation.Log; +import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.service.UserRoleService; +import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -106,9 +106,9 @@ public class ProjectUserRoleController { @Parameter(name = "projectId", description = "当前项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)), @Parameter(name = "roleId", description = "用户组ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) }) - public List getMember(@PathVariable String projectId, - @PathVariable String roleId, - @Schema(description = "查询关键字,根据邮箱和用户名查询") + public List getMember(@PathVariable String projectId, + @PathVariable String roleId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") @RequestParam(required = false) String keyword) { return userRoleService.getMember(projectId, roleId, keyword); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/common/CommonParams.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/common/CommonParams.java index 642a7238a5..bc3d23c1ae 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/common/CommonParams.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/common/CommonParams.java @@ -11,7 +11,7 @@ public class CommonParams implements Serializable { @Serial private static final long serialVersionUID = 1L; @Schema(description = "链接超时时间") - private Long requestTimeout; + private Long requestTimeout = 600000L; @Schema(description = "响应超时时间") - private Long responseTimeout; + private Long responseTimeout = 600000L; } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/script/ScriptContent.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/script/ScriptContent.java index a4683e1909..dbe375e1b9 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/script/ScriptContent.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/script/ScriptContent.java @@ -20,7 +20,7 @@ public class ScriptContent { @Data @EqualsAndHashCode(callSuper = true) - public static class ScenarioPostScript extends ScriptContent { + public static class ScenarioScript extends ScriptContent { @Schema(description = "关联场景结果 true: 是/false: 否") private Boolean associateScenarioResults = false; @@ -28,12 +28,11 @@ public class ScriptContent { @Data @EqualsAndHashCode(callSuper = true) - public static class StepPostScript extends ScriptContent { - + public static class StepScript extends ScriptContent { @Schema(description = "忽略请求") - private List filterRequestPostScript; + private List filterRequestScript; @Schema(description = "脚本执行顺序 true:先执行 false:后执行") - private Boolean preScriptExecBefore = true; + private Boolean scriptExecBefore = true; @Schema(description = "脚本内容") private ScriptContent scriptContent; @@ -42,10 +41,10 @@ public class ScriptContent { @Data public static class ApiScript { @Schema(description = "测试计划级") - private ScriptContent envJSR223PostScript; + private ScriptContent envJSR223Script; @Schema(description = "场景级") - private ScenarioPostScript scenarioJSR223PostScript; - @Schema(description = "步骤级") - private StepPostScript stepJSR223PostScript; + private ScenarioScript scenarioJSR223Script; + @Schema(description = "步骤级 ") + private List stepJSR223Script; } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.java b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.java index 181b63bbdb..92d86816a1 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.java @@ -1,7 +1,7 @@ package io.metersphere.project.mapper; import io.metersphere.project.request.ProjectMemberRequest; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -25,5 +25,5 @@ public interface ExtProjectMemberMapper { * @param keyword 搜索关键字 * @return 成员 */ - List getMemberByOrg(@Param("organizationId") String organizationId, @Param("keyword") String keyword); + List getMemberByOrg(@Param("organizationId") String organizationId, @Param("keyword") String keyword); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.xml b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.xml index 61a9b5d17a..d37cb963d7 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.xml +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectMemberMapper.xml @@ -17,7 +17,7 @@ order by u.name - select distinct u.* from user_role_relation urr join `user` u on urr.user_id = u.id where u.deleted = 0 diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java index c5d2e38f6f..506568144f 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java @@ -13,7 +13,7 @@ import io.metersphere.sdk.constants.UserRoleEnum; import io.metersphere.sdk.constants.UserRoleType; import io.metersphere.sdk.dto.LogDTO; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; @@ -109,18 +109,18 @@ public class ProjectMemberService { * @param projectId 项目ID * @return 项目成员下拉选项 */ - public List getMemberOption(String projectId, String keyword) { + public List getMemberOption(String projectId, String keyword) { Project project = projectMapper.selectByPrimaryKey(projectId); if (project == null) { return new ArrayList<>(); } // 组织成员 - List orgMembers = extProjectMemberMapper.getMemberByOrg(project.getOrganizationId(), keyword); + List orgMembers = extProjectMemberMapper.getMemberByOrg(project.getOrganizationId(), keyword); if (CollectionUtils.isEmpty(orgMembers)) { return new ArrayList<>(); } // 设置是否是项目成员 - List orgMemberIds = orgMembers.stream().map(UserExtend::getId).toList(); + List orgMemberIds = orgMembers.stream().map(UserExtendDTO::getId).toList(); UserRoleRelationExample example = new UserRoleRelationExample(); example.createCriteria().andUserIdIn(orgMemberIds).andSourceIdEqualTo(projectId).andOrganizationIdEqualTo(project.getOrganizationId()); List projectRelations = userRoleRelationMapper.selectByExample(example); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java index f23e69cdc2..c17f7d2eea 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java @@ -324,16 +324,16 @@ public class EnvironmentControllerTests extends BaseTest { ScriptContent.ApiScript apiScript = new ScriptContent.ApiScript(); ScriptContent scriptContent = new ScriptContent(); scriptContent.setScript("script"); - apiScript.setEnvJSR223PostScript(scriptContent); - ScriptContent.ScenarioPostScript scenarioPostScript = new ScriptContent.ScenarioPostScript(); - scenarioPostScript.setAssociateScenarioResults(true); - scenarioPostScript.setScript("scenarioPostScript"); - apiScript.setScenarioJSR223PostScript(scenarioPostScript); - ScriptContent.StepPostScript stepPostScript = new ScriptContent.StepPostScript(); - stepPostScript.setPreScriptExecBefore(true); + apiScript.setEnvJSR223Script(scriptContent); + ScriptContent.ScenarioScript scenarioScript = new ScriptContent.ScenarioScript(); + scenarioScript.setAssociateScenarioResults(true); + scenarioScript.setScript("scenarioPostScript"); + apiScript.setScenarioJSR223Script(scenarioScript); + ScriptContent.StepScript stepPostScript = new ScriptContent.StepScript(); + stepPostScript.setScriptExecBefore(true); stepPostScript.setScriptContent(scriptContent); - stepPostScript.setFilterRequestPostScript(new ArrayList<>()); - apiScript.setStepJSR223PostScript(stepPostScript); + stepPostScript.setFilterRequestScript(new ArrayList<>()); + apiScript.setStepJSR223Script(List.of(stepPostScript)); return apiScript; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java index 292e546a31..c6a501d888 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java @@ -5,7 +5,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.system.dto.AddProjectRequest; @@ -116,7 +116,7 @@ public class OrganizationProjectController { @PostMapping("/member-list") @RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ) @Operation(summary = "系统设置-组织-项目-成员列表") - public Pager> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) { + public Pager> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); return PageUtils.setPageInfo(page, organizationProjectService.getProjectMember(request)); @@ -145,7 +145,7 @@ public class OrganizationProjectController { @GetMapping("/user-admin-list/{organizationId}") @Operation(summary = "系统设置-组织-项目-获取管理员列表") @RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ) - public List getUserAdminList(@PathVariable String organizationId, @Schema(description = "查询关键字,根据邮箱和用户名查询") + public List getUserAdminList(@PathVariable String organizationId, @Schema(description = "查询关键字,根据邮箱和用户名查询") @RequestParam(value = "keyword", required = false) String keyword) { return organizationProjectService.getUserAdminList(organizationId, keyword); } @@ -153,8 +153,8 @@ public class OrganizationProjectController { @GetMapping("/user-member-list/{organizationId}/{projectId}") @Operation(summary = "系统设置-组织-项目-获取成员列表") @RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ) - public List getUserMemberList(@PathVariable String organizationId, @PathVariable String projectId, - @Schema(description = "查询关键字,根据邮箱和用户名查询") + public List getUserMemberList(@PathVariable String organizationId, @PathVariable String projectId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") @RequestParam(value = "keyword", required = false) String keyword) { return organizationProjectService.getUserMemberList(organizationId, projectId, keyword); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationUserRoleController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationUserRoleController.java index 69ae3a0d60..05d7803ece 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationUserRoleController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationUserRoleController.java @@ -4,22 +4,22 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.PermissionDefinitionItem; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest; -import io.metersphere.system.log.annotation.Log; -import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; -import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.domain.User; import io.metersphere.system.domain.UserRole; +import io.metersphere.system.log.annotation.Log; +import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.request.OrganizationUserRoleEditRequest; import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest; import io.metersphere.system.request.OrganizationUserRoleMemberRequest; import io.metersphere.system.service.OrganizationUserRoleLogService; import io.metersphere.system.service.OrganizationUserRoleService; import io.metersphere.system.service.UserRoleService; +import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -106,9 +106,9 @@ public class OrganizationUserRoleController { @Parameter(name = "organizationId", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)), @Parameter(name = "roleId", description = "用户组ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) }) - public List getMember(@PathVariable String organizationId, - @PathVariable String roleId, - @Schema(description = "查询关键字,根据邮箱和用户名查询") + public List getMember(@PathVariable String organizationId, + @PathVariable String roleId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") @RequestParam(required = false) String keyword) { return userRoleService.getMember(organizationId, roleId, keyword); } 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 90005d3ee3..4a694ec1f5 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 @@ -4,13 +4,12 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.system.dto.ProjectDTO; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; -import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.dto.OrganizationDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.system.dto.ProjectDTO; import io.metersphere.system.request.OrganizationMemberRequest; import io.metersphere.system.request.OrganizationProjectRequest; import io.metersphere.system.request.OrganizationRequest; @@ -18,6 +17,7 @@ import io.metersphere.system.request.ProjectRequest; import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.UserService; +import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -66,7 +66,7 @@ public class SystemOrganizationController { @PostMapping("/list-member") @Operation(summary = "系统设置-系统-组织与项目-组织-获取组织成员列表") @RequiresPermissions(value = {PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, PermissionConstants.SYSTEM_USER_READ}) - public Pager> listMember(@Validated @RequestBody OrganizationRequest request) { + public Pager> listMember(@Validated @RequestBody OrganizationRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), true); return PageUtils.setPageInfo(page, organizationService.getMemberListBySystem(request)); } @@ -118,8 +118,8 @@ public class SystemOrganizationController { @Operation(summary = "系统设置-系统-组织与项目-获取成员下拉选项") @RequiresPermissions(value = {PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ}) @Parameter(name = "sourceId", description = "组织ID或项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) - public List getMemberOption(@PathVariable String sourceId, - @Schema(description = "查询关键字,根据邮箱和用户名查询") + public List getMemberOption(@PathVariable String sourceId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") @RequestParam(value = "keyword", required = false) String keyword) { return userService.getMemberOption(sourceId, keyword); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java index 6061ab9442..97a41c9419 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java @@ -5,7 +5,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.system.domain.User; @@ -120,7 +120,7 @@ public class SystemProjectController { @PostMapping("/member-list") @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ) @Operation(summary = "系统设置-系统-组织与项目-项目-成员列表") - public Pager> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) { + public Pager> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); return PageUtils.setPageInfo(page, systemProjectService.getProjectMember(request)); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/ProjectDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/ProjectDTO.java index 0e86df9324..c3c52184a1 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/ProjectDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/ProjectDTO.java @@ -1,7 +1,7 @@ package io.metersphere.system.dto; import io.metersphere.project.domain.Project; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -17,7 +17,7 @@ public class ProjectDTO extends Project implements Serializable { @Schema(description = "所属组织", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String organizationName; @Schema(description = "管理员", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - private List adminList; + private List adminList; @Schema(description = "创建人是否是管理员", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Boolean projectCreateUserIsAdmin; @Schema(description = "模块设置", requiredMode = Schema.RequiredMode.NOT_REQUIRED) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java index bf1a41288c..1e0c06754a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java @@ -1,7 +1,7 @@ package io.metersphere.system.mapper; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.system.domain.User; import io.metersphere.system.dto.*; import io.metersphere.system.request.OrganizationDeleteRequest; @@ -66,7 +66,7 @@ public interface ExtOrganizationMapper { * @param request 组织成员列表请求参数 * @return 组织成员列表数据 */ - List listMember(@Param("request") OrganizationRequest request); + List listMember(@Param("request") OrganizationRequest request); /** diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml index 452b8e7656..b086ea648f 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml @@ -56,7 +56,7 @@ where id = #{id} - select temp.*, max(if(temp.role_id = 'org_admin', true, false)) as adminFlag from ( select u.*, urr.role_id diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java index 703f590c66..bca40fa9a5 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java @@ -1,9 +1,9 @@ package io.metersphere.system.mapper; +import io.metersphere.sdk.dto.UserExtendDTO; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.ProjectDTO; import io.metersphere.system.dto.ProjectResourcePoolDTO; -import io.metersphere.sdk.dto.UserExtend; -import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.request.ProjectMemberRequest; import io.metersphere.system.request.ProjectRequest; import org.apache.ibatis.annotations.Param; @@ -12,17 +12,17 @@ import java.util.List; public interface ExtSystemProjectMapper { - List getProjectMemberList(@Param("request") ProjectMemberRequest request); + List getProjectMemberList(@Param("request") ProjectMemberRequest request); List getProjectList(@Param("request") ProjectRequest request); - List getProjectAdminList(@Param("projectIds") List projectIds); + List getProjectAdminList(@Param("projectIds") List projectIds); List selectProjectOptions(@Param("organizationId") String organizationId); - List getUserAdminList(@Param("organizationId") String organizationId, @Param("keyword") String keyword); + List getUserAdminList(@Param("organizationId") String organizationId, @Param("keyword") String keyword); - List getUserMemberList(@Param("userIds") List userIds, @Param("projectId") String projectId, @Param("keyword") String keyword); + List getUserMemberList(@Param("userIds") List userIds, @Param("projectId") String projectId, @Param("keyword") String keyword); List getProjectExtendDTOList(@Param("projectIds") List projectIds); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml index 0a76e17120..9cc2f0752a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml @@ -3,7 +3,7 @@ - SELECT temp.* , MAX( if (temp.role_id = 'project_admin', true, false)) as adminFlag FROM ( SELECT `user`.* , user_role_relation.role_id @@ -42,7 +42,7 @@ INNER JOIN organization o on p.organization_id = o.id - SELECT `user`.*, user_role_relation.source_id FROM user_role_relation LEFT JOIN `user` ON user_role_relation.user_id = `user`.id @@ -114,7 +114,7 @@ - select distinct u.id, u.NAME, @@ -129,7 +129,7 @@ - select distinct u.id, u.NAME, u.email, count(temp.id) > 0 as memberFlag from diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java index dad6196575..75ac1116c3 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java @@ -1,6 +1,6 @@ package io.metersphere.system.mapper; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.system.domain.User; import org.apache.ibatis.annotations.Param; @@ -8,7 +8,7 @@ import java.util.List; public interface ExtUserMapper { - List getMemberOption(@Param("sourceId") String sourceId, @Param("keyword") String keyword); + List getMemberOption(@Param("sourceId") String sourceId, @Param("keyword") String keyword); List getUserListByOrgId(@Param("sourceId") String sourceId, @Param("keyword") String keyword); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml index c05a7f5ac5..fe896bf4ea 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml @@ -1,7 +1,7 @@ - select distinct u.*, count(urr.id) > 0 as memberFlag from `user` u left join user_role_relation urr on urr.user_id = u.id and urr.source_id = #{sourceId} where u.deleted = 0 diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java index f13f3d3e7f..b3661395bb 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java @@ -12,7 +12,7 @@ import io.metersphere.sdk.constants.OperationLogConstants; import io.metersphere.sdk.constants.UserRoleType; import io.metersphere.sdk.dto.LogDTO; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; @@ -210,49 +210,51 @@ public class CommonProjectService { public List buildUserInfo(List projectList) { //取项目的创建人 修改人 删除人到一个list中 List userIds = new ArrayList<>(); - userIds.addAll(projectList.stream().map(ProjectDTO::getCreateUser).toList()); - userIds.addAll(projectList.stream().map(ProjectDTO::getUpdateUser).toList()); - userIds.addAll(projectList.stream().map(ProjectDTO::getDeleteUser).toList()); - Map userMap = userLoginService.getUserNameMap(userIds.stream().filter(StringUtils::isNotBlank).distinct().toList()); - // 获取项目id - List projectIds = projectList.stream().map(ProjectDTO::getId).toList(); - List users = extSystemProjectMapper.getProjectAdminList(projectIds); - List projectDTOList = extSystemProjectMapper.getProjectExtendDTOList(projectIds); - Map projectMap = projectDTOList.stream().collect(Collectors.toMap(ProjectDTO::getId, projectDTO -> projectDTO)); - //根据sourceId分组 - Map> userMapList = users.stream().collect(Collectors.groupingBy(UserExtend::getSourceId)); - //获取资源池 - List projectResourcePoolDTOList = extSystemProjectMapper.getProjectResourcePoolDTOList(projectIds); - //根据projectId分组 key为项目id 值为资源池TestResourcePool - Map> poolMap = projectResourcePoolDTOList.stream().collect(Collectors.groupingBy(ProjectResourcePoolDTO::getProjectId)); + if (CollectionUtils.isNotEmpty(projectList)) { + userIds.addAll(projectList.stream().map(ProjectDTO::getCreateUser).toList()); + userIds.addAll(projectList.stream().map(ProjectDTO::getUpdateUser).toList()); + userIds.addAll(projectList.stream().map(ProjectDTO::getDeleteUser).toList()); + Map userMap = userLoginService.getUserNameMap(userIds.stream().filter(StringUtils::isNotBlank).distinct().toList()); + // 获取项目id + List projectIds = projectList.stream().map(ProjectDTO::getId).toList(); + List users = extSystemProjectMapper.getProjectAdminList(projectIds); + List projectDTOList = extSystemProjectMapper.getProjectExtendDTOList(projectIds); + Map projectMap = projectDTOList.stream().collect(Collectors.toMap(ProjectDTO::getId, projectDTO -> projectDTO)); + //根据sourceId分组 + Map> userMapList = users.stream().collect(Collectors.groupingBy(UserExtendDTO::getSourceId)); + //获取资源池 + List projectResourcePoolDTOList = extSystemProjectMapper.getProjectResourcePoolDTOList(projectIds); + //根据projectId分组 key为项目id 值为资源池TestResourcePool + Map> poolMap = projectResourcePoolDTOList.stream().collect(Collectors.groupingBy(ProjectResourcePoolDTO::getProjectId)); - projectList.forEach(projectDTO -> { - if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) { - projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class)); - } - projectDTO.setMemberCount(projectMap.get(projectDTO.getId()).getMemberCount()); - List userExtends = userMapList.get(projectDTO.getId()); - if (CollectionUtils.isNotEmpty(userExtends)) { - projectDTO.setAdminList(userExtends); - List userIdList = userExtends.stream().map(User::getId).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(userIdList) && userIdList.contains(projectDTO.getCreateUser())) { - projectDTO.setProjectCreateUserIsAdmin(true); - } else { - projectDTO.setProjectCreateUserIsAdmin(false); + projectList.forEach(projectDTO -> { + if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) { + projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class)); } - } else { - projectDTO.setAdminList(new ArrayList<>()); - } - List projectResourcePoolDTOS = poolMap.get(projectDTO.getId()); - if (CollectionUtils.isNotEmpty(projectResourcePoolDTOS)) { - projectDTO.setResourcePoolList(projectResourcePoolDTOS); - } else { - projectDTO.setResourcePoolList(new ArrayList<>()); - } - projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser())); - projectDTO.setUpdateUser(userMap.get(projectDTO.getUpdateUser())); - projectDTO.setDeleteUser(userMap.get(projectDTO.getDeleteUser())); - }); + projectDTO.setMemberCount(projectMap.get(projectDTO.getId()).getMemberCount()); + List userExtendDTOS = userMapList.get(projectDTO.getId()); + if (CollectionUtils.isNotEmpty(userExtendDTOS)) { + projectDTO.setAdminList(userExtendDTOS); + List userIdList = userExtendDTOS.stream().map(User::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(userIdList) && userIdList.contains(projectDTO.getCreateUser())) { + projectDTO.setProjectCreateUserIsAdmin(true); + } else { + projectDTO.setProjectCreateUserIsAdmin(false); + } + } else { + projectDTO.setAdminList(new ArrayList<>()); + } + List projectResourcePoolDTOS = poolMap.get(projectDTO.getId()); + if (CollectionUtils.isNotEmpty(projectResourcePoolDTOS)) { + projectDTO.setResourcePoolList(projectResourcePoolDTOS); + } else { + projectDTO.setResourcePoolList(new ArrayList<>()); + } + projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser())); + projectDTO.setUpdateUser(userMap.get(projectDTO.getUpdateUser())); + projectDTO.setDeleteUser(userMap.get(projectDTO.getDeleteUser())); + }); + } return projectList; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationProjectService.java index 4efc575b50..edf3bfaa72 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationProjectService.java @@ -1,7 +1,7 @@ package io.metersphere.system.service; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.Translator; @@ -76,7 +76,7 @@ public class OrganizationProjectService { return commonProjectService.delete(id, deleteUser); } - public List getProjectMember(ProjectMemberRequest request) { + public List getProjectMember(ProjectMemberRequest request) { return extSystemProjectMapper.getProjectMemberList(request); } @@ -106,12 +106,12 @@ public class OrganizationProjectService { commonProjectService.disable(id, updateUser); } - public List getUserAdminList(String organizationId, String keyword) { + public List getUserAdminList(String organizationId, String keyword) { checkOrgIsExist(organizationId); return extSystemProjectMapper.getUserAdminList(organizationId, keyword); } - public List getUserMemberList(String organizationId, String projectId, String keyword) { + public List getUserMemberList(String organizationId, String projectId, String keyword) { checkOrgIsExist(organizationId); commonProjectService.checkProjectNotExist(projectId); UserRoleRelationExample example = new UserRoleRelationExample(); 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 5197a6fb6c..bad0b08988 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 @@ -6,7 +6,7 @@ import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.*; import io.metersphere.sdk.dto.LogDTO; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.CommonBeanFactory; @@ -108,7 +108,7 @@ public class OrganizationService { * @param request 请求参数 * @return 组织成员集合 */ - public List getMemberListBySystem(OrganizationRequest request) { + public List getMemberListBySystem(OrganizationRequest request) { return extOrganizationMapper.listMember(request); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java index 36ed460143..1c4bfcc85b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java @@ -2,7 +2,7 @@ package io.metersphere.system.service; import io.metersphere.project.domain.Project; import io.metersphere.sdk.dto.OptionDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.*; import io.metersphere.system.log.constants.OperationLogModule; @@ -58,7 +58,7 @@ public class SystemProjectService { return commonProjectService.delete(id, deleteUser); } - public List getProjectMember(ProjectMemberRequest request) { + public List getProjectMember(ProjectMemberRequest request) { return extSystemProjectMapper.getProjectMemberList(request); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleService.java index 8729634680..3de22888cf 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleService.java @@ -1,6 +1,6 @@ package io.metersphere.system.service; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.system.domain.*; import io.metersphere.system.mapper.ExtUserMapper; @@ -39,8 +39,8 @@ public class UserRoleService { } } - public List getMember(String sourceId, String roleId, String keyword) { - List userExtends = new ArrayList<>(); + public List getMember(String sourceId, String roleId, String keyword) { + List userExtendDTOS = new ArrayList<>(); // 查询组织或项目下所有用户关系 UserRoleRelationExample example = new UserRoleRelationExample(); example.createCriteria().andSourceIdEqualTo(sourceId); @@ -49,22 +49,22 @@ public class UserRoleService { Map> userRoleMap = userRoleRelations.stream().collect(Collectors.groupingBy(UserRoleRelation::getUserId, Collectors.mapping(UserRoleRelation::getRoleId, Collectors.toList()))); userRoleMap.forEach((k, v) -> { - UserExtend userExtend = new UserExtend(); - userExtend.setId(k); + UserExtendDTO userExtendDTO = new UserExtendDTO(); + userExtendDTO.setId(k); v.forEach(roleItem -> { if (StringUtils.equals(roleItem, roleId)) { // 该用户已存在用户组关系, 设置为选中状态 - userExtend.setCheckRoleFlag(true); + userExtendDTO.setCheckRoleFlag(true); } }); - userExtends.add(userExtend); + userExtendDTOS.add(userExtendDTO); }); // 设置用户信息, 用户不存在或者已删除, 则不展示 - List userIds = userExtends.stream().map(UserExtend::getId).toList(); + List userIds = userExtendDTOS.stream().map(UserExtendDTO::getId).toList(); List users = extUserMapper.getRoleUserByParam(userIds, keyword); if (CollectionUtils.isNotEmpty(users)) { Map userMap = users.stream().collect(Collectors.toMap(User::getId, user -> user)); - userExtends.removeIf(userExtend -> { + userExtendDTOS.removeIf(userExtend -> { if (userMap.containsKey(userExtend.getId())) { BeanUtils.copyBean(userExtend, userMap.get(userExtend.getId())); return false; @@ -72,11 +72,11 @@ public class UserRoleService { return true; }); } else { - userExtends.clear(); + userExtendDTOS.clear(); } } - userExtends.sort(Comparator.comparing(UserExtend::getName)); - return userExtends; + userExtendDTOS.sort(Comparator.comparing(UserExtendDTO::getName)); + return userExtendDTOS; } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java index 8a0fef9a46..97fbe9e9a2 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java @@ -3,7 +3,6 @@ package io.metersphere.system.service; import com.alibaba.excel.EasyExcelFactory; import io.metersphere.sdk.constants.ParamConstants; import io.metersphere.sdk.constants.UserSource; -import io.metersphere.sdk.dto.UserExtend; import io.metersphere.sdk.dto.*; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.*; @@ -330,7 +329,7 @@ public class UserService { * @param sourceId 组织ID, 项目ID * @return 系统用户选项 */ - public List getMemberOption(String sourceId, String keyword) { + public List getMemberOption(String sourceId, String keyword) { return extUserMapper.getMemberOption(sourceId, keyword); } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java index 7b43a291bc..9da53c67cb 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java @@ -6,19 +6,20 @@ import io.metersphere.project.domain.ProjectTestResourcePool; import io.metersphere.project.domain.ProjectTestResourcePoolExample; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.project.mapper.ProjectTestResourcePoolMapper; -import io.metersphere.system.base.BaseTest; import io.metersphere.sdk.constants.InternalUserRole; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.SessionConstants; -import io.metersphere.system.controller.handler.ResultHolder; -import io.metersphere.sdk.dto.*; -import io.metersphere.system.dto.*; -import io.metersphere.system.log.constants.OperationLogType; +import io.metersphere.sdk.dto.UserDTO; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Pager; +import io.metersphere.system.base.BaseTest; +import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.domain.User; import io.metersphere.system.domain.UserRoleRelation; import io.metersphere.system.domain.UserRoleRelationExample; +import io.metersphere.system.dto.*; +import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserRoleRelationMapper; import io.metersphere.system.request.OrganizationProjectRequest; @@ -667,7 +668,7 @@ public class OrganizationProjectControllerTests extends BaseTest { //返回值的页码和当前页码相同 Assertions.assertEquals(returnPager.getCurrent(), memberRequest.getCurrent()); //返回的数据量不超过规定要返回的数据量相同 - Assertions.assertTrue(((List) returnPager.getList()).size() <= memberRequest.getPageSize()); + Assertions.assertTrue(((List) returnPager.getList()).size() <= memberRequest.getPageSize()); UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample(); userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId); List userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample); @@ -682,10 +683,10 @@ public class OrganizationProjectControllerTests extends BaseTest { returnPager = parseObjectFromMvcResult(mvcResult, Pager.class); //第一个数据的createTime是最大的 assert returnPager != null; - List userExtends = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtend.class); - long firstCreateTime = userExtends.get(0).getCreateTime(); - for (UserExtend userExtend : userExtends) { - Assertions.assertFalse(userExtend.getCreateTime() > firstCreateTime); + List userExtendDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtendDTO.class); + long firstCreateTime = userExtendDTOS.get(0).getCreateTime(); + for (UserExtendDTO userExtendDTO : userExtendDTOS) { + Assertions.assertFalse(userExtendDTO.getCreateTime() > firstCreateTime); } // @@校验权限 requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getProjectMemberList, memberRequest); 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 c8d5299e14..58ed60f09e 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 @@ -2,13 +2,13 @@ package io.metersphere.system.controller; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.SessionConstants; -import io.metersphere.system.dto.ProjectDTO; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Pager; 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.log.constants.OperationLogType; import io.metersphere.system.request.OrganizationMemberRequest; import io.metersphere.system.request.OrganizationRequest; @@ -171,10 +171,10 @@ public class SystemOrganizationControllerTests extends BaseTest{ // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize()); // 返回值中取出第一条数据, 并判断是否包含关键字admin - UserExtend userExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtend.class).get(0); - Assertions.assertTrue(StringUtils.contains(userExtend.getName(), organizationRequest.getKeyword()) - || StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword()) - || StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword())); + UserExtendDTO userExtendDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtendDTO.class).get(0); + Assertions.assertTrue(StringUtils.contains(userExtendDTO.getName(), organizationRequest.getKeyword()) + || StringUtils.contains(userExtendDTO.getEmail(), organizationRequest.getKeyword()) + || StringUtils.contains(userExtendDTO.getPhone(), organizationRequest.getKeyword())); // sort不为空 Map sort = new HashMap<>(); @@ -185,8 +185,8 @@ public class SystemOrganizationControllerTests extends BaseTest{ ResultHolder sortHolder = JSON.parseObject(sortData, ResultHolder.class); Pager sortPageData = JSON.parseObject(JSON.toJSONString(sortHolder.getData()), Pager.class); // 返回值中取出第一条ID最大的数据, 并判断是否是admin - UserExtend userExtend1 = JSON.parseArray(JSON.toJSONString(sortPageData.getList()), UserExtend.class).get(0); - Assertions.assertTrue(StringUtils.contains(userExtend1.getId(), "admin")); + UserExtendDTO userExtendDTO1 = JSON.parseArray(JSON.toJSONString(sortPageData.getList()), UserExtendDTO.class).get(0); + Assertions.assertTrue(StringUtils.contains(userExtendDTO1.getId(), "admin")); // 权限校验 requestPostPermissionsTest(List.of(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, PermissionConstants.SYSTEM_USER_READ), ORGANIZATION_LIST_MEMBER, organizationRequest); @@ -241,10 +241,10 @@ public class SystemOrganizationControllerTests extends BaseTest{ // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize()); // 返回值中取出第一条数据, 并判断是否包含关键字admin - UserExtend userExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtend.class).get(0); - Assertions.assertTrue(StringUtils.contains(userExtend.getName(), organizationRequest.getKeyword()) - || StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword()) - || StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword())); + UserExtendDTO userExtendDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtendDTO.class).get(0); + Assertions.assertTrue(StringUtils.contains(userExtendDTO.getName(), organizationRequest.getKeyword()) + || StringUtils.contains(userExtendDTO.getEmail(), organizationRequest.getKeyword()) + || StringUtils.contains(userExtendDTO.getPhone(), organizationRequest.getKeyword())); // 权限校验 organizationMemberRequest.setUserIds(List.of("admin")); requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD, ORGANIZATION_ADD_MEMBER, organizationMemberRequest); @@ -277,10 +277,10 @@ public class SystemOrganizationControllerTests extends BaseTest{ // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize()); // 返回值中取出第一条数据, 并判断是否包含关键字admin - UserExtend userExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtend.class).get(0); - Assertions.assertTrue(StringUtils.contains(userExtend.getName(), organizationRequest.getKeyword()) - || StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword()) - || StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword())); + UserExtendDTO userExtendDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtendDTO.class).get(0); + Assertions.assertTrue(StringUtils.contains(userExtendDTO.getName(), organizationRequest.getKeyword()) + || StringUtils.contains(userExtendDTO.getEmail(), organizationRequest.getKeyword()) + || StringUtils.contains(userExtendDTO.getPhone(), organizationRequest.getKeyword())); } @Test diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java index d3b696f85f..be03658854 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java @@ -7,7 +7,7 @@ import io.metersphere.project.domain.ProjectTestResourcePoolExample; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.project.mapper.ProjectTestResourcePoolMapper; import io.metersphere.sdk.constants.*; -import io.metersphere.sdk.dto.UserExtend; +import io.metersphere.sdk.dto.UserExtendDTO; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Pager; @@ -563,6 +563,13 @@ public class SystemProjectControllerTests extends BaseTest { Assertions.assertFalse(projectDTO.getOrganizationName().compareTo(firstOrganizationName) > 0); } + //查询不存在的组织id + projectRequest.setOrganizationId("111111"); + mvcResult = this.responsePost(getProjectList, projectRequest); + returnPager = parseObjectFromMvcResult(mvcResult, Pager.class); + //返回值不为空 + Assertions.assertNotNull(returnPager); + //返回值为 // @@校验权限 requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProjectList, projectRequest); @@ -786,17 +793,17 @@ public class SystemProjectControllerTests extends BaseTest { //返回值的页码和当前页码相同 Assertions.assertEquals(returnPager.getCurrent(), memberRequest.getCurrent()); //返回的数据量不超过规定要返回的数据量相同 - Assertions.assertTrue(((List) returnPager.getList()).size() <= memberRequest.getPageSize()); + Assertions.assertTrue(((List) returnPager.getList()).size() <= memberRequest.getPageSize()); memberRequest.setSort(new HashMap<>() {{ put("createTime", "desc"); }}); mvcResult = this.responsePost(getProjectMemberList, memberRequest); returnPager = parseObjectFromMvcResult(mvcResult, Pager.class); //第一个数据的createTime是最大的 - List userExtends = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtend.class); - long firstCreateTime = userExtends.get(0).getCreateTime(); - for (UserExtend userExtend : userExtends) { - Assertions.assertFalse(userExtend.getCreateTime() > firstCreateTime); + List userExtendDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtendDTO.class); + long firstCreateTime = userExtendDTOS.get(0).getCreateTime(); + for (UserExtendDTO userExtendDTO : userExtendDTOS) { + Assertions.assertFalse(userExtendDTO.getCreateTime() > firstCreateTime); } // @@校验权限 requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProjectMemberList, memberRequest);