diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectController.java index 49541dffb6..9178408fd7 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectController.java @@ -9,12 +9,14 @@ import io.metersphere.system.dto.ProjectDTO; import io.metersphere.system.dto.UpdateProjectRequest; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.user.UserDTO; +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.security.CheckOwner; 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.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -75,4 +77,13 @@ public class ProjectController { return projectService.hasPermission(id, SessionUtils.getUserId()); } + @GetMapping("/get-member/option/{projectId}") + @Operation(summary = "项目管理-获取成员下拉选项") + @RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ) + public List getMemberOption(@PathVariable String projectId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") + @RequestParam(value = "keyword", required = false) String keyword) { + return projectService.getMemberOption(projectId, keyword); + } + } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java index 1031858a26..5cfb7702eb 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java @@ -21,9 +21,10 @@ import io.metersphere.system.dto.UpdateProjectRequest; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.sdk.SessionUser; import io.metersphere.system.dto.user.UserDTO; +import io.metersphere.system.dto.user.UserExtendDTO; +import io.metersphere.system.mapper.ExtSystemProjectMapper; import io.metersphere.system.mapper.OrganizationMapper; import io.metersphere.system.mapper.TestResourcePoolMapper; -import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper; import io.metersphere.system.mapper.UserRoleRelationMapper; import io.metersphere.system.service.CommonProjectService; import io.metersphere.system.service.UserLoginService; @@ -62,7 +63,7 @@ public class ProjectService { @Resource private ProjectTestResourcePoolMapper projectTestResourcePoolMapper; @Resource - private TestResourcePoolOrganizationMapper testResourcePoolOrganizationMapper; + private ExtSystemProjectMapper extSystemProjectMapper; public static final Long ORDER_STEP = 5000L; @@ -219,4 +220,13 @@ public class ProjectService { } return hasPermission; } + + public List getMemberOption(String projectId, String keyword) { + Project project = projectMapper.selectByPrimaryKey(projectId); + if (project == null) { + return new ArrayList<>(); + } + return extSystemProjectMapper.getMemberByProjectId(projectId, keyword); + } } + diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java index f91550af5d..d0ee64a2a3 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java @@ -436,4 +436,17 @@ public class ProjectControllerTests extends BaseTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); } + + @Test + @Order(12) + public void testGetProjectMember() throws Exception { + // 成员列表 + MvcResult mvcResult = this.responseGet(prefix + "/get-member/option/" + DEFAULT_PROJECT_ID); + List list = parseObjectFromMvcResult(mvcResult, List.class); + Assertions.assertNotNull(list); + + this.requestGet(prefix + "/get-member/option/" + "123"); + + requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, prefix + "/get-member/option/" + DEFAULT_PROJECT_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 5155fcace6..def8486c12 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 @@ -29,4 +29,6 @@ public interface ExtSystemProjectMapper { List getProjectResourcePoolDTOList(@Param("projectIds") List projectIds); String selectModuleSettingsByResourceIdAndTable(@Param("resourceId") String resourceId, @Param("resourceTable") String resourceTable); + + List getMemberByProjectId(@Param("projectId") String projectId, @Param("keyword") String keyword); } 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 2a9084dd97..abd187d8f1 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 @@ -196,4 +196,17 @@ + \ No newline at end of file