diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/DashboardController.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/DashboardController.java index e0b39a1393..49fcd6b94d 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/DashboardController.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/DashboardController.java @@ -17,11 +17,13 @@ import io.metersphere.project.service.PermissionCheckService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.exception.MSException; import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO; +import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.security.CheckOwner; import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; 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.springframework.validation.annotation.Validated; @@ -48,7 +50,7 @@ public class DashboardController { @PostMapping("/layout/edit/{organizationId}") @Operation(summary = "编辑用户布局") @CheckOwner(resourceId = "#organizationId", resourceType = "organization") - public List editLayout(@PathVariable String organizationId, @Validated @RequestBody List layoutDTO) { + public List editLayout(@PathVariable String organizationId, @RequestBody List layoutDTO ) { return dashboardService.editLayout(organizationId, SessionUtils.getUserId(), layoutDTO); } @@ -94,6 +96,15 @@ public class DashboardController { return dashboardService.getBugHandleUserList(projectId); } + @GetMapping("/member/get-project-member/option/{projectId}") + @Operation(summary = "获取项目成员列表") + @CheckOwner(resourceId = "#projectId", resourceType = "project") + public List getMemberOption(@PathVariable String projectId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") + @RequestParam(value = "keyword", required = false) String keyword) { + return dashboardService.getMemberOption(projectId, keyword); + } + @PostMapping("/case_count") @Operation(summary = "用例数") @CheckOwner(resourceId = "#request.getOrganizationId()", resourceType = "organization") diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/dto/LayoutDTO.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/dto/LayoutDTO.java index 9f6bd7bf35..c42b555e57 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/dto/LayoutDTO.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/dto/LayoutDTO.java @@ -5,12 +5,17 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serial; +import java.io.Serializable; import java.util.List; @Data @AllArgsConstructor @NoArgsConstructor -public class LayoutDTO { +public class LayoutDTO implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + @Schema(description = "布局卡片id") private String id; @Schema(description = "布局卡片key") diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java index b1da80fc65..d7c6557e55 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java @@ -59,7 +59,9 @@ import io.metersphere.system.domain.UserLayoutExample; import io.metersphere.system.dto.ProtocolDTO; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.user.ProjectUserMemberDTO; +import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.mapper.ExtExecTaskItemMapper; +import io.metersphere.system.mapper.ExtSystemProjectMapper; import io.metersphere.system.mapper.UserLayoutMapper; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.utils.PageUtils; @@ -127,6 +129,8 @@ public class DashboardService { private CaseReviewService caseReviewService; @Resource private ApiTestService apiTestService; + @Resource + private ExtSystemProjectMapper extSystemProjectMapper; public static final String FUNCTIONAL = "FUNCTIONAL"; // 功能用例 @@ -366,10 +370,10 @@ public class DashboardService { } public List getLayout(String organizationId, String userId) { + List allPermissionProjects = projectService.getUserProject(organizationId, userId); UserLayoutExample userLayoutExample = new UserLayoutExample(); userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId); List userLayouts = userLayoutMapper.selectByExampleWithBLOBs(userLayoutExample); - ListallPermissionProjects = extProjectMapper.getProjectNameModule(organizationId, null); if (CollectionUtils.isEmpty(allPermissionProjects)) { return new ArrayList<>(); } @@ -379,6 +383,9 @@ public class DashboardService { UserLayout userLayout = userLayouts.getFirst(); byte[] configuration = userLayout.getConfiguration(); String layoutDTOStr = new String(configuration); + if (StringUtils.isBlank(layoutDTOStr)) { + return new ArrayList<>(); + } List layoutDTOS = JSON.parseArray(layoutDTOStr, LayoutDTO.class); Map> permissionModuleProjectIdMap = dashboardProjectService.getPermissionModuleProjectIds(allPermissionProjects, userId); List orgProjectMemberList = extProjectMemberMapper.getOrgProjectMemberList(organizationId, null); @@ -1399,6 +1406,14 @@ public class DashboardService { statisticsDTO.setStatusPercentList(statusPercentList); return statisticsDTO; } + + 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/dashboard/src/test/java/io/metersphere/dashboard/controller/DashboardFrontPageControllerTests.java b/backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/DashboardFrontPageControllerTests.java index 07e26d074c..f9e53000b3 100644 --- a/backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/DashboardFrontPageControllerTests.java +++ b/backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/DashboardFrontPageControllerTests.java @@ -27,6 +27,7 @@ import io.metersphere.sdk.util.JSON; import io.metersphere.system.base.BasePluginTestService; import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; +import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.utils.Pager; import jakarta.annotation.Resource; import org.junit.jupiter.api.*; @@ -101,6 +102,8 @@ public class DashboardFrontPageControllerTests extends BaseTest { private static final String API_CHANGE = "/dashboard/api_change"; private static final String BUG_HANDLE_USER_LIST = "/dashboard/bug_handle_user/list/"; + private static final String PROJECT_MEMBER_USER_LIST = "/dashboard/member/get-project-member/option/"; + @Test @Order(1) @Sql(scripts = {"/dml/init_dashboard.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) @@ -202,11 +205,7 @@ public class DashboardFrontPageControllerTests extends BaseTest { @Test @Order(2) public void testLayout() throws Exception { - MvcResult mvcResultGrt = this.requestGetWithOkAndReturn(GET_LAYOUT + "DEFAULT_ORGANIZATION_ID"); - String contentAsString = mvcResultGrt.getResponse().getContentAsString(StandardCharsets.UTF_8); - ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); - List layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class); - Assertions.assertEquals(0, layoutDTOS.size()); + this.requestGet(GET_LAYOUT + "DEFAULT_ORGANIZATION_ID").andExpect(status().is5xxServerError()); ProjectExample projectExample = new ProjectExample(); projectExample.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID); @@ -261,12 +260,12 @@ public class DashboardFrontPageControllerTests extends BaseTest { layoutDTO1.setFullScreen(false); layoutDTO.add(layoutDTO1); MvcResult mvcResult = this.requestPostWithOkAndReturn(EDIT_LAYOUT + DEFAULT_ORGANIZATION_ID, layoutDTO); - contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); - resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); - layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class); + String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); + ListlayoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class); Assertions.assertNotNull(layoutDTOS); - mvcResultGrt = this.requestGetWithOkAndReturn(GET_LAYOUT + DEFAULT_ORGANIZATION_ID); + MvcResult mvcResultGrt = this.requestGetWithOkAndReturn(GET_LAYOUT + DEFAULT_ORGANIZATION_ID); contentAsString = mvcResultGrt.getResponse().getContentAsString(StandardCharsets.UTF_8); resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class); @@ -546,6 +545,22 @@ public class DashboardFrontPageControllerTests extends BaseTest { Assertions.assertNotNull(list); } + @Test + @Order(6) + public void testProjectUserList() throws Exception { + MvcResult mvcResult = this.requestGetWithOkAndReturn(PROJECT_MEMBER_USER_LIST + DEFAULT_PROJECT_ID); + String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); + List list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), UserExtendDTO.class); + Assertions.assertNotNull(list); + + mvcResult = this.requestGetWithOkAndReturn(PROJECT_MEMBER_USER_LIST + "id"); + returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + resultHolder = JSON.parseObject(returnData, ResultHolder.class); + list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), UserExtendDTO.class); + Assertions.assertNotNull(list); + } + private void enableDefaultPlatformConfig() { ProjectApplication record = new ProjectApplication(); record.setTypeValue("true"); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java index cd86ac857d..1ee749267f 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java @@ -82,7 +82,6 @@ public interface ExtTestPlanMapper { @BaseConditionFilter List selectMyFollowByConditions(@Param("request") TestPlanTableRequest request); - List getSimpleTestPlanList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); /** * 获取项目下的计划关联缺陷 diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml index a0c9ff08c5..a165dfd44f 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml @@ -789,6 +789,7 @@ AND test_plan.create_user = #{userId} + AND test_plan.type = 'TEST_PLAN' group by test_plan.project_id; @@ -806,6 +807,7 @@ #{userId} + AND test_plan.type = 'TEST_PLAN' group by test_plan.create_user; @@ -860,14 +862,7 @@ ) t - +