From 9ff9a3d25aba309d700cc7a6f56b18bfa6541070 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 20 Jun 2024 18:53:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=8E=A5=E5=8F=A3=E7=9A=84=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/BasePlanCaseBatchRequest.java | 3 + .../dto/request/TestPlanApiCaseRequest.java | 32 +++++++++- .../request/TestPlanApiScenarioRequest.java | 35 ++++++++++- .../plan/mapper/ExtTestPlanApiCaseMapper.java | 14 ++--- .../plan/mapper/ExtTestPlanApiCaseMapper.xml | 19 ++++-- .../mapper/ExtTestPlanApiScenarioMapper.xml | 19 ++++-- .../plan/service/TestPlanApiCaseService.java | 59 ++++++++++++------- .../service/TestPlanApiScenarioService.java | 55 ++++++++++------- 8 files changed, 175 insertions(+), 61 deletions(-) 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 index f76de94006..d0940fb3c0 100644 --- 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 @@ -27,4 +27,7 @@ public class BasePlanCaseBatchRequest extends TableBatchProcessDTO implements Se @Schema(description = "计划集id") private String collectionId; + + @Schema(description = "项目Id") + private String projectId; } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiCaseRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiCaseRequest.java index 7bbe82f943..660b7ab347 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiCaseRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiCaseRequest.java @@ -1,17 +1,23 @@ package io.metersphere.plan.dto.request; -import io.metersphere.api.dto.definition.ApiTestCasePageRequest; +import io.metersphere.system.dto.sdk.BasePageRequest; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; import lombok.Data; +import java.io.Serial; +import java.util.ArrayList; import java.util.List; /** * @author wx */ @Data -public class TestPlanApiCaseRequest extends ApiTestCasePageRequest { +public class TestPlanApiCaseRequest extends BasePageRequest { + + @Serial + private static final long serialVersionUID = 1L; @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{test_plan.id.not_blank}") @@ -20,4 +26,26 @@ public class TestPlanApiCaseRequest extends ApiTestCasePageRequest { @Schema(description = "计划集id") private String collectionId; + @Schema(description = "接口pk") + @Size(max = 50, message = "{api_definition.id.length_range}") + private String apiDefinitionId; + + @Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) + @Size(max = 50, message = "{api_definition.project_id.length_range}") + private String projectId; + + @Schema(description = "接口协议", requiredMode = Schema.RequiredMode.REQUIRED) + private List protocols = new ArrayList<>(); + + @Schema(description = "模块ID") + private List<@NotBlank String> moduleIds; + + @Schema(description = "版本fk") + @Size(max = 50, message = "{api_definition.version_id.length_range}") + private String versionId; + + @Schema(description = "版本来源") + @Size(max = 50, message = "{api_definition.ref_id.length_range}") + private String refId; + } \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiScenarioRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiScenarioRequest.java index a0fb2c9371..a0adfebaee 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiScenarioRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiScenarioRequest.java @@ -1,15 +1,21 @@ package io.metersphere.plan.dto.request; -import io.metersphere.api.dto.scenario.ApiScenarioPageRequest; +import io.metersphere.system.dto.sdk.BasePageRequest; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; /** * @author wx */ @Data -public class TestPlanApiScenarioRequest extends ApiScenarioPageRequest { +@EqualsAndHashCode(callSuper = false) +public class TestPlanApiScenarioRequest extends BasePageRequest { @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{test_plan.id.not_blank}") @@ -18,4 +24,29 @@ public class TestPlanApiScenarioRequest extends ApiScenarioPageRequest { @Schema(description = "计划集id") private String collectionId; + @Schema(description = "场景pk") + @Size(min = 1, max = 50, message = "{api_scenario_step.scenario_id.length_range}") + private String scenarioId; + + @Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) + @Size(max = 50, message = "{api_definition.project_id.length_range}") + private String projectId; + + @Schema(description = "版本fk") + @Size(min = 1, max = 50, message = "{api_definition.version_id.length_range}") + private String versionId; + + @Schema(description = "版本引用fk") + @Size(min = 1, max = 50, message = "{api_definition.ref_id.length_range}") + private String refId; + + @Schema(description = "模块ID(根据模块树查询时要把当前节点以及子节点都放在这里。)") + private List<@NotBlank String> moduleIds; + + @Schema(description = "删除状态(状态为 1 时为回收站数据)") + private Boolean deleted = false; + + @Schema(description = "查询时排除的ID") + private List excludeIds = new ArrayList<>(); + } \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java index 653e27364a..ec354cff57 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java @@ -60,13 +60,13 @@ public interface ExtTestPlanApiCaseMapper { Long getMaxPosByCollectionId(String collectionId); - /** - * 获取计划下的功能用例集合 - * - * @param planIds 测试计划ID集合 - * @return 计划功能用例集合 - */ - List getPlanApiCaseByIds(@Param("planIds") List planIds); + /** + * 获取计划下的功能用例集合 + * + * @param planIds 测试计划ID集合 + * @return 计划功能用例集合 + */ + List getPlanApiCaseByIds(@Param("planIds") List planIds); List getApiCaseExecuteInfoByIds(@Param("ids") List ids); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml index 3c84322c1a..a311efb852 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml @@ -451,6 +451,9 @@ and atc.api_definition_id = #{request.apiDefinitionId} + + and atc.project_id = #{request.projectId} + and ( atc.name like concat('%', #{request.keyword},'%') @@ -462,7 +465,14 @@ and a.module_id in - #{nodeId} + + + 'root' + + + #{nodeId} + + @@ -540,7 +550,8 @@ diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml index 9c67780835..dace5360d1 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml @@ -122,10 +122,20 @@ and api_scenario.id = #{request.scenarioId} + + and api_scenario.project_id = #{request.projectId} + and api_scenario.module_id in - #{nodeId} + + + 'root' + + + #{nodeId} + + @@ -323,14 +333,15 @@