From eae3398f94f977aedcb5a0a427606feb9fb196e7 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Sat, 11 May 2024 18:47:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F=E5=8F=96=E6=B6=88=E5=85=B3?= =?UTF-8?q?=E8=81=94=E7=94=A8=E4=BE=8B=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestPlanFunctionalCaseController.java | 12 ++++- .../dto/request/BasePlanCaseBatchRequest.java | 27 ++++++++++ .../ExtTestPlanFunctionalCaseMapper.java | 3 ++ .../ExtTestPlanFunctionalCaseMapper.xml | 52 +++++++++++++++++++ .../TestPlanFunctionalCaseService.java | 34 +++++++++++- .../plan/service/TestPlanResourceService.java | 24 +++++++++ .../TestPlanCaseControllerTests.java | 32 ++++++++++++ .../dml/init_test_plan_case_relate_bug.sql | 16 ++++-- 8 files changed, 194 insertions(+), 6 deletions(-) create mode 100644 backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/BasePlanCaseBatchRequest.java diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanFunctionalCaseController.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanFunctionalCaseController.java index 9eeed7fd18..c7533a3219 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanFunctionalCaseController.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanFunctionalCaseController.java @@ -1,10 +1,9 @@ package io.metersphere.plan.controller; -import com.alibaba.excel.util.StringUtils; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import io.metersphere.functional.request.ReviewFunctionalCasePageRequest; import io.metersphere.plan.constants.TestPlanResourceConfig; +import io.metersphere.plan.dto.request.BasePlanCaseBatchRequest; import io.metersphere.plan.dto.request.ResourceSortRequest; import io.metersphere.plan.dto.request.TestPlanAssociationRequest; import io.metersphere.plan.dto.request.TestPlanCaseRequest; @@ -86,4 +85,13 @@ public class TestPlanFunctionalCaseController { public Map moduleCount(@Validated @RequestBody TestPlanCaseRequest request) { return testPlanFunctionalCaseService.moduleCount(request); } + @PostMapping("/batch/disassociate") + @Operation(summary = "测试计划-计划详情-列表-批量取消关联用例") + @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_ASSOCIATION) + @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") + public TestPlanAssociationResponse batchDisassociate(@Validated @RequestBody BasePlanCaseBatchRequest request) { + testPlanManagementService.checkModuleIsOpen(request.getTestPlanId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN_FUNCTIONAL_CASE)); + return testPlanFunctionalCaseService.disassociate(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/functional/case/association", HttpMethodConstants.POST.name())); + } + } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/BasePlanCaseBatchRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/BasePlanCaseBatchRequest.java new file mode 100644 index 0000000000..5c3d7460b4 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/BasePlanCaseBatchRequest.java @@ -0,0 +1,27 @@ +package io.metersphere.plan.dto.request; + +import io.metersphere.system.dto.table.TableBatchProcessDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * @author wx + */ +@Data +public class BasePlanCaseBatchRequest extends TableBatchProcessDTO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan.id.not_blank}") + private String testPlanId; + + @Schema(description = "模块id") + private List moduleIds; +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java index 383310e45f..7c68db919a 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java @@ -5,6 +5,7 @@ import io.metersphere.functional.dto.FunctionalCaseModuleDTO; import io.metersphere.functional.dto.ProjectOptionDTO; import io.metersphere.plan.dto.AssociationNode; import io.metersphere.plan.dto.ResourceSelectParam; +import io.metersphere.plan.dto.request.BasePlanCaseBatchRequest; import io.metersphere.plan.dto.request.TestPlanCaseRequest; import io.metersphere.plan.dto.response.TestPlanCasePageResponse; import io.metersphere.project.dto.NodeSortQueryParam; @@ -35,4 +36,6 @@ public interface ExtTestPlanFunctionalCaseMapper { List countModuleIdByRequest(@Param("request") TestPlanCaseRequest request, @Param("deleted") boolean deleted); long caseCount(@Param("request") TestPlanCaseRequest request, @Param("deleted") boolean deleted); + + List getIds(@Param("request") BasePlanCaseBatchRequest request, @Param("deleted") boolean deleted); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml index 9520d8dc84..c34b0ec998 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml @@ -44,6 +44,19 @@ ORDER BY #{orderString} + + +