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()),