From 2ff25735da37606814615ee4c5ca4c2ccb1bc230 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 29 Apr 2024 15:14:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/domain/TestPlanConfig.java | 8 +- .../plan/domain/TestPlanConfigExample.java | 60 ++++++ .../plan/mapper/TestPlanConfigMapper.java | 6 - .../plan/mapper/TestPlanConfigMapper.xml | 82 ++------ .../3.0.0/ddl/V3.0.0_12__beta_ddl.sql | 5 + .../main/resources/i18n/plan_en_US.properties | 3 +- .../main/resources/i18n/plan_zh_CN.properties | 3 +- .../main/resources/i18n/plan_zh_TW.properties | 3 +- .../dto/request/TestPlanCreateRequest.java | 5 +- .../dto/request/TestPlanTableRequest.java | 14 +- .../plan/dto/response/TestPlanResponse.java | 4 +- .../plan/mapper/ExtTestPlanMapper.java | 3 +- .../plan/mapper/ExtTestPlanMapper.xml | 189 +++++++++++++++++- .../service/TestPlanManagementService.java | 79 ++++---- .../plan/service/TestPlanService.java | 1 + .../plan/controller/TestPlanTests.java | 10 + 16 files changed, 347 insertions(+), 128 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfig.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfig.java index b9f0f90262..9816adcb8b 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfig.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfig.java @@ -27,8 +27,10 @@ public class TestPlanConfig implements Serializable { @NotNull(message = "{test_plan_config.pass_threshold.not_blank}", groups = {Created.class}) private Double passThreshold; - @Schema(description = "运行模式") - private String runModeConfig; + @Schema(description = "是否开启测试规划", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan_config.test_planning.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 1, message = "{test_plan_config.test_planning.length_range}", groups = {Created.class, Updated.class}) + private Boolean testPlanning; private static final long serialVersionUID = 1L; @@ -37,7 +39,7 @@ public class TestPlanConfig implements Serializable { automaticStatusUpdate("automatic_status_update", "automaticStatusUpdate", "BIT", false), repeatCase("repeat_case", "repeatCase", "BIT", false), passThreshold("pass_threshold", "passThreshold", "DOUBLE", false), - runModeConfig("run_mode_config", "runModeConfig", "LONGVARCHAR", false); + testPlanning("test_planning", "testPlanning", "BIT", false); private static final String BEGINNING_DELIMITER = "`"; diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfigExample.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfigExample.java index 374e906d60..94bee01b00 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfigExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanConfigExample.java @@ -353,6 +353,66 @@ public class TestPlanConfigExample { addCriterion("pass_threshold not between", value1, value2, "passThreshold"); return (Criteria) this; } + + public Criteria andTestPlanningIsNull() { + addCriterion("test_planning is null"); + return (Criteria) this; + } + + public Criteria andTestPlanningIsNotNull() { + addCriterion("test_planning is not null"); + return (Criteria) this; + } + + public Criteria andTestPlanningEqualTo(Boolean value) { + addCriterion("test_planning =", value, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningNotEqualTo(Boolean value) { + addCriterion("test_planning <>", value, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningGreaterThan(Boolean value) { + addCriterion("test_planning >", value, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningGreaterThanOrEqualTo(Boolean value) { + addCriterion("test_planning >=", value, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningLessThan(Boolean value) { + addCriterion("test_planning <", value, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningLessThanOrEqualTo(Boolean value) { + addCriterion("test_planning <=", value, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningIn(List values) { + addCriterion("test_planning in", values, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningNotIn(List values) { + addCriterion("test_planning not in", values, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningBetween(Boolean value1, Boolean value2) { + addCriterion("test_planning between", value1, value2, "testPlanning"); + return (Criteria) this; + } + + public Criteria andTestPlanningNotBetween(Boolean value1, Boolean value2) { + addCriterion("test_planning not between", value1, value2, "testPlanning"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.java b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.java index f2e217bf13..2421e1d026 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.java @@ -16,22 +16,16 @@ public interface TestPlanConfigMapper { int insertSelective(TestPlanConfig record); - List selectByExampleWithBLOBs(TestPlanConfigExample example); - List selectByExample(TestPlanConfigExample example); TestPlanConfig selectByPrimaryKey(String testPlanId); int updateByExampleSelective(@Param("record") TestPlanConfig record, @Param("example") TestPlanConfigExample example); - int updateByExampleWithBLOBs(@Param("record") TestPlanConfig record, @Param("example") TestPlanConfigExample example); - int updateByExample(@Param("record") TestPlanConfig record, @Param("example") TestPlanConfigExample example); int updateByPrimaryKeySelective(TestPlanConfig record); - int updateByPrimaryKeyWithBLOBs(TestPlanConfig record); - int updateByPrimaryKey(TestPlanConfig record); int batchInsert(@Param("list") List list); diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.xml index 1dfd0eb81c..d953157f91 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanConfigMapper.xml @@ -6,9 +6,7 @@ - - - + @@ -69,27 +67,8 @@ - test_plan_id, automatic_status_update, repeat_case, pass_threshold + test_plan_id, automatic_status_update, repeat_case, pass_threshold, test_planning - - run_mode_config - - - select - , - from test_plan_config where test_plan_id = #{testPlanId,jdbcType=VARCHAR} @@ -124,9 +101,9 @@ insert into test_plan_config (test_plan_id, automatic_status_update, repeat_case, - pass_threshold, run_mode_config) + pass_threshold, test_planning) values (#{testPlanId,jdbcType=VARCHAR}, #{automaticStatusUpdate,jdbcType=BIT}, #{repeatCase,jdbcType=BIT}, - #{passThreshold,jdbcType=DOUBLE}, #{runModeConfig,jdbcType=LONGVARCHAR}) + #{passThreshold,jdbcType=DOUBLE}, #{testPlanning,jdbcType=BIT}) insert into test_plan_config @@ -143,8 +120,8 @@ pass_threshold, - - run_mode_config, + + test_planning, @@ -160,8 +137,8 @@ #{passThreshold,jdbcType=DOUBLE}, - - #{runModeConfig,jdbcType=LONGVARCHAR}, + + #{testPlanning,jdbcType=BIT}, @@ -186,31 +163,21 @@ pass_threshold = #{record.passThreshold,jdbcType=DOUBLE}, - - run_mode_config = #{record.runModeConfig,jdbcType=LONGVARCHAR}, + + test_planning = #{record.testPlanning,jdbcType=BIT}, - - update test_plan_config - set test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, - automatic_status_update = #{record.automaticStatusUpdate,jdbcType=BIT}, - repeat_case = #{record.repeatCase,jdbcType=BIT}, - pass_threshold = #{record.passThreshold,jdbcType=DOUBLE}, - run_mode_config = #{record.runModeConfig,jdbcType=LONGVARCHAR} - - - - update test_plan_config set test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, automatic_status_update = #{record.automaticStatusUpdate,jdbcType=BIT}, repeat_case = #{record.repeatCase,jdbcType=BIT}, - pass_threshold = #{record.passThreshold,jdbcType=DOUBLE} + pass_threshold = #{record.passThreshold,jdbcType=DOUBLE}, + test_planning = #{record.testPlanning,jdbcType=BIT} @@ -227,35 +194,28 @@ pass_threshold = #{passThreshold,jdbcType=DOUBLE}, - - run_mode_config = #{runModeConfig,jdbcType=LONGVARCHAR}, + + test_planning = #{testPlanning,jdbcType=BIT}, where test_plan_id = #{testPlanId,jdbcType=VARCHAR} - - update test_plan_config - set automatic_status_update = #{automaticStatusUpdate,jdbcType=BIT}, - repeat_case = #{repeatCase,jdbcType=BIT}, - pass_threshold = #{passThreshold,jdbcType=DOUBLE}, - run_mode_config = #{runModeConfig,jdbcType=LONGVARCHAR} - where test_plan_id = #{testPlanId,jdbcType=VARCHAR} - update test_plan_config set automatic_status_update = #{automaticStatusUpdate,jdbcType=BIT}, repeat_case = #{repeatCase,jdbcType=BIT}, - pass_threshold = #{passThreshold,jdbcType=DOUBLE} + pass_threshold = #{passThreshold,jdbcType=DOUBLE}, + test_planning = #{testPlanning,jdbcType=BIT} where test_plan_id = #{testPlanId,jdbcType=VARCHAR} insert into test_plan_config - (test_plan_id, automatic_status_update, repeat_case, pass_threshold, run_mode_config + (test_plan_id, automatic_status_update, repeat_case, pass_threshold, test_planning ) values (#{item.testPlanId,jdbcType=VARCHAR}, #{item.automaticStatusUpdate,jdbcType=BIT}, - #{item.repeatCase,jdbcType=BIT}, #{item.passThreshold,jdbcType=DOUBLE}, #{item.runModeConfig,jdbcType=LONGVARCHAR} + #{item.repeatCase,jdbcType=BIT}, #{item.passThreshold,jdbcType=DOUBLE}, #{item.testPlanning,jdbcType=BIT} ) @@ -281,8 +241,8 @@ #{item.passThreshold,jdbcType=DOUBLE} - - #{item.runModeConfig,jdbcType=LONGVARCHAR} + + #{item.testPlanning,jdbcType=BIT} ) diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_12__beta_ddl.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_12__beta_ddl.sql index 5f8d17cea4..8369c8d5ec 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_12__beta_ddl.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_12__beta_ddl.sql @@ -8,6 +8,11 @@ ALTER TABLE api_definition_mock ADD COLUMN status_code INT(50) ; CREATE INDEX idx_scene ON custom_field (scene); CREATE INDEX idx_internal ON custom_field (internal); +CREATE INDEX idx_num ON test_plan(num); +ALTER TABLE test_plan_config DROP COLUMN run_mode_config; + +ALTER TABLE test_plan_config ADD COLUMN test_planning BIT NOT NULL DEFAULT 0 COMMENT '是否开启测试规划'; + -- set innodb lock wait timeout to default SET SESSION innodb_lock_wait_timeout = DEFAULT; diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties index 943b756fda..064857ddf8 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties @@ -93,4 +93,5 @@ log.test_plan.move=Move resources log.test_plan.update=Update resources log.test_plan.functional_case=Functional case log.test_plan.api_case=Api case -log.test_plan.api_scenario=Api scenario \ No newline at end of file +log.test_plan.api_scenario=Api scenario +test_plan.type.not_blank=Test plan type cannot be empty \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties index b0ecb74332..cffddb9777 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties @@ -93,4 +93,5 @@ log.test_plan.move=移动了资源 log.test_plan.update=修改了资源 log.test_plan.functional_case=功能用例 log.test_plan.api_case=接口用例 -log.test_plan.api_scenario=接口场景 \ No newline at end of file +log.test_plan.api_scenario=接口场景 +test_plan.type.not_blank=测试计划类型不能为空 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties index 885e28a3b4..81a20ee468 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties @@ -93,4 +93,5 @@ log.test_plan.move=移動了資源 log.test_plan.update=修改了資源 log.test_plan.functional_case=功能用例 log.test_plan.api_case=接口用例 -log.test_plan.api_scenario=接口場景 \ No newline at end of file +log.test_plan.api_scenario=接口場景 +test_plan.type.not_blank=測試計劃類型不能為空 \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java index c27e2df773..828b0b97a9 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java @@ -51,6 +51,9 @@ public class TestPlanCreateRequest { @Schema(description = "描述") private String description; + @Schema(description = "是否开启测试规划", requiredMode = Schema.RequiredMode.REQUIRED) + private boolean testPlanning; + @Schema(description = "是否自定更新功能用例状态", requiredMode = Schema.RequiredMode.REQUIRED) private boolean automaticStatusUpdate; @@ -61,7 +64,7 @@ public class TestPlanCreateRequest { @Max(value = 100, message = "{test_plan.pass_threshold.max}") @Min(value = 0) private double passThreshold = 100; - @Schema(description = "测试计划类型") + @Schema(description = "测试计划类型",allowableValues ={"TEST_PLAN", "GROUP"}, requiredMode = Schema.RequiredMode.REQUIRED ) private String type = TestPlanConstants.TEST_PLAN_TYPE_PLAN; public List getTags() { diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java index 34782b0dd4..a547c9f981 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java @@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import java.util.List; @@ -17,18 +16,13 @@ public class TestPlanTableRequest extends BasePageRequest { private List moduleIds; @Schema(description = "项目ID") - @NotBlank(message = "{id must not be blank}") + @NotBlank(message = "{test_plan.project_id.not_blank}") private String projectId; - public TestPlanTableRequest() { - this.setCurrent(1); - this.setPageSize(5); - } + @Schema(description = "类型", allowableValues = {"ALL", "TEST_PLAN", "GROUP"}, requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan.type.not_blank}") + private String type; - //没有查询条件 - public boolean conditionIsEmpty() { - return StringUtils.isEmpty(this.getKeyword()) && MapUtils.isEmpty(this.getFilter()) && MapUtils.isEmpty(this.getCombine()); - } public String getSortString() { if (StringUtils.isEmpty(super.getSortString())) { diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanResponse.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanResponse.java index c5c0cdf783..8fbf06f49c 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanResponse.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanResponse.java @@ -33,7 +33,9 @@ public class TestPlanResponse { private String moduleId; @Schema(description = "测试计划组内的测试计划") List children; + @Schema(description = "组内计划数量") + private Integer childrenCount; @Schema(description = "测试计划组Id") - private String testPlanGroupId; + private String groupId; } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java index 16a9d78f30..7e539a280b 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java @@ -2,6 +2,7 @@ package io.metersphere.plan.mapper; import io.metersphere.plan.domain.TestPlan; import io.metersphere.plan.dto.TestPlanQueryConditions; +import io.metersphere.plan.dto.request.TestPlanTableRequest; import io.metersphere.plan.dto.response.TestPlanResponse; import io.metersphere.project.dto.ModuleCountDTO; import org.apache.ibatis.annotations.Param; @@ -13,7 +14,7 @@ public interface ExtTestPlanMapper { List selectByGroupIdList(@Param("list") List parentTestPlanId); - List selectByConditions(TestPlanQueryConditions testPlanQueryConditions); + List selectByConditions(@Param("request") TestPlanTableRequest request,@Param("groupIds") List groupIds); List selectIdByConditions(TestPlanQueryConditions testPlanQueryConditions); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml index 923cd8033a..ec418cd8d4 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml @@ -11,6 +11,7 @@ + @@ -33,10 +34,9 @@ + + + and t.module_id in + + #{moduleId} + + + + and ( + t.name like concat('%', #{request.keyword},'%') + or t.num like concat('%', #{request.keyword},'%') + or t.tags like concat('%', #{request.keyword}, '%') + ) + + + + + and t.group_id = 'NONE' + + + and t.group_id = 'NONE' + and t.type = 'TEST_PLAN' + + + and t.group_id = 'NONE' + and t.type = 'GTOUP' + + + + + + + + + AND + + + and ( + + ) + + + + + + + + + + + + + and t.status in + + + + + + + + + + + + + + + + + 1=1 + + + + + + t.name + + + + + + + + + + t.num + + + + + + + + + + t.moduleId + + + + + + + + + + t.create_user + + + + + + + + + + t.create_time + + + + + + + + + + + + + + + + + + + + AND + + + OR + + + + + + + + + ( + t.tags is null or t.tags = '[]' or + + !JSON_CONTAINS(t.tags, JSON_ARRAY(#{tag})) + + ) + + + + + + + + JSON_CONTAINS(t.tags, JSON_ARRAY(#{tag})) + + + + + + + + (t.tags is null or t.tags = '[]') + + + + + + +