From d4191a07d8c671ab6eca620a7143f037dc501490 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 18 Nov 2024 18:15:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=BB=9F=E8=AE=A1=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/controller/TestPlanController.java | 10 ++++++++++ .../plan/dto/response/TestPlanCoverageDTO.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanController.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanController.java index f3f02e3b1d..611c70bd90 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanController.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanController.java @@ -8,6 +8,7 @@ import io.metersphere.plan.dto.TestPlanExecuteHisDTO; import io.metersphere.plan.dto.request.*; import io.metersphere.plan.dto.response.*; import io.metersphere.plan.service.*; +import io.metersphere.project.service.PermissionCheckService; import io.metersphere.sdk.constants.HttpMethodConstants; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.dto.LogInsertModule; @@ -48,6 +49,10 @@ public class TestPlanController { private TestPlanManagementService testPlanManagementService; @Resource private TestPlanStatisticsService testPlanStatisticsService; + @Resource + private PermissionCheckService permissionCheckService; + + public static final String TEST_PLAN_MODULE = "testPlan"; @PostMapping("/page") @@ -64,6 +69,11 @@ public class TestPlanController { @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public TestPlanCoverageDTO rage(@Validated @RequestBody TestPlanCoverageRequest request) { + if (Boolean.FALSE.equals(permissionCheckService.checkModule(request.getProjectId(), TEST_PLAN_MODULE, SessionUtils.getUserId(), PermissionConstants.TEST_PLAN_READ))) { + TestPlanCoverageDTO testPlanCoverageDTO = new TestPlanCoverageDTO(); + testPlanCoverageDTO.setErrorCode(109001); + return testPlanCoverageDTO; + } return testPlanService.rageByProjectIdAndTimestamp(request.getProjectId(), request.getStartTime(), request.getEndTime()); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanCoverageDTO.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanCoverageDTO.java index 5e839c9de6..0638b4f959 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanCoverageDTO.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanCoverageDTO.java @@ -1,5 +1,6 @@ package io.metersphere.plan.dto.response; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @Data @@ -29,6 +30,9 @@ public class TestPlanCoverageDTO { private int prepared = 0; private int archived = 0; + @Schema(description = "错误码") + private int errorCode; + public void archivedAutoIncrement() { archived++; }