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} + + +