refactor(工作台): 测试计划统计增加权限校验

This commit is contained in:
guoyuqi 2024-11-18 18:15:23 +08:00 committed by Craftsman
parent 9bf0488506
commit d4191a07d8
2 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import io.metersphere.plan.dto.TestPlanExecuteHisDTO;
import io.metersphere.plan.dto.request.*; import io.metersphere.plan.dto.request.*;
import io.metersphere.plan.dto.response.*; import io.metersphere.plan.dto.response.*;
import io.metersphere.plan.service.*; import io.metersphere.plan.service.*;
import io.metersphere.project.service.PermissionCheckService;
import io.metersphere.sdk.constants.HttpMethodConstants; import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.dto.LogInsertModule; import io.metersphere.system.dto.LogInsertModule;
@ -48,6 +49,10 @@ public class TestPlanController {
private TestPlanManagementService testPlanManagementService; private TestPlanManagementService testPlanManagementService;
@Resource @Resource
private TestPlanStatisticsService testPlanStatisticsService; private TestPlanStatisticsService testPlanStatisticsService;
@Resource
private PermissionCheckService permissionCheckService;
public static final String TEST_PLAN_MODULE = "testPlan";
@PostMapping("/page") @PostMapping("/page")
@ -64,6 +69,11 @@ public class TestPlanController {
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public TestPlanCoverageDTO rage(@Validated @RequestBody TestPlanCoverageRequest request) { 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()); return testPlanService.rageByProjectIdAndTimestamp(request.getProjectId(), request.getStartTime(), request.getEndTime());
} }

View File

@ -1,5 +1,6 @@
package io.metersphere.plan.dto.response; package io.metersphere.plan.dto.response;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@Data @Data
@ -29,6 +30,9 @@ public class TestPlanCoverageDTO {
private int prepared = 0; private int prepared = 0;
private int archived = 0; private int archived = 0;
@Schema(description = "错误码")
private int errorCode;
public void archivedAutoIncrement() { public void archivedAutoIncrement() {
archived++; archived++;
} }