From 989c29d0105f676e76e1e9398e3b534428b16b41 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 18 Nov 2024 14:28:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8D=A1=E7=89=87=E5=A2=9E=E5=8A=A0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=85=A8=E9=80=89=E6=B8=85=E7=A9=BA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/TestCasePageProviderRequest.java | 2 -- .../java/io/metersphere/dashboard/dto/LayoutDTO.java | 2 ++ .../dashboard/request/DashboardFrontPageRequest.java | 3 +++ .../dashboard/service/DashboardService.java | 9 ++++++++- .../DashboardFrontPageControllerTests.java | 12 +++++++++++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/backend/framework/provider/src/main/java/io/metersphere/request/TestCasePageProviderRequest.java b/backend/framework/provider/src/main/java/io/metersphere/request/TestCasePageProviderRequest.java index 49e029ce33..9d80d375ff 100644 --- a/backend/framework/provider/src/main/java/io/metersphere/request/TestCasePageProviderRequest.java +++ b/backend/framework/provider/src/main/java/io/metersphere/request/TestCasePageProviderRequest.java @@ -41,8 +41,6 @@ public class TestCasePageProviderRequest extends BaseCondition implements Serial private String apiDefinitionId; @Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{api_definition.project_id.not_blank}") - @Size(min = 1, max = 50, message = "{api_definition.project_id.length_range}") private String projectId; @Schema(description = "接口协议", requiredMode = Schema.RequiredMode.REQUIRED) 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 9eb8083a43..9f6bd7bf35 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 @@ -23,6 +23,8 @@ public class LayoutDTO { private Boolean fullScreen; @Schema(description = "选中的项目ID") private List projectIds; + @Schema(description = "是否全选") + private boolean selectAll; @Schema(description = "人员集合") private List handleUsers; diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/request/DashboardFrontPageRequest.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/request/DashboardFrontPageRequest.java index 1798253aa5..01f858572c 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/request/DashboardFrontPageRequest.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/request/DashboardFrontPageRequest.java @@ -12,6 +12,9 @@ import java.util.List; @Data public class DashboardFrontPageRequest extends DashboardBaseRequest{ + @Schema(description = "是否全选") + private boolean selectAll; + @Schema(description = "固定时间天数") private Integer dayNumber; 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 11a61aef4a..b739aaa609 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 @@ -142,6 +142,9 @@ public class DashboardService { public OverViewCountDTO createByMeCount(DashboardFrontPageRequest request, String userId) { + if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) { + return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>()); + } List projects; if (CollectionUtils.isNotEmpty(request.getProjectIds())) { projects = extProjectMapper.getProjectNameModule(null, request.getProjectIds()); @@ -295,6 +298,9 @@ public class DashboardService { } public OverViewCountDTO projectViewCount(DashboardFrontPageRequest request, String userId) { + if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) { + return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>()); + } List collect = getHasPermissionProjects(request, userId); Map> permissionModuleProjectIdMap = dashboardProjectService.getModuleProjectIds(collect); Long toStartTime = request.getToStartTime(); @@ -457,6 +463,7 @@ public class DashboardService { layoutDTO.setKey(layoutKey.toString()); layoutDTO.setLabel(label); layoutDTO.setPos(pos); + layoutDTO.setSelectAll(true); layoutDTO.setFullScreen(true); layoutDTO.setProjectIds(projectIds); layoutDTO.setHandleUsers(new ArrayList<>()); @@ -1011,7 +1018,7 @@ public class DashboardService { public Pager> getFunctionalCasePage(DashboardFrontPageRequest request) { CaseReviewPageRequest reviewRequest = getCaseReviewPageRequest(request); Page page = PageHelper.startPage(reviewRequest.getCurrent(), reviewRequest.getPageSize(), - com.alibaba.excel.util.StringUtils.isNotBlank(reviewRequest.getSortString()) ? reviewRequest.getSortString() : "pos desc"); + StringUtils.isNotBlank(reviewRequest.getSortString()) ? reviewRequest.getSortString() : "pos desc"); return PageUtils.setPageInfo(page, caseReviewService.getCaseReviewPage(reviewRequest)); } 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 39bee52cbd..07e26d074c 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 @@ -124,10 +124,20 @@ public class DashboardFrontPageControllerTests extends BaseTest { MvcResult mvcResultAll = this.requestPostWithOkAndReturn(PROJECT_VIEW, dashboardFrontPageRequest); OverViewCountDTO moduleCountAll = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResultAll).get("data")), OverViewCountDTO.class); Assertions.assertNotNull(moduleCountAll); + dashboardFrontPageRequest.setProjectIds(new ArrayList<>()); + dashboardFrontPageRequest.setSelectAll(false); + mvcResult = this.requestPostWithOkAndReturn(CREATE_BY_ME, dashboardFrontPageRequest); + contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); + moduleCount = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), OverViewCountDTO.class); + Assertions.assertNotNull(moduleCount); + mvcResultAll = this.requestPostWithOkAndReturn(PROJECT_VIEW, dashboardFrontPageRequest); + moduleCountAll = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResultAll).get("data")), OverViewCountDTO.class); + Assertions.assertNotNull(moduleCountAll); + dashboardFrontPageRequest.setDayNumber(null); dashboardFrontPageRequest.setStartTime(1716185577387L); dashboardFrontPageRequest.setEndTime(1730181702699L); - dashboardFrontPageRequest.setProjectIds(new ArrayList<>()); mvcResult = this.requestPostWithOkAndReturn(CREATE_BY_ME, dashboardFrontPageRequest); moduleCount = JSON.parseObject(JSON.toJSONString( JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),