diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCase.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCase.java index d9b4b6b141..dd2bb8a196 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCase.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCase.java @@ -15,6 +15,9 @@ public class TestPlanApiCase implements Serializable { @Size(min = 1, max = 50, message = "{test_plan_api_case.id.length_range}", groups = {Created.class, Updated.class}) private String id; + @Schema(description = "num") + private Long num; + @Schema(description = "测试计划ID", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{test_plan_api_case.test_plan_id.not_blank}", groups = {Created.class}) @Size(min = 1, max = 50, message = "{test_plan_api_case.test_plan_id.length_range}", groups = {Created.class, Updated.class}) @@ -51,6 +54,7 @@ public class TestPlanApiCase implements Serializable { public enum Column { id("id", "id", "VARCHAR", false), + num("num", "num", "BIGINT", false), testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), apiCaseId("api_case_id", "apiCaseId", "VARCHAR", false), lastExecResult("last_exec_result", "lastExecResult", "VARCHAR", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCaseExample.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCaseExample.java index 428f2c5c8f..70d5c421f7 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCaseExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiCaseExample.java @@ -174,6 +174,66 @@ public class TestPlanApiCaseExample { return (Criteria) this; } + public Criteria andNumIsNull() { + addCriterion("num is null"); + return (Criteria) this; + } + + public Criteria andNumIsNotNull() { + addCriterion("num is not null"); + return (Criteria) this; + } + + public Criteria andNumEqualTo(Long value) { + addCriterion("num =", value, "num"); + return (Criteria) this; + } + + public Criteria andNumNotEqualTo(Long value) { + addCriterion("num <>", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThan(Long value) { + addCriterion("num >", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThanOrEqualTo(Long value) { + addCriterion("num >=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThan(Long value) { + addCriterion("num <", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThanOrEqualTo(Long value) { + addCriterion("num <=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumIn(List values) { + addCriterion("num in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumNotIn(List values) { + addCriterion("num not in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumBetween(Long value1, Long value2) { + addCriterion("num between", value1, value2, "num"); + return (Criteria) this; + } + + public Criteria andNumNotBetween(Long value1, Long value2) { + addCriterion("num not between", value1, value2, "num"); + return (Criteria) this; + } + public Criteria andTestPlanIdIsNull() { addCriterion("test_plan_id is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenario.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenario.java index d90320b9c0..0e37be5185 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenario.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenario.java @@ -15,6 +15,9 @@ public class TestPlanApiScenario implements Serializable { @Size(min = 1, max = 50, message = "{test_plan_api_scenario.id.length_range}", groups = {Created.class, Updated.class}) private String id; + @Schema(description = "num") + private Long num; + @Schema(description = "测试计划ID", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{test_plan_api_scenario.test_plan_id.not_blank}", groups = {Created.class}) @Size(min = 1, max = 50, message = "{test_plan_api_scenario.test_plan_id.length_range}", groups = {Created.class, Updated.class}) @@ -49,6 +52,7 @@ public class TestPlanApiScenario implements Serializable { public enum Column { id("id", "id", "VARCHAR", false), + num("num", "num", "BIGINT", false), testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), apiScenarioId("api_scenario_id", "apiScenarioId", "VARCHAR", false), lastExecResult("last_exec_result", "lastExecResult", "VARCHAR", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenarioExample.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenarioExample.java index 4c996f2a26..758a318b99 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenarioExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanApiScenarioExample.java @@ -174,6 +174,66 @@ public class TestPlanApiScenarioExample { return (Criteria) this; } + public Criteria andNumIsNull() { + addCriterion("num is null"); + return (Criteria) this; + } + + public Criteria andNumIsNotNull() { + addCriterion("num is not null"); + return (Criteria) this; + } + + public Criteria andNumEqualTo(Long value) { + addCriterion("num =", value, "num"); + return (Criteria) this; + } + + public Criteria andNumNotEqualTo(Long value) { + addCriterion("num <>", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThan(Long value) { + addCriterion("num >", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThanOrEqualTo(Long value) { + addCriterion("num >=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThan(Long value) { + addCriterion("num <", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThanOrEqualTo(Long value) { + addCriterion("num <=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumIn(List values) { + addCriterion("num in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumNotIn(List values) { + addCriterion("num not in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumBetween(Long value1, Long value2) { + addCriterion("num between", value1, value2, "num"); + return (Criteria) this; + } + + public Criteria andNumNotBetween(Long value1, Long value2) { + addCriterion("num not between", value1, value2, "num"); + return (Criteria) this; + } + public Criteria andTestPlanIdIsNull() { addCriterion("test_plan_id is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanBug.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanBug.java new file mode 100644 index 0000000000..bfe2d713f2 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanBug.java @@ -0,0 +1,126 @@ +package io.metersphere.plan.domain; + +import io.metersphere.validation.groups.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import lombok.Data; + +@Data +public class TestPlanBug implements Serializable { + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan_bug.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{test_plan_bug.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(description = "num") + private Long num; + + @Schema(description = "测试计划ID;测试计划ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan_bug.test_plan_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{test_plan_bug.test_plan_id.length_range}", groups = {Created.class, Updated.class}) + private String testPlanId; + + @Schema(description = "接口用例ID;测试用例ID(包含功能、接口、场景等)", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan_bug.case_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{test_plan_bug.case_id.length_range}", groups = {Created.class, Updated.class}) + private String caseId; + + @Schema(description = "用例类型;用例类型(FUNCTIONAL_CASE/API_TEST_CASE/API_SCENARIO)", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan_bug.case_type.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{test_plan_bug.case_type.length_range}", groups = {Created.class, Updated.class}) + private String caseType; + + @Schema(description = "缺陷id;缺陷ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{test_plan_bug.bug_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{test_plan_bug.bug_id.length_range}", groups = {Created.class, Updated.class}) + private String bugId; + + @Schema(description = "创建时间") + private Long createTime; + + @Schema(description = "创建人") + private String createUser; + + private static final long serialVersionUID = 1L; + + public enum Column { + id("id", "id", "VARCHAR", false), + num("num", "num", "BIGINT", false), + testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), + caseId("case_id", "caseId", "VARCHAR", false), + caseType("case_type", "caseType", "VARCHAR", false), + bugId("bug_id", "bugId", "VARCHAR", false), + createTime("create_time", "createTime", "BIGINT", false), + createUser("create_user", "createUser", "VARCHAR", false); + + private static final String BEGINNING_DELIMITER = "`"; + + private static final String ENDING_DELIMITER = "`"; + + private final String column; + + private final boolean isColumnNameDelimited; + + private final String javaProperty; + + private final String jdbcType; + + public String value() { + return this.column; + } + + public String getValue() { + return this.column; + } + + public String getJavaProperty() { + return this.javaProperty; + } + + public String getJdbcType() { + return this.jdbcType; + } + + Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) { + this.column = column; + this.javaProperty = javaProperty; + this.jdbcType = jdbcType; + this.isColumnNameDelimited = isColumnNameDelimited; + } + + public String desc() { + return this.getEscapedColumnName() + " DESC"; + } + + public String asc() { + return this.getEscapedColumnName() + " ASC"; + } + + public static Column[] excludes(Column ... excludes) { + ArrayList columns = new ArrayList<>(Arrays.asList(Column.values())); + if (excludes != null && excludes.length > 0) { + columns.removeAll(new ArrayList<>(Arrays.asList(excludes))); + } + return columns.toArray(new Column[]{}); + } + + public static Column[] all() { + return Column.values(); + } + + public String getEscapedColumnName() { + if (this.isColumnNameDelimited) { + return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString(); + } else { + return this.column; + } + } + + public String getAliasedEscapedColumnName() { + return this.getEscapedColumnName(); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanBugExample.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanBugExample.java new file mode 100644 index 0000000000..3756491766 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanBugExample.java @@ -0,0 +1,740 @@ +package io.metersphere.plan.domain; + +import java.util.ArrayList; +import java.util.List; + +public class TestPlanBugExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public TestPlanBugExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNumIsNull() { + addCriterion("num is null"); + return (Criteria) this; + } + + public Criteria andNumIsNotNull() { + addCriterion("num is not null"); + return (Criteria) this; + } + + public Criteria andNumEqualTo(Long value) { + addCriterion("num =", value, "num"); + return (Criteria) this; + } + + public Criteria andNumNotEqualTo(Long value) { + addCriterion("num <>", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThan(Long value) { + addCriterion("num >", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThanOrEqualTo(Long value) { + addCriterion("num >=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThan(Long value) { + addCriterion("num <", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThanOrEqualTo(Long value) { + addCriterion("num <=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumIn(List values) { + addCriterion("num in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumNotIn(List values) { + addCriterion("num not in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumBetween(Long value1, Long value2) { + addCriterion("num between", value1, value2, "num"); + return (Criteria) this; + } + + public Criteria andNumNotBetween(Long value1, Long value2) { + addCriterion("num not between", value1, value2, "num"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIsNull() { + addCriterion("test_plan_id is null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIsNotNull() { + addCriterion("test_plan_id is not null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdEqualTo(String value) { + addCriterion("test_plan_id =", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotEqualTo(String value) { + addCriterion("test_plan_id <>", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThan(String value) { + addCriterion("test_plan_id >", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) { + addCriterion("test_plan_id >=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThan(String value) { + addCriterion("test_plan_id <", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThanOrEqualTo(String value) { + addCriterion("test_plan_id <=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLike(String value) { + addCriterion("test_plan_id like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotLike(String value) { + addCriterion("test_plan_id not like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIn(List values) { + addCriterion("test_plan_id in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotIn(List values) { + addCriterion("test_plan_id not in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdBetween(String value1, String value2) { + addCriterion("test_plan_id between", value1, value2, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotBetween(String value1, String value2) { + addCriterion("test_plan_id not between", value1, value2, "testPlanId"); + return (Criteria) this; + } + + public Criteria andCaseIdIsNull() { + addCriterion("case_id is null"); + return (Criteria) this; + } + + public Criteria andCaseIdIsNotNull() { + addCriterion("case_id is not null"); + return (Criteria) this; + } + + public Criteria andCaseIdEqualTo(String value) { + addCriterion("case_id =", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdNotEqualTo(String value) { + addCriterion("case_id <>", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdGreaterThan(String value) { + addCriterion("case_id >", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdGreaterThanOrEqualTo(String value) { + addCriterion("case_id >=", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdLessThan(String value) { + addCriterion("case_id <", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdLessThanOrEqualTo(String value) { + addCriterion("case_id <=", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdLike(String value) { + addCriterion("case_id like", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdNotLike(String value) { + addCriterion("case_id not like", value, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdIn(List values) { + addCriterion("case_id in", values, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdNotIn(List values) { + addCriterion("case_id not in", values, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdBetween(String value1, String value2) { + addCriterion("case_id between", value1, value2, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseIdNotBetween(String value1, String value2) { + addCriterion("case_id not between", value1, value2, "caseId"); + return (Criteria) this; + } + + public Criteria andCaseTypeIsNull() { + addCriterion("case_type is null"); + return (Criteria) this; + } + + public Criteria andCaseTypeIsNotNull() { + addCriterion("case_type is not null"); + return (Criteria) this; + } + + public Criteria andCaseTypeEqualTo(String value) { + addCriterion("case_type =", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeNotEqualTo(String value) { + addCriterion("case_type <>", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeGreaterThan(String value) { + addCriterion("case_type >", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeGreaterThanOrEqualTo(String value) { + addCriterion("case_type >=", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeLessThan(String value) { + addCriterion("case_type <", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeLessThanOrEqualTo(String value) { + addCriterion("case_type <=", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeLike(String value) { + addCriterion("case_type like", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeNotLike(String value) { + addCriterion("case_type not like", value, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeIn(List values) { + addCriterion("case_type in", values, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeNotIn(List values) { + addCriterion("case_type not in", values, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeBetween(String value1, String value2) { + addCriterion("case_type between", value1, value2, "caseType"); + return (Criteria) this; + } + + public Criteria andCaseTypeNotBetween(String value1, String value2) { + addCriterion("case_type not between", value1, value2, "caseType"); + return (Criteria) this; + } + + public Criteria andBugIdIsNull() { + addCriterion("bug_id is null"); + return (Criteria) this; + } + + public Criteria andBugIdIsNotNull() { + addCriterion("bug_id is not null"); + return (Criteria) this; + } + + public Criteria andBugIdEqualTo(String value) { + addCriterion("bug_id =", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdNotEqualTo(String value) { + addCriterion("bug_id <>", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdGreaterThan(String value) { + addCriterion("bug_id >", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdGreaterThanOrEqualTo(String value) { + addCriterion("bug_id >=", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdLessThan(String value) { + addCriterion("bug_id <", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdLessThanOrEqualTo(String value) { + addCriterion("bug_id <=", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdLike(String value) { + addCriterion("bug_id like", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdNotLike(String value) { + addCriterion("bug_id not like", value, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdIn(List values) { + addCriterion("bug_id in", values, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdNotIn(List values) { + addCriterion("bug_id not in", values, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdBetween(String value1, String value2) { + addCriterion("bug_id between", value1, value2, "bugId"); + return (Criteria) this; + } + + public Criteria andBugIdNotBetween(String value1, String value2) { + addCriterion("bug_id not between", value1, value2, "bugId"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCase.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCase.java index 41de80dd79..7da0e1c9a2 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCase.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCase.java @@ -15,6 +15,9 @@ public class TestPlanFunctionalCase implements Serializable { @Size(min = 1, max = 50, message = "{test_plan_functional_case.id.length_range}", groups = {Created.class, Updated.class}) private String id; + @Schema(description = "num") + private Long num; + @Schema(description = "测试计划ID", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{test_plan_functional_case.test_plan_id.not_blank}", groups = {Created.class}) @Size(min = 1, max = 50, message = "{test_plan_functional_case.test_plan_id.length_range}", groups = {Created.class, Updated.class}) @@ -48,6 +51,7 @@ public class TestPlanFunctionalCase implements Serializable { public enum Column { id("id", "id", "VARCHAR", false), + num("num", "num", "BIGINT", false), testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), functionalCaseId("functional_case_id", "functionalCaseId", "VARCHAR", false), createTime("create_time", "createTime", "BIGINT", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCaseExample.java b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCaseExample.java index c163e177ed..f7ace1c399 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCaseExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/domain/TestPlanFunctionalCaseExample.java @@ -174,6 +174,66 @@ public class TestPlanFunctionalCaseExample { return (Criteria) this; } + public Criteria andNumIsNull() { + addCriterion("num is null"); + return (Criteria) this; + } + + public Criteria andNumIsNotNull() { + addCriterion("num is not null"); + return (Criteria) this; + } + + public Criteria andNumEqualTo(Long value) { + addCriterion("num =", value, "num"); + return (Criteria) this; + } + + public Criteria andNumNotEqualTo(Long value) { + addCriterion("num <>", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThan(Long value) { + addCriterion("num >", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThanOrEqualTo(Long value) { + addCriterion("num >=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThan(Long value) { + addCriterion("num <", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThanOrEqualTo(Long value) { + addCriterion("num <=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumIn(List values) { + addCriterion("num in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumNotIn(List values) { + addCriterion("num not in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumBetween(Long value1, Long value2) { + addCriterion("num between", value1, value2, "num"); + return (Criteria) this; + } + + public Criteria andNumNotBetween(Long value1, Long value2) { + addCriterion("num not between", value1, value2, "num"); + return (Criteria) this; + } + public Criteria andTestPlanIdIsNull() { addCriterion("test_plan_id is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiCaseMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiCaseMapper.xml index 9f2c96993e..1af9033e27 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiCaseMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiCaseMapper.xml @@ -3,6 +3,7 @@ + @@ -74,7 +75,7 @@ - id, test_plan_id, api_case_id, last_exec_result, last_exec_report_id, execute_user, + id, num, test_plan_id, api_case_id, last_exec_result, last_exec_report_id, execute_user, create_time, create_user, pos @@ -129,14 +130,14 @@ - insert into test_plan_api_case (id, test_plan_id, api_case_id, - last_exec_result, last_exec_report_id, execute_user, - create_time, create_user, pos, - environment_id) - values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{apiCaseId,jdbcType=VARCHAR}, - #{lastExecResult,jdbcType=VARCHAR}, #{lastExecReportId,jdbcType=VARCHAR}, #{executeUser,jdbcType=VARCHAR}, - #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, - #{environmentId,jdbcType=LONGVARCHAR}) + insert into test_plan_api_case (id, num, test_plan_id, + api_case_id, last_exec_result, last_exec_report_id, + execute_user, create_time, create_user, + pos, environment_id) + values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{testPlanId,jdbcType=VARCHAR}, + #{apiCaseId,jdbcType=VARCHAR}, #{lastExecResult,jdbcType=VARCHAR}, #{lastExecReportId,jdbcType=VARCHAR}, + #{executeUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, + #{pos,jdbcType=BIGINT}, #{environmentId,jdbcType=LONGVARCHAR}) insert into test_plan_api_case @@ -144,6 +145,9 @@ id, + + num, + test_plan_id, @@ -176,6 +180,9 @@ #{id,jdbcType=VARCHAR}, + + #{num,jdbcType=BIGINT}, + #{testPlanId,jdbcType=VARCHAR}, @@ -217,6 +224,9 @@ id = #{record.id,jdbcType=VARCHAR}, + + num = #{record.num,jdbcType=BIGINT}, + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, @@ -252,6 +262,7 @@ update test_plan_api_case set id = #{record.id,jdbcType=VARCHAR}, + num = #{record.num,jdbcType=BIGINT}, test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, api_case_id = #{record.apiCaseId,jdbcType=VARCHAR}, last_exec_result = #{record.lastExecResult,jdbcType=VARCHAR}, @@ -268,6 +279,7 @@ update test_plan_api_case set id = #{record.id,jdbcType=VARCHAR}, + num = #{record.num,jdbcType=BIGINT}, test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, api_case_id = #{record.apiCaseId,jdbcType=VARCHAR}, last_exec_result = #{record.lastExecResult,jdbcType=VARCHAR}, @@ -283,6 +295,9 @@ update test_plan_api_case + + num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, @@ -315,7 +330,8 @@ update test_plan_api_case - set test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + set num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, api_case_id = #{apiCaseId,jdbcType=VARCHAR}, last_exec_result = #{lastExecResult,jdbcType=VARCHAR}, last_exec_report_id = #{lastExecReportId,jdbcType=VARCHAR}, @@ -328,7 +344,8 @@ update test_plan_api_case - set test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + set num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, api_case_id = #{apiCaseId,jdbcType=VARCHAR}, last_exec_result = #{lastExecResult,jdbcType=VARCHAR}, last_exec_report_id = #{lastExecReportId,jdbcType=VARCHAR}, @@ -340,12 +357,12 @@ insert into test_plan_api_case - (id, test_plan_id, api_case_id, last_exec_result, last_exec_report_id, execute_user, + (id, num, test_plan_id, api_case_id, last_exec_result, last_exec_report_id, execute_user, create_time, create_user, pos, environment_id) values - (#{item.id,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.apiCaseId,jdbcType=VARCHAR}, - #{item.lastExecResult,jdbcType=VARCHAR}, #{item.lastExecReportId,jdbcType=VARCHAR}, + (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.testPlanId,jdbcType=VARCHAR}, + #{item.apiCaseId,jdbcType=VARCHAR}, #{item.lastExecResult,jdbcType=VARCHAR}, #{item.lastExecReportId,jdbcType=VARCHAR}, #{item.executeUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, #{item.environmentId,jdbcType=LONGVARCHAR}) @@ -363,6 +380,9 @@ #{item.id,jdbcType=VARCHAR} + + #{item.num,jdbcType=BIGINT} + #{item.testPlanId,jdbcType=VARCHAR} diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiScenarioMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiScenarioMapper.xml index 808c681c97..d0882a63c1 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiScenarioMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanApiScenarioMapper.xml @@ -3,6 +3,7 @@ + @@ -74,7 +75,7 @@ - id, test_plan_id, api_scenario_id, last_exec_result, last_exec_report_id, execute_user, + id, num, test_plan_id, api_scenario_id, last_exec_result, last_exec_report_id, execute_user, create_time, create_user, pos @@ -129,14 +130,14 @@ - insert into test_plan_api_scenario (id, test_plan_id, api_scenario_id, - last_exec_result, last_exec_report_id, execute_user, - create_time, create_user, pos, - environment_id) - values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{apiScenarioId,jdbcType=VARCHAR}, - #{lastExecResult,jdbcType=VARCHAR}, #{lastExecReportId,jdbcType=VARCHAR}, #{executeUser,jdbcType=VARCHAR}, - #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, - #{environmentId,jdbcType=LONGVARCHAR}) + insert into test_plan_api_scenario (id, num, test_plan_id, + api_scenario_id, last_exec_result, last_exec_report_id, + execute_user, create_time, create_user, + pos, environment_id) + values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{testPlanId,jdbcType=VARCHAR}, + #{apiScenarioId,jdbcType=VARCHAR}, #{lastExecResult,jdbcType=VARCHAR}, #{lastExecReportId,jdbcType=VARCHAR}, + #{executeUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, + #{pos,jdbcType=BIGINT}, #{environmentId,jdbcType=LONGVARCHAR}) insert into test_plan_api_scenario @@ -144,6 +145,9 @@ id, + + num, + test_plan_id, @@ -176,6 +180,9 @@ #{id,jdbcType=VARCHAR}, + + #{num,jdbcType=BIGINT}, + #{testPlanId,jdbcType=VARCHAR}, @@ -217,6 +224,9 @@ id = #{record.id,jdbcType=VARCHAR}, + + num = #{record.num,jdbcType=BIGINT}, + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, @@ -252,6 +262,7 @@ update test_plan_api_scenario set id = #{record.id,jdbcType=VARCHAR}, + num = #{record.num,jdbcType=BIGINT}, test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, api_scenario_id = #{record.apiScenarioId,jdbcType=VARCHAR}, last_exec_result = #{record.lastExecResult,jdbcType=VARCHAR}, @@ -268,6 +279,7 @@ update test_plan_api_scenario set id = #{record.id,jdbcType=VARCHAR}, + num = #{record.num,jdbcType=BIGINT}, test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, api_scenario_id = #{record.apiScenarioId,jdbcType=VARCHAR}, last_exec_result = #{record.lastExecResult,jdbcType=VARCHAR}, @@ -283,6 +295,9 @@ update test_plan_api_scenario + + num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, @@ -315,7 +330,8 @@ update test_plan_api_scenario - set test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + set num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, api_scenario_id = #{apiScenarioId,jdbcType=VARCHAR}, last_exec_result = #{lastExecResult,jdbcType=VARCHAR}, last_exec_report_id = #{lastExecReportId,jdbcType=VARCHAR}, @@ -328,7 +344,8 @@ update test_plan_api_scenario - set test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + set num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, api_scenario_id = #{apiScenarioId,jdbcType=VARCHAR}, last_exec_result = #{lastExecResult,jdbcType=VARCHAR}, last_exec_report_id = #{lastExecReportId,jdbcType=VARCHAR}, @@ -340,14 +357,15 @@ insert into test_plan_api_scenario - (id, test_plan_id, api_scenario_id, last_exec_result, last_exec_report_id, execute_user, + (id, num, test_plan_id, api_scenario_id, last_exec_result, last_exec_report_id, execute_user, create_time, create_user, pos, environment_id) values - (#{item.id,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.apiScenarioId,jdbcType=VARCHAR}, - #{item.lastExecResult,jdbcType=VARCHAR}, #{item.lastExecReportId,jdbcType=VARCHAR}, - #{item.executeUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, - #{item.pos,jdbcType=BIGINT}, #{item.environmentId,jdbcType=LONGVARCHAR}) + (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.testPlanId,jdbcType=VARCHAR}, + #{item.apiScenarioId,jdbcType=VARCHAR}, #{item.lastExecResult,jdbcType=VARCHAR}, + #{item.lastExecReportId,jdbcType=VARCHAR}, #{item.executeUser,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, + #{item.environmentId,jdbcType=LONGVARCHAR}) @@ -363,6 +381,9 @@ #{item.id,jdbcType=VARCHAR} + + #{item.num,jdbcType=BIGINT} + #{item.testPlanId,jdbcType=VARCHAR} diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanBugMapper.java b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanBugMapper.java new file mode 100644 index 0000000000..f2e89d3366 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanBugMapper.java @@ -0,0 +1,34 @@ +package io.metersphere.plan.mapper; + +import io.metersphere.plan.domain.TestPlanBug; +import io.metersphere.plan.domain.TestPlanBugExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface TestPlanBugMapper { + long countByExample(TestPlanBugExample example); + + int deleteByExample(TestPlanBugExample example); + + int deleteByPrimaryKey(String id); + + int insert(TestPlanBug record); + + int insertSelective(TestPlanBug record); + + List selectByExample(TestPlanBugExample example); + + TestPlanBug selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") TestPlanBug record, @Param("example") TestPlanBugExample example); + + int updateByExample(@Param("record") TestPlanBug record, @Param("example") TestPlanBugExample example); + + int updateByPrimaryKeySelective(TestPlanBug record); + + int updateByPrimaryKey(TestPlanBug record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") TestPlanBug.Column ... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanBugMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanBugMapper.xml new file mode 100644 index 0000000000..25b5ab8f93 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanBugMapper.xml @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, num, test_plan_id, case_id, case_type, bug_id, create_time, create_user + + + + + delete from test_plan_bug + where id = #{id,jdbcType=VARCHAR} + + + delete from test_plan_bug + + + + + + insert into test_plan_bug (id, num, test_plan_id, + case_id, case_type, bug_id, + create_time, create_user) + values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{testPlanId,jdbcType=VARCHAR}, + #{caseId,jdbcType=VARCHAR}, #{caseType,jdbcType=VARCHAR}, #{bugId,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}) + + + insert into test_plan_bug + + + id, + + + num, + + + test_plan_id, + + + case_id, + + + case_type, + + + bug_id, + + + create_time, + + + create_user, + + + + + #{id,jdbcType=VARCHAR}, + + + #{num,jdbcType=BIGINT}, + + + #{testPlanId,jdbcType=VARCHAR}, + + + #{caseId,jdbcType=VARCHAR}, + + + #{caseType,jdbcType=VARCHAR}, + + + #{bugId,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{createUser,jdbcType=VARCHAR}, + + + + + + update test_plan_bug + + + id = #{record.id,jdbcType=VARCHAR}, + + + num = #{record.num,jdbcType=BIGINT}, + + + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + + + case_id = #{record.caseId,jdbcType=VARCHAR}, + + + case_type = #{record.caseType,jdbcType=VARCHAR}, + + + bug_id = #{record.bugId,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + create_user = #{record.createUser,jdbcType=VARCHAR}, + + + + + + + + update test_plan_bug + set id = #{record.id,jdbcType=VARCHAR}, + num = #{record.num,jdbcType=BIGINT}, + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + case_id = #{record.caseId,jdbcType=VARCHAR}, + case_type = #{record.caseType,jdbcType=VARCHAR}, + bug_id = #{record.bugId,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR} + + + + + + update test_plan_bug + + + num = #{num,jdbcType=BIGINT}, + + + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + + + case_id = #{caseId,jdbcType=VARCHAR}, + + + case_type = #{caseType,jdbcType=VARCHAR}, + + + bug_id = #{bugId,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + create_user = #{createUser,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + update test_plan_bug + set num = #{num,jdbcType=BIGINT}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + case_id = #{caseId,jdbcType=VARCHAR}, + case_type = #{caseType,jdbcType=VARCHAR}, + bug_id = #{bugId,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + + + insert into test_plan_bug + (id, num, test_plan_id, case_id, case_type, bug_id, create_time, create_user) + values + + (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.testPlanId,jdbcType=VARCHAR}, + #{item.caseId,jdbcType=VARCHAR}, #{item.caseType,jdbcType=VARCHAR}, #{item.bugId,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}) + + + + insert into test_plan_bug ( + + ${column.escapedColumnName} + + ) + values + + ( + + + #{item.id,jdbcType=VARCHAR} + + + #{item.num,jdbcType=BIGINT} + + + #{item.testPlanId,jdbcType=VARCHAR} + + + #{item.caseId,jdbcType=VARCHAR} + + + #{item.caseType,jdbcType=VARCHAR} + + + #{item.bugId,jdbcType=VARCHAR} + + + #{item.createTime,jdbcType=BIGINT} + + + #{item.createUser,jdbcType=VARCHAR} + + + ) + + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanFunctionalCaseMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanFunctionalCaseMapper.xml index c6faecfa4f..723d9f6da9 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanFunctionalCaseMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/plan/mapper/TestPlanFunctionalCaseMapper.xml @@ -3,6 +3,7 @@ + @@ -71,8 +72,8 @@ - id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time, - last_exec_result, pos + id, num, test_plan_id, functional_case_id, create_time, create_user, execute_user, + last_exec_time, last_exec_result, pos SELECT - tpfc.*, tp.num as num, tp.status as planStatus, p.name as projectName + tpfc.*, tp.num as testPlanNum, tp.status as planStatus, p.name as projectName FROM test_plan_functional_case tpfc LEFT JOIN test_plan tp ON tpfc.test_plan_id = tp.id diff --git a/backend/services/case-management/src/test/resources/dml/init_test_plan_case.sql b/backend/services/case-management/src/test/resources/dml/init_test_plan_case.sql index 73576a7a6d..b137b329a1 100644 --- a/backend/services/case-management/src/test/resources/dml/init_test_plan_case.sql +++ b/backend/services/case-management/src/test/resources/dml/init_test_plan_case.sql @@ -15,6 +15,6 @@ INSERT INTO project(id, num, organization_id, name, description, create_time, up UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, false, null, true, null); -INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, create_time, create_user, last_exec_time, last_exec_result, pos) -VALUES ('associate_case_plan_gyq_one', 'test_plan_associate_case_gyq_one', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200), +INSERT INTO test_plan_functional_case(id,num, test_plan_id, functional_case_id, create_time, create_user, last_exec_time, last_exec_result, pos) +VALUES ('associate_case_plan_gyq_one', '123456','test_plan_associate_case_gyq_one', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200), ('associate_case_plan_gyq_two', 'test_plan_associate_case_gyq_two', 'gyq_associate_function_case', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'SUCCESS', 200); \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/uid/NumGenerator.java b/backend/services/system-setting/src/main/java/io/metersphere/system/uid/NumGenerator.java index 3880a5399b..0fa4a1a4c2 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/uid/NumGenerator.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/uid/NumGenerator.java @@ -25,7 +25,7 @@ public class NumGenerator { private static StringRedisTemplate stringRedisTemplate; private static ProjectMapper projectMapper; - private static final List SUB_NUM = List.of(ApplicationNumScope.API_TEST_CASE, ApplicationNumScope.API_MOCK); + private static final List SUB_NUM = List.of(ApplicationNumScope.API_TEST_CASE, ApplicationNumScope.API_MOCK, ApplicationNumScope.TEST_PLAN_FUNCTION_CASE, ApplicationNumScope.TEST_PLAN_API_CASE, ApplicationNumScope.TEST_PLAN_API_SCENARIO); /** * @param prefix 前缀: PROJECT_ID, 或者 PROJECT_ID + "_" + DOMAIN 例如接口用例的前缀为: 100001_12345 diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanApiCaseController.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanApiCaseController.java new file mode 100644 index 0000000000..c6a119ee17 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanApiCaseController.java @@ -0,0 +1,47 @@ +package io.metersphere.plan.controller; + +import io.metersphere.plan.dto.LogInsertModule; +import io.metersphere.plan.dto.request.ResourceSortRequest; +import io.metersphere.plan.dto.request.TestPlanAssociationRequest; +import io.metersphere.plan.dto.response.TestPlanAssociationResponse; +import io.metersphere.plan.dto.response.TestPlanResourceSortResponse; +import io.metersphere.plan.service.TestPlanApiCaseService; +import io.metersphere.sdk.constants.HttpMethodConstants; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.security.CheckOwner; +import io.metersphere.system.utils.SessionUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "测试计划接口用例") +@RestController +@RequestMapping("/test-plan/api/case") +public class TestPlanApiCaseController { + + @Resource + private TestPlanApiCaseService testPlanApiCaseService; + + @PostMapping(value = "/association") + @Operation(summary = "测试计划接口用例-关联接口用例") + @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE) + @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") + public TestPlanAssociationResponse association(@Validated @RequestBody TestPlanAssociationRequest request) { + return testPlanApiCaseService.association(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/case/association", HttpMethodConstants.POST.name())); + } + + @PostMapping(value = "/sort") + @Operation(summary = "测试计划接口用例-关联功能用例") + @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE) + @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") + public TestPlanResourceSortResponse sortNode(@Validated @RequestBody ResourceSortRequest request) { + return testPlanApiCaseService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/case/sort", HttpMethodConstants.POST.name())); + } + +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanApiScenarioController.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanApiScenarioController.java new file mode 100644 index 0000000000..b0af924b23 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanApiScenarioController.java @@ -0,0 +1,47 @@ +package io.metersphere.plan.controller; + +import io.metersphere.plan.dto.LogInsertModule; +import io.metersphere.plan.dto.request.ResourceSortRequest; +import io.metersphere.plan.dto.request.TestPlanAssociationRequest; +import io.metersphere.plan.dto.response.TestPlanAssociationResponse; +import io.metersphere.plan.dto.response.TestPlanResourceSortResponse; +import io.metersphere.plan.service.TestPlanApiScenarioService; +import io.metersphere.sdk.constants.HttpMethodConstants; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.security.CheckOwner; +import io.metersphere.system.utils.SessionUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "测试计划场景用例") +@RestController +@RequestMapping("/test-plan/api/scenario") +public class TestPlanApiScenarioController { + + @Resource + private TestPlanApiScenarioService testPlanApiScenarioService; + + @PostMapping(value = "/association") + @Operation(summary = "测试计划场景用例-关联接口用例") + @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE) + @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") + public TestPlanAssociationResponse association(@Validated @RequestBody TestPlanAssociationRequest request) { + return testPlanApiScenarioService.association(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/scenario/association", HttpMethodConstants.POST.name())); + } + + @PostMapping(value = "/sort") + @Operation(summary = "测试计划场景用例-关联功能用例") + @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE) + @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") + public TestPlanResourceSortResponse sortNode(@Validated @RequestBody ResourceSortRequest request) { + return testPlanApiScenarioService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/scenario/sort", HttpMethodConstants.POST.name())); + } + +} 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 cf734c20de..d35468cc19 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,5 +1,6 @@ package io.metersphere.plan.controller; +import io.metersphere.plan.dto.LogInsertModule; import io.metersphere.plan.dto.request.ResourceSortRequest; import io.metersphere.plan.dto.request.TestPlanAssociationRequest; import io.metersphere.plan.dto.response.TestPlanAssociationResponse; @@ -10,6 +11,7 @@ import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.security.CheckOwner; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.validation.annotation.Validated; @@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController +@Tag(name = "测试计划功能用例") @RequestMapping("/test-plan/functional/case") public class TestPlanFunctionalCaseController { @@ -26,19 +29,19 @@ public class TestPlanFunctionalCaseController { private TestPlanFunctionalCaseService testPlanFunctionalCaseService; @PostMapping(value = "/association") - @Operation(summary = "测试计划-关联功能用例") + @Operation(summary = "测试计划功能用例-关联功能用例") @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE) @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") public TestPlanAssociationResponse association(@Validated @RequestBody TestPlanAssociationRequest request) { - return testPlanFunctionalCaseService.association(request, SessionUtils.getUserId(), "/test-plan/functional/case/association", HttpMethodConstants.POST.name()); + return testPlanFunctionalCaseService.association(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/functional/case/association", HttpMethodConstants.POST.name())); } @PostMapping(value = "/sort") - @Operation(summary = "测试计划-关联功能用例") + @Operation(summary = "测试计划功能用例-关联功能用例") @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE) @CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan") public TestPlanResourceSortResponse sortNode(@Validated @RequestBody ResourceSortRequest request) { - return testPlanFunctionalCaseService.sortNode(request, SessionUtils.getUserId(), "/test-plan/functional/case/sort", HttpMethodConstants.POST.name()); + return testPlanFunctionalCaseService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/functional/case/sort", HttpMethodConstants.POST.name())); } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/LogInsertModule.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/LogInsertModule.java new file mode 100644 index 0000000000..cea789d0f8 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/LogInsertModule.java @@ -0,0 +1,19 @@ +package io.metersphere.plan.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +//用于记录模块的DTO +@Data +@AllArgsConstructor +@NoArgsConstructor +public class LogInsertModule { + @NotBlank + private String operator; + @NotBlank + private String requestUrl; + @NotBlank + private String requestMethod; +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ResourceLogInsertModule.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ResourceLogInsertModule.java new file mode 100644 index 0000000000..47da371b2b --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ResourceLogInsertModule.java @@ -0,0 +1,17 @@ +package io.metersphere.plan.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class ResourceLogInsertModule extends LogInsertModule { + @NotBlank + private String resourceType; + + public ResourceLogInsertModule(String resourceType, LogInsertModule logInsertModule) { + this.resourceType = resourceType; + this.setOperator(logInsertModule.getOperator()); + this.setRequestUrl(logInsertModule.getRequestUrl()); + this.setRequestMethod(logInsertModule.getRequestMethod()); + } +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ResourceSelectParam.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ResourceSelectParam.java new file mode 100644 index 0000000000..703703a2b2 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/ResourceSelectParam.java @@ -0,0 +1,18 @@ +package io.metersphere.plan.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ResourceSelectParam { + private String testPlanId; + private List selectIds; + private List moduleIds; + private boolean repeatCase; + private String orderString; +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanResourceAssociationParam.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanResourceAssociationParam.java new file mode 100644 index 0000000000..9b07e8ac27 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanResourceAssociationParam.java @@ -0,0 +1,23 @@ +package io.metersphere.plan.dto; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +@Data +@AllArgsConstructor +public class TestPlanResourceAssociationParam { + @NotEmpty + private List resourceIdList; + @NotBlank + private String projectId; + @NotBlank + private String testPlanId; + @NotBlank + private Long testPlanNum; + @NotBlank + private String operator; +} 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 new file mode 100644 index 0000000000..2065fade1e --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java @@ -0,0 +1,25 @@ +package io.metersphere.plan.mapper; + +import io.metersphere.plan.dto.AssociationNode; +import io.metersphere.plan.dto.ResourceSelectParam; +import io.metersphere.project.dto.NodeSortQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtTestPlanApiCaseMapper { + + long updatePos(@Param("id") String id, @Param("pos") long pos); + + List selectIdByTestPlanIdOrderByPos(String testPlanId); + + Long getMaxPosByTestPlanId(String testPlanId); + + List getIdByIds(ResourceSelectParam resourceSelectParam); + + List getIdByModuleIds(ResourceSelectParam resourceSelectParam); + + AssociationNode selectDragInfoById(String id); + + AssociationNode selectNodeByPosOperator(NodeSortQueryParam nodeSortQueryParam); +} 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 new file mode 100644 index 0000000000..627b7728a6 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml @@ -0,0 +1,80 @@ + + + + + UPDATE + test_plan_api_case + SET pos =#{pos} + WHERE id = #{id} + + + + + + + + \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.java new file mode 100644 index 0000000000..6079a40228 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.java @@ -0,0 +1,25 @@ +package io.metersphere.plan.mapper; + +import io.metersphere.plan.dto.AssociationNode; +import io.metersphere.plan.dto.ResourceSelectParam; +import io.metersphere.project.dto.NodeSortQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtTestPlanApiScenarioMapper { + + long updatePos(@Param("id") String id, @Param("pos") long pos); + + List selectIdByTestPlanIdOrderByPos(String testPlanId); + + Long getMaxPosByTestPlanId(String testPlanId); + + List getIdByIds(ResourceSelectParam resourceSelectParam); + + List getIdByModuleIds(ResourceSelectParam resourceSelectParam); + + AssociationNode selectDragInfoById(String id); + + AssociationNode selectNodeByPosOperator(NodeSortQueryParam nodeSortQueryParam); +} 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 new file mode 100644 index 0000000000..f8a0ad2c63 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml @@ -0,0 +1,80 @@ + + + + + UPDATE + test_plan_api_scenario + SET pos =#{pos} + WHERE id = #{id} + + + + + + + + \ No newline at end of file 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 3d7f8b44e1..5fb21ea059 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 @@ -1,6 +1,7 @@ package io.metersphere.plan.mapper; import io.metersphere.plan.dto.AssociationNode; +import io.metersphere.plan.dto.ResourceSelectParam; import io.metersphere.project.dto.NodeSortQueryParam; import org.apache.ibatis.annotations.Param; @@ -14,9 +15,9 @@ public interface ExtTestPlanFunctionalCaseMapper { Long getMaxPosByTestPlanId(String testPlanId); - List getIdByIds(@Param("selectIds") List selectIds, @Param("testPlanId") String testPlanId, @Param("repeatCase") boolean repeatCase, @Param("orderString") String orderString); + List getIdByIds(ResourceSelectParam resourceSelectParam); - List getIdByModuleIds(@Param("moduleIds") List selectModuleIds, @Param("testPlanId") String testPlanId, @Param("repeatCase") boolean repeatCase, @Param("orderString") String orderString); + List getIdByModuleIds(ResourceSelectParam resourceSelectParam); AssociationNode selectDragInfoById(String id); 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 d9706cba25..105c4a93cf 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 @@ -18,7 +18,9 @@ FROM test_plan_functional_case WHERE test_plan_id = #{0} - SELECT id FROM functional_case WHERE deleted = false @@ -34,7 +36,9 @@ ORDER BY #{orderString} - SELECT id FROM functional_case WHERE deleted = false diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java index 7365a69cf5..78149f7020 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java @@ -1,32 +1,136 @@ package io.metersphere.plan.service; +import io.metersphere.plan.domain.TestPlan; import io.metersphere.plan.domain.TestPlanApiCase; import io.metersphere.plan.domain.TestPlanApiCaseExample; -import io.metersphere.plan.dto.TestPlanApiCaseDTO; +import io.metersphere.plan.dto.AssociationNodeSortDTO; +import io.metersphere.plan.dto.LogInsertModule; +import io.metersphere.plan.dto.ResourceLogInsertModule; +import io.metersphere.plan.dto.TestPlanResourceAssociationParam; +import io.metersphere.plan.dto.request.ResourceSortRequest; +import io.metersphere.plan.dto.request.TestPlanAssociationRequest; +import io.metersphere.plan.dto.response.TestPlanAssociationResponse; +import io.metersphere.plan.dto.response.TestPlanResourceSortResponse; +import io.metersphere.plan.mapper.ExtTestPlanApiCaseMapper; import io.metersphere.plan.mapper.TestPlanApiCaseMapper; -import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.plan.mapper.TestPlanConfigMapper; +import io.metersphere.plan.mapper.TestPlanMapper; +import io.metersphere.sdk.constants.ApplicationNumScope; +import io.metersphere.sdk.constants.TestPlanResourceConstants; +import io.metersphere.sdk.exception.MSException; +import io.metersphere.system.uid.IDGenerator; +import io.metersphere.system.uid.NumGenerator; import jakarta.annotation.Resource; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import java.util.ArrayList; import java.util.List; @Service @Transactional(rollbackFor = Exception.class) -public class TestPlanApiCaseService { - +public class TestPlanApiCaseService extends TestPlanResourceService { @Resource - TestPlanApiCaseMapper testPlanApiCaseMapper; - - public int deleteByTestPlanId(String testPlanId) { - TestPlanApiCaseExample example = new TestPlanApiCaseExample(); - example.createCriteria().andTestPlanIdEqualTo(testPlanId); - return testPlanApiCaseMapper.deleteByExample(example); - } + private SqlSessionFactory sqlSessionFactory; + @Resource + private TestPlanApiCaseMapper testPlanApiCaseMapper; + @Resource + private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper; + @Resource + private TestPlanConfigMapper testPlanConfigMapper; + @Resource + private TestPlanResourceLogService testPlanResourceLogService; + @Resource + private TestPlanMapper testPlanMapper; + @Override public int deleteBatchByTestPlanId(List testPlanIdList) { TestPlanApiCaseExample example = new TestPlanApiCaseExample(); example.createCriteria().andTestPlanIdIn(testPlanIdList); return testPlanApiCaseMapper.deleteByExample(example); } + + @Override + public long getNextOrder(String testPlanId) { + Long maxPos = extTestPlanApiCaseMapper.getMaxPosByTestPlanId(testPlanId); + if (maxPos == null) { + return 0; + } else { + return maxPos + DEFAULT_NODE_INTERVAL_POS; + } + } + + @Override + public void updatePos(String id, long pos) { + extTestPlanApiCaseMapper.updatePos(id, pos); + } + + @Override + public void refreshPos(String testPlanId) { + List caseIdList = extTestPlanApiCaseMapper.selectIdByTestPlanIdOrderByPos(testPlanId); + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + ExtTestPlanApiCaseMapper batchUpdateMapper = sqlSession.getMapper(ExtTestPlanApiCaseMapper.class); + for (int i = 0; i < caseIdList.size(); i++) { + batchUpdateMapper.updatePos(caseIdList.get(i), i * DEFAULT_NODE_INTERVAL_POS); + } + sqlSession.flushStatements(); + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + } + + public TestPlanAssociationResponse association(TestPlanAssociationRequest request, LogInsertModule logInsertModule) { + return super.association( + TestPlanResourceConstants.RESOURCE_API_CASE, + request, + logInsertModule, + extTestPlanApiCaseMapper::getIdByIds, + extTestPlanApiCaseMapper::getIdByModuleIds, + this::saveTestPlanResource); + } + + private void saveTestPlanResource(@Validated TestPlanResourceAssociationParam associationParam) { + long pox = this.getNextOrder(associationParam.getTestPlanId()); + long now = System.currentTimeMillis(); + List testPlanResourceList = new ArrayList<>(); + List associationIdList = associationParam.getResourceIdList(); + for (int i = 0; i < associationIdList.size(); i++) { + TestPlanApiCase testPlanResourceCase = new TestPlanApiCase(); + testPlanResourceCase.setId(IDGenerator.nextStr()); + testPlanResourceCase.setNum(NumGenerator.nextNum(associationParam.getTestPlanNum() + "_" + associationParam.getProjectId(), ApplicationNumScope.TEST_PLAN_API_CASE)); + testPlanResourceCase.setTestPlanId(associationParam.getTestPlanId()); + testPlanResourceCase.setApiCaseId(associationIdList.get(i)); + testPlanResourceCase.setPos(pox + (i + 1) * DEFAULT_NODE_INTERVAL_POS); + testPlanResourceCase.setCreateTime(now); + testPlanResourceCase.setCreateUser(associationParam.getOperator()); + testPlanResourceCase.setExecuteUser(associationParam.getOperator()); + testPlanResourceList.add(testPlanResourceCase); + } + testPlanApiCaseMapper.batchInsert(testPlanResourceList); + } + + public TestPlanResourceSortResponse sortNode(ResourceSortRequest request, LogInsertModule logInsertModule) { + TestPlanResourceSortResponse response = new TestPlanResourceSortResponse(); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); + TestPlanApiCase dragNode = testPlanApiCaseMapper.selectByPrimaryKey(request.getDragNodeId()); + if (dragNode == null && testPlan == null) { + throw new MSException("test_plan.drag.node.error"); + } + if (request.getDropPosition() == -1 || request.getDropPosition() == 1) { + AssociationNodeSortDTO sortDTO = super.getNodeSortDTO( + request, + extTestPlanApiCaseMapper::selectDragInfoById, + extTestPlanApiCaseMapper::selectNodeByPosOperator + ); + this.sort(sortDTO); + response.setSortNodeNum(1); + testPlanResourceLogService.saveSortLog(testPlan, request.getDragNodeId(), new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_API_CASE, logInsertModule)); + } else { + throw new MSException("test_plan.drag.position.error"); + } + return response; + } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java index bc88237fc6..a3926b8802 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java @@ -1,28 +1,133 @@ package io.metersphere.plan.service; +import io.metersphere.plan.domain.TestPlan; +import io.metersphere.plan.domain.TestPlanApiScenario; import io.metersphere.plan.domain.TestPlanApiScenarioExample; -import io.metersphere.plan.mapper.TestPlanApiScenarioMapper; +import io.metersphere.plan.dto.AssociationNodeSortDTO; +import io.metersphere.plan.dto.LogInsertModule; +import io.metersphere.plan.dto.ResourceLogInsertModule; +import io.metersphere.plan.dto.TestPlanResourceAssociationParam; +import io.metersphere.plan.dto.request.ResourceSortRequest; +import io.metersphere.plan.dto.request.TestPlanAssociationRequest; +import io.metersphere.plan.dto.response.TestPlanAssociationResponse; +import io.metersphere.plan.dto.response.TestPlanResourceSortResponse; +import io.metersphere.plan.mapper.*; +import io.metersphere.sdk.constants.ApplicationNumScope; +import io.metersphere.sdk.constants.TestPlanResourceConstants; +import io.metersphere.sdk.exception.MSException; +import io.metersphere.system.uid.IDGenerator; +import io.metersphere.system.uid.NumGenerator; import jakarta.annotation.Resource; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import java.util.ArrayList; import java.util.List; @Service @Transactional(rollbackFor = Exception.class) -public class TestPlanApiScenarioService { +public class TestPlanApiScenarioService extends TestPlanResourceService { + @Resource + private SqlSessionFactory sqlSessionFactory; @Resource private TestPlanApiScenarioMapper testPlanApiScenarioMapper; + @Resource + private ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper; + @Resource + private TestPlanConfigMapper testPlanConfigMapper; + @Resource + private TestPlanResourceLogService testPlanResourceLogService; + @Resource + private TestPlanMapper testPlanMapper; - public int deleteByTestPlanId(String testPlanId) { - TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); - example.createCriteria().andTestPlanIdEqualTo(testPlanId); - return testPlanApiScenarioMapper.deleteByExample(example); - } - + @Override public int deleteBatchByTestPlanId(List testPlanIdList) { TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); example.createCriteria().andTestPlanIdIn(testPlanIdList); return testPlanApiScenarioMapper.deleteByExample(example); } + + @Override + public long getNextOrder(String testPlanId) { + Long maxPos = extTestPlanApiScenarioMapper.getMaxPosByTestPlanId(testPlanId); + if (maxPos == null) { + return 0; + } else { + return maxPos + DEFAULT_NODE_INTERVAL_POS; + } + } + + @Override + public void updatePos(String id, long pos) { + extTestPlanApiScenarioMapper.updatePos(id, pos); + } + + @Override + public void refreshPos(String testPlanId) { + List caseIdList = extTestPlanApiScenarioMapper.selectIdByTestPlanIdOrderByPos(testPlanId); + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + ExtTestPlanApiCaseMapper batchUpdateMapper = sqlSession.getMapper(ExtTestPlanApiCaseMapper.class); + for (int i = 0; i < caseIdList.size(); i++) { + batchUpdateMapper.updatePos(caseIdList.get(i), i * DEFAULT_NODE_INTERVAL_POS); + } + sqlSession.flushStatements(); + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + } + + public TestPlanAssociationResponse association(TestPlanAssociationRequest request, LogInsertModule logInsertModule) { + return super.association( + TestPlanResourceConstants.RESOURCE_API_CASE, + request, + logInsertModule, + extTestPlanApiScenarioMapper::getIdByIds, + extTestPlanApiScenarioMapper::getIdByModuleIds, + this::saveTestPlanResource); + } + + private void saveTestPlanResource(@Validated TestPlanResourceAssociationParam associationParam) { + long pox = this.getNextOrder(associationParam.getTestPlanId()); + long now = System.currentTimeMillis(); + List testPlanResourceList = new ArrayList<>(); + List associationIdList = associationParam.getResourceIdList(); + for (int i = 0; i < associationIdList.size(); i++) { + TestPlanApiScenario testPlanResourceCase = new TestPlanApiScenario(); + testPlanResourceCase.setId(IDGenerator.nextStr()); + testPlanResourceCase.setNum(NumGenerator.nextNum(associationParam.getTestPlanNum() + "_" + associationParam.getProjectId(), ApplicationNumScope.TEST_PLAN_API_SCENARIO)); + testPlanResourceCase.setTestPlanId(associationParam.getTestPlanId()); + testPlanResourceCase.setApiScenarioId(associationIdList.get(i)); + testPlanResourceCase.setPos(pox + (i + 1) * DEFAULT_NODE_INTERVAL_POS); + testPlanResourceCase.setCreateTime(now); + testPlanResourceCase.setCreateUser(associationParam.getOperator()); + testPlanResourceCase.setExecuteUser(associationParam.getOperator()); + testPlanResourceList.add(testPlanResourceCase); + } + testPlanApiScenarioMapper.batchInsert(testPlanResourceList); + } + + public TestPlanResourceSortResponse sortNode(ResourceSortRequest request, LogInsertModule logInsertModule) { + TestPlanResourceSortResponse response = new TestPlanResourceSortResponse(); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); + TestPlanApiScenario dragNode = testPlanApiScenarioMapper.selectByPrimaryKey(request.getDragNodeId()); + if (dragNode == null && testPlan == null) { + throw new MSException("test_plan.drag.node.error"); + } + if (request.getDropPosition() == -1 || request.getDropPosition() == 1) { + AssociationNodeSortDTO sortDTO = super.getNodeSortDTO( + request, + extTestPlanApiScenarioMapper::selectDragInfoById, + extTestPlanApiScenarioMapper::selectNodeByPosOperator + ); + this.sort(sortDTO); + response.setSortNodeNum(1); + testPlanResourceLogService.saveSortLog(testPlan, request.getDragNodeId(), new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_API_CASE, logInsertModule)); + } else { + throw new MSException("test_plan.drag.position.error"); + } + return response; + } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java new file mode 100644 index 0000000000..8bbdae7baa --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java @@ -0,0 +1,43 @@ +package io.metersphere.plan.service; + +import io.metersphere.plan.domain.TestPlanBugExample; +import io.metersphere.plan.mapper.TestPlanBugMapper; +import jakarta.annotation.Resource; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TestPlanBugService extends TestPlanResourceService { + @Resource + private TestPlanBugMapper testPlanBugMapper; + + @Override + public int deleteBatchByTestPlanId(List testPlanIdList) { + if (CollectionUtils.isEmpty(testPlanIdList)) { + return 0; + } + TestPlanBugExample example = new TestPlanBugExample(); + example.createCriteria().andTestPlanIdIn(testPlanIdList); + return testPlanBugMapper.deleteByExample(example); + } + + @Override + public long getNextOrder(String testPlanId) { + return 0; + } + + @Override + public void updatePos(String id, long pos) { + + } + + @Override + public void refreshPos(String testPlanId) { + + } + +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index faae8cb528..dc20c68410 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -1,10 +1,12 @@ package io.metersphere.plan.service; import io.metersphere.plan.domain.TestPlan; -import io.metersphere.plan.domain.TestPlanConfig; import io.metersphere.plan.domain.TestPlanFunctionalCase; import io.metersphere.plan.domain.TestPlanFunctionalCaseExample; import io.metersphere.plan.dto.AssociationNodeSortDTO; +import io.metersphere.plan.dto.LogInsertModule; +import io.metersphere.plan.dto.ResourceLogInsertModule; +import io.metersphere.plan.dto.TestPlanResourceAssociationParam; import io.metersphere.plan.dto.request.ResourceSortRequest; import io.metersphere.plan.dto.request.TestPlanAssociationRequest; import io.metersphere.plan.dto.response.TestPlanAssociationResponse; @@ -13,17 +15,19 @@ import io.metersphere.plan.mapper.ExtTestPlanFunctionalCaseMapper; import io.metersphere.plan.mapper.TestPlanConfigMapper; import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper; import io.metersphere.plan.mapper.TestPlanMapper; +import io.metersphere.sdk.constants.ApplicationNumScope; import io.metersphere.sdk.constants.TestPlanResourceConstants; import io.metersphere.sdk.exception.MSException; import io.metersphere.system.uid.IDGenerator; +import io.metersphere.system.uid.NumGenerator; import jakarta.annotation.Resource; -import org.apache.commons.collections4.CollectionUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; import java.util.ArrayList; import java.util.List; @@ -44,6 +48,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { @Resource private TestPlanMapper testPlanMapper; + @Override public int deleteBatchByTestPlanId(List testPlanIdList) { TestPlanFunctionalCaseExample example = new TestPlanFunctionalCaseExample(); example.createCriteria().andTestPlanIdIn(testPlanIdList); @@ -77,73 +82,51 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } - public TestPlanAssociationResponse association(TestPlanAssociationRequest request, String operator, String requestUrl, String requestMethod) { - TestPlanAssociationResponse response = new TestPlanAssociationResponse(); - if (request.isEmpty()) { - return response; - } - TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); - TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(request.getTestPlanId()); - boolean repeatCase = testPlanConfig.getRepeatCase(); - List associationIdList = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(request.getSelectIds())) { - //获取有效ID - associationIdList.addAll(extTestPlanFunctionalCaseMapper.getIdByIds(request.getSelectIds(), request.getTestPlanId(), repeatCase, request.getOrderString())); - } - if (CollectionUtils.isNotEmpty(request.getSelectModuleIds())) { - //获取有效ID - associationIdList.addAll(extTestPlanFunctionalCaseMapper.getIdByModuleIds(request.getSelectModuleIds(), request.getTestPlanId(), repeatCase, request.getOrderString())); - } - associationIdList = new ArrayList<>(associationIdList.stream().distinct().toList()); - associationIdList.removeAll(request.getExcludeIds()); - - this.saveTestPlanResource(associationIdList, request.getTestPlanId(), operator); - response.setAssociationCount(associationIdList.size()); - - testPlanResourceLogService.saveAddLog(testPlan, TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, operator, requestUrl, requestMethod); - return response; + public TestPlanAssociationResponse association(TestPlanAssociationRequest request, LogInsertModule logInsertModule) { + return super.association( + TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, + request, + logInsertModule, + extTestPlanFunctionalCaseMapper::getIdByIds, + extTestPlanFunctionalCaseMapper::getIdByModuleIds, + this::saveTestPlanResource); } - private void saveTestPlanResource(List associationIdList, String testPlanId, String operator) { - if (CollectionUtils.isEmpty(associationIdList)) { - return; - } - long pox = this.getNextOrder(testPlanId); + private void saveTestPlanResource(@Validated TestPlanResourceAssociationParam associationParam) { + long pox = this.getNextOrder(associationParam.getTestPlanId()); long now = System.currentTimeMillis(); List testPlanFunctionalCaseList = new ArrayList<>(); + List associationIdList = associationParam.getResourceIdList(); for (int i = 0; i < associationIdList.size(); i++) { TestPlanFunctionalCase testPlanFunctionalCase = new TestPlanFunctionalCase(); testPlanFunctionalCase.setId(IDGenerator.nextStr()); - testPlanFunctionalCase.setTestPlanId(testPlanId); + testPlanFunctionalCase.setNum(NumGenerator.nextNum(associationParam.getTestPlanNum() + "_" + associationParam.getProjectId(), ApplicationNumScope.TEST_PLAN_FUNCTION_CASE)); + testPlanFunctionalCase.setTestPlanId(associationParam.getTestPlanId()); testPlanFunctionalCase.setFunctionalCaseId(associationIdList.get(i)); testPlanFunctionalCase.setPos(pox + (i + 1) * DEFAULT_NODE_INTERVAL_POS); testPlanFunctionalCase.setCreateTime(now); - testPlanFunctionalCase.setCreateUser(operator); - testPlanFunctionalCase.setExecuteUser(operator); + testPlanFunctionalCase.setCreateUser(associationParam.getOperator()); + testPlanFunctionalCase.setExecuteUser(associationParam.getOperator()); testPlanFunctionalCaseList.add(testPlanFunctionalCase); } testPlanFunctionalCaseMapper.batchInsert(testPlanFunctionalCaseList); } - public TestPlanResourceSortResponse sortNode(ResourceSortRequest request, String userId, String requestUrl, String requestMethod) { - TestPlanResourceSortResponse response = new TestPlanResourceSortResponse(); - if (request.getDropPosition() == -1 || request.getDropPosition() == 1) { - TestPlanFunctionalCase dragNode = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getDragNodeId()); - TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); - if (dragNode == null && testPlan == null) { - throw new MSException("test_plan.drag.node.error"); - } - AssociationNodeSortDTO sortDTO = super.getNodeSortDTO( - request, - extTestPlanFunctionalCaseMapper::selectDragInfoById, - extTestPlanFunctionalCaseMapper::selectNodeByPosOperator - ); - this.sort(sortDTO); - response.setSortNodeNum(1); - testPlanResourceLogService.saveSortLog(testPlan, request.getDragNodeId(), TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, userId, requestUrl, requestMethod); - } else { - throw new MSException("test_plan.drag.position.error"); + public TestPlanResourceSortResponse sortNode(ResourceSortRequest request, LogInsertModule logInsertModule) { + TestPlanFunctionalCase dragNode = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getDragNodeId()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); + if (dragNode == null && testPlan == null) { + throw new MSException("test_plan.drag.node.error"); } + TestPlanResourceSortResponse response = new TestPlanResourceSortResponse(); + AssociationNodeSortDTO sortDTO = super.getNodeSortDTO( + request, + extTestPlanFunctionalCaseMapper::selectDragInfoById, + extTestPlanFunctionalCaseMapper::selectNodeByPosOperator + ); + super.sort(sortDTO); + response.setSortNodeNum(1); + testPlanResourceLogService.saveSortLog(testPlan, request.getDragNodeId(), new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, logInsertModule)); return response; } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java index 67daa69140..db2006ff86 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java @@ -1,6 +1,7 @@ package io.metersphere.plan.service; import io.metersphere.plan.domain.TestPlan; +import io.metersphere.plan.dto.ResourceLogInsertModule; import io.metersphere.project.domain.Project; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.util.Translator; @@ -13,6 +14,7 @@ import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; @Service @Transactional(rollbackFor = Exception.class) @@ -37,50 +39,50 @@ public class TestPlanResourceLogService { return content.toString(); } - public void saveAddLog(TestPlan module, String resourceType, String operator, String requestUrl, String requestMethod) { + public void saveAddLog(TestPlan module, @Validated ResourceLogInsertModule logInsertModule) { Project project = projectMapper.selectByPrimaryKey(module.getProjectId()); LogDTO dto = LogDTOBuilder.builder() .projectId(module.getProjectId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.ADD.name()) .module(logModule) - .method(requestMethod) - .path(requestUrl) + .method(logInsertModule.getRequestMethod()) + .path(logInsertModule.getRequestUrl()) .sourceId(module.getId()) - .content(generateContent(module.getName(), resourceType, "add")) - .createUser(operator) + .content(generateContent(module.getName(), logInsertModule.getResourceType(), "add")) + .createUser(logInsertModule.getOperator()) .build().getLogDTO(); operationLogService.add(dto); } - public void saveDeleteLog(TestPlan module, String resourceType, String operator, String requestUrl, String requestMethod) { + public void saveDeleteLog(TestPlan module, @Validated ResourceLogInsertModule logInsertModule) { Project project = projectMapper.selectByPrimaryKey(module.getProjectId()); LogDTO dto = LogDTOBuilder.builder() .projectId(module.getProjectId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.DELETE.name()) .module(logModule) - .method(requestMethod) - .path(requestUrl) + .method(logInsertModule.getRequestMethod()) + .path(logInsertModule.getRequestUrl()) .sourceId(module.getId()) - .content(generateContent(module.getName(), resourceType, "remove")) - .createUser(operator) + .content(generateContent(module.getName(), logInsertModule.getResourceType(), "remove")) + .createUser(logInsertModule.getOperator()) .build().getLogDTO(); operationLogService.add(dto); } - public void saveSortLog(TestPlan testPlan, String resourceId, String resourceType, String operator, String requestUrl, String requestMethod) { + public void saveSortLog(TestPlan testPlan, String resourceId, @Validated ResourceLogInsertModule logInsertModule) { Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId()); LogDTO dto = LogDTOBuilder.builder() .projectId(testPlan.getProjectId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.UPDATE.name()) .module(logModule) - .method(requestMethod) - .path(requestUrl) + .method(logInsertModule.getRequestMethod()) + .path(logInsertModule.getRequestUrl()) .sourceId(resourceId) - .content(generateContent(testPlan.getName(), resourceType, "move")) - .createUser(operator) + .content(generateContent(testPlan.getName(), logInsertModule.getResourceType(), "move")) + .createUser(logInsertModule.getOperator()) .build().getLogDTO(); operationLogService.add(dto); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java index e39baf660b..e7aa10dc32 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java @@ -1,18 +1,28 @@ package io.metersphere.plan.service; -import io.metersphere.plan.dto.AssociationNode; -import io.metersphere.plan.dto.AssociationNodeSortDTO; +import io.metersphere.plan.domain.TestPlan; +import io.metersphere.plan.domain.TestPlanConfig; +import io.metersphere.plan.dto.*; import io.metersphere.plan.dto.request.ResourceSortRequest; +import io.metersphere.plan.dto.request.TestPlanAssociationRequest; +import io.metersphere.plan.dto.response.TestPlanAssociationResponse; +import io.metersphere.plan.mapper.TestPlanConfigMapper; +import io.metersphere.plan.mapper.TestPlanMapper; import io.metersphere.project.dto.ModuleSortCountResultDTO; import io.metersphere.project.dto.NodeSortQueryParam; import io.metersphere.project.utils.NodeSortUtils; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.Translator; +import jakarta.annotation.Resource; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; import java.util.function.Function; //测试计划关联表 通用方法 @@ -20,6 +30,13 @@ import java.util.function.Function; @Transactional(rollbackFor = Exception.class) public abstract class TestPlanResourceService { + @Resource + private TestPlanMapper testPlanMapper; + @Resource + private TestPlanConfigMapper testPlanConfigMapper; + @Resource + private TestPlanResourceLogService testPlanResourceLogService; + protected static final long DEFAULT_NODE_INTERVAL_POS = NodeSortUtils.DEFAULT_NODE_INTERVAL_POS; public abstract long getNextOrder(String testPlanId); @@ -32,9 +49,51 @@ public abstract class TestPlanResourceService { private static final String MOVE_POS_OPERATOR_LESS = "lessThan"; private static final String MOVE_POS_OPERATOR_MORE = "moreThan"; - private static final String MOVE_POS_OPERATOR_LATEST = "latest"; private static final String DRAG_NODE_NOT_EXIST = "drag_node.not.exist"; + /** + * 关联资源od + * + * @return + */ + public TestPlanAssociationResponse association( + String resourceType, + TestPlanAssociationRequest request, + @Validated LogInsertModule logInsertModule, + Function> selectByResourceIdFunc, + Function> selectByModuleIdFunc, + Consumer saveResourceFunc) { + TestPlanAssociationResponse response = new TestPlanAssociationResponse(); + if (request.isEmpty()) { + return response; + } + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); + TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(request.getTestPlanId()); + boolean repeatCase = testPlanConfig.getRepeatCase(); + List associationIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(request.getSelectIds())) { + //获取有效ID + associationIdList.addAll( + selectByResourceIdFunc.apply( + new ResourceSelectParam(request.getTestPlanId(), request.getSelectIds(), null, repeatCase, request.getOrderString()))); + } + if (CollectionUtils.isNotEmpty(request.getSelectModuleIds())) { + //获取有效ID + associationIdList.addAll( + selectByModuleIdFunc.apply( + new ResourceSelectParam(request.getTestPlanId(), null, request.getSelectModuleIds(), repeatCase, request.getOrderString()))); + } + associationIdList = new ArrayList<>(associationIdList.stream().distinct().toList()); + associationIdList.removeAll(request.getExcludeIds()); + if (CollectionUtils.isNotEmpty(associationIdList)) { + TestPlanResourceAssociationParam associationParam = new TestPlanResourceAssociationParam(associationIdList, testPlan.getProjectId(), testPlan.getId(), testPlan.getNum(), logInsertModule.getOperator()); + saveResourceFunc.accept(associationParam); + response.setAssociationCount(associationIdList.size()); + testPlanResourceLogService.saveAddLog(testPlan, new ResourceLogInsertModule(resourceType, logInsertModule)); + } + return response; + } + /** * 构建节点排序的参数 * @@ -59,8 +118,8 @@ public abstract class TestPlanResourceService { throw new MSException(Translator.get(DRAG_NODE_NOT_EXIST) + ":" + request.getDropNodeId()); } - AssociationNode previousNode = null; - AssociationNode nextNode = null; + AssociationNode previousNode; + AssociationNode nextNode; if (request.getDropPosition() == 1) { //dropPosition=1: 放到dropNode节点后,原dropNode后面的节点之前 @@ -102,4 +161,5 @@ public abstract class TestPlanResourceService { refreshPos(sortDTO.getTestPlanId()); } } + } diff --git a/backend/services/test-plan/src/main/resources/testPlanGeneratorConfig.xml b/backend/services/test-plan/src/main/resources/testPlanGeneratorConfig.xml index d97e354d7b..c7633fd3ba 100644 --- a/backend/services/test-plan/src/main/resources/testPlanGeneratorConfig.xml +++ b/backend/services/test-plan/src/main/resources/testPlanGeneratorConfig.xml @@ -77,10 +77,10 @@ - - - - +
+
+
+