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 830097986d..d9a84a5d26 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 @@ -404,8 +404,10 @@ public class DashboardService { if (CollectionUtils.isEmpty(allPermissionProjects)) { return new ArrayList<>(); } + List orgProjectMemberList = extProjectMemberMapper.getOrgProjectMemberList(organizationId, null); if (CollectionUtils.isEmpty(userLayouts)) { - return getDefaultLayoutDTOS(allPermissionProjects.getFirst().getId()); + List userIds = orgProjectMemberList.stream().map(ProjectUserMemberDTO::getId).distinct().toList(); + return getDefaultLayoutDTOS(allPermissionProjects.getFirst().getId(),userIds); } UserLayout userLayout = userLayouts.getFirst(); byte[] configuration = userLayout.getConfiguration(); @@ -415,7 +417,6 @@ public class DashboardService { } List layoutDTOS = JSON.parseArray(layoutDTOStr, LayoutDTO.class); Map> permissionModuleProjectIdMap = dashboardProjectService.getPermissionModuleProjectIds(allPermissionProjects, userId); - List orgProjectMemberList = extProjectMemberMapper.getOrgProjectMemberList(organizationId, null); rebuildLayouts(layoutDTOS, allPermissionProjects, orgProjectMemberList, permissionModuleProjectIdMap); return layoutDTOS.stream().sorted(Comparator.comparing(LayoutDTO::getPos)).collect(Collectors.toList()); } @@ -477,6 +478,10 @@ public class DashboardService { || StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.BUG_HANDLE_USER.toString())) { Set hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_BUG_READ); checkHasPermissionProject(layoutDTO, hasReadProjectIds); + if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.BUG_HANDLE_USER.toString())) { + List list = orgProjectMemberList.stream().filter(t -> layoutDTO.getHandleUsers().contains(t.getId())).toList(); + layoutDTO.setHandleUsers(list.stream().map(ProjectUserMemberDTO::getId).distinct().toList()); + } } } } @@ -496,16 +501,16 @@ public class DashboardService { /** * 获取默认布局 * - * @param organizationId 组织ID + * @param projectId 项目ID * @return List */ - private static List getDefaultLayoutDTOS(String organizationId) { + private static List getDefaultLayoutDTOS(String projectId, List userIds) { List layoutDTOS = new ArrayList<>(); - LayoutDTO projectLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_VIEW, "workbench.homePage.projectOverview", 0, new ArrayList<>()); + LayoutDTO projectLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_VIEW, "workbench.homePage.projectOverview", 0, new ArrayList<>(), new ArrayList<>()); layoutDTOS.add(projectLayoutDTO); - LayoutDTO createByMeLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.CREATE_BY_ME, "workbench.homePage.createdByMe", 1, new ArrayList<>()); + LayoutDTO createByMeLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.CREATE_BY_ME, "workbench.homePage.createdByMe", 1, new ArrayList<>(), new ArrayList<>()); layoutDTOS.add(createByMeLayoutDTO); - LayoutDTO projectMemberLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW, "workbench.homePage.staffOverview", 2, List.of(organizationId)); + LayoutDTO projectMemberLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW, "workbench.homePage.staffOverview", 2, List.of(projectId), userIds); layoutDTOS.add(projectMemberLayoutDTO); return layoutDTOS; } @@ -519,7 +524,7 @@ public class DashboardService { * @param projectIds 布局卡片所选的项目ids * @return LayoutDTO */ - private static LayoutDTO buildDefaultLayoutDTO(DashboardUserLayoutKeys layoutKey, String label, int pos, List projectIds) { + private static LayoutDTO buildDefaultLayoutDTO(DashboardUserLayoutKeys layoutKey, String label, int pos, List projectIds, List users) { LayoutDTO layoutDTO = new LayoutDTO(); layoutDTO.setId(UUID.randomUUID().toString()); layoutDTO.setKey(layoutKey.toString()); @@ -528,7 +533,7 @@ public class DashboardService { layoutDTO.setSelectAll(true); layoutDTO.setFullScreen(true); layoutDTO.setProjectIds(projectIds); - layoutDTO.setHandleUsers(new ArrayList<>()); + layoutDTO.setHandleUsers(users); return layoutDTO; } 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 91a8d4b5ca..17d49da82a 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 @@ -115,6 +115,7 @@ public class DashboardFrontPageControllerTests extends BaseTest { dashboardFrontPageRequest.setCurrent(1); dashboardFrontPageRequest.setPageSize(5); dashboardFrontPageRequest.setProjectIds(List.of(DEFAULT_PROJECT_ID)); + dashboardFrontPageRequest.setHandleUsers(List.of("admin")); MvcResult bugMvcResult = this.requestPostWithOkAndReturn(BUG_HANDLE_USER, dashboardFrontPageRequest); String bugContentAsString = bugMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); ResultHolder bugResultHolder = JSON.parseObject(bugContentAsString, ResultHolder.class);