diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinition.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinition.java index 0d727aff26..3c38c19a0b 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinition.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinition.java @@ -1,12 +1,17 @@ package io.metersphere.api.domain; -import io.metersphere.validation.groups.*; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; -import lombok.Data; +import java.util.List; @Data public class ApiDefinition implements Serializable { @@ -40,7 +45,7 @@ public class ApiDefinition implements Serializable { private Long num; @Schema(description = "标签") - private String tags; + private List tags; @Schema(description = "自定义排序", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "{api_definition.pos.not_blank}", groups = {Created.class}) @@ -164,7 +169,7 @@ public class ApiDefinition implements Serializable { return this.getEscapedColumnName() + " ASC"; } - public static Column[] excludes(Column ... excludes) { + 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))); @@ -188,4 +193,4 @@ public class ApiDefinition implements Serializable { return this.getEscapedColumnName(); } } -} +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionExample.java index d330b76131..22a05c7d68 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionExample.java @@ -64,19 +64,50 @@ public class ApiDefinitionExample { } protected abstract static class GeneratedCriteria { + protected List tagsCriteria; + + protected List allCriteria; + protected List criteria; protected GeneratedCriteria() { super(); criteria = new ArrayList(); + tagsCriteria = new ArrayList(); + } + + public List getTagsCriteria() { + return tagsCriteria; + } + + protected void addTagsCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + tagsCriteria.add(new Criterion(condition, value, "io.metersphere.handler.ListTypeHandler")); + allCriteria = null; + } + + protected void addTagsCriterion(String condition, List value1, List value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + tagsCriteria.add(new Criterion(condition, value1, value2, "io.metersphere.handler.ListTypeHandler")); + allCriteria = null; } public boolean isValid() { - return criteria.size() > 0; + return criteria.size() > 0 + || tagsCriteria.size() > 0; } public List getAllCriteria() { - return criteria; + if (allCriteria == null) { + allCriteria = new ArrayList(); + allCriteria.addAll(criteria); + allCriteria.addAll(tagsCriteria); + } + return allCriteria; } public List getCriteria() { @@ -88,6 +119,7 @@ public class ApiDefinitionExample { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion(condition)); + allCriteria = null; } protected void addCriterion(String condition, Object value, String property) { @@ -95,6 +127,7 @@ public class ApiDefinitionExample { throw new RuntimeException("Value for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value)); + allCriteria = null; } protected void addCriterion(String condition, Object value1, Object value2, String property) { @@ -102,6 +135,7 @@ public class ApiDefinitionExample { throw new RuntimeException("Between values for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value1, value2)); + allCriteria = null; } public Criteria andIdIsNull() { @@ -594,63 +628,63 @@ public class ApiDefinitionExample { return (Criteria) this; } - public Criteria andTagsEqualTo(String value) { - addCriterion("tags =", value, "tags"); + public Criteria andTagsEqualTo(List value) { + addTagsCriterion("tags =", value, "tags"); return (Criteria) this; } - public Criteria andTagsNotEqualTo(String value) { - addCriterion("tags <>", value, "tags"); + public Criteria andTagsNotEqualTo(List value) { + addTagsCriterion("tags <>", value, "tags"); return (Criteria) this; } - public Criteria andTagsGreaterThan(String value) { - addCriterion("tags >", value, "tags"); + public Criteria andTagsGreaterThan(List value) { + addTagsCriterion("tags >", value, "tags"); return (Criteria) this; } - public Criteria andTagsGreaterThanOrEqualTo(String value) { - addCriterion("tags >=", value, "tags"); + public Criteria andTagsGreaterThanOrEqualTo(List value) { + addTagsCriterion("tags >=", value, "tags"); return (Criteria) this; } - public Criteria andTagsLessThan(String value) { - addCriterion("tags <", value, "tags"); + public Criteria andTagsLessThan(List value) { + addTagsCriterion("tags <", value, "tags"); return (Criteria) this; } - public Criteria andTagsLessThanOrEqualTo(String value) { - addCriterion("tags <=", value, "tags"); + public Criteria andTagsLessThanOrEqualTo(List value) { + addTagsCriterion("tags <=", value, "tags"); return (Criteria) this; } - public Criteria andTagsLike(String value) { - addCriterion("tags like", value, "tags"); + public Criteria andTagsLike(List value) { + addTagsCriterion("tags like", value, "tags"); return (Criteria) this; } - public Criteria andTagsNotLike(String value) { - addCriterion("tags not like", value, "tags"); + public Criteria andTagsNotLike(List value) { + addTagsCriterion("tags not like", value, "tags"); return (Criteria) this; } - public Criteria andTagsIn(List values) { - addCriterion("tags in", values, "tags"); + public Criteria andTagsIn(List> values) { + addTagsCriterion("tags in", values, "tags"); return (Criteria) this; } - public Criteria andTagsNotIn(List values) { - addCriterion("tags not in", values, "tags"); + public Criteria andTagsNotIn(List> values) { + addTagsCriterion("tags not in", values, "tags"); return (Criteria) this; } - public Criteria andTagsBetween(String value1, String value2) { - addCriterion("tags between", value1, value2, "tags"); + public Criteria andTagsBetween(List value1, List value2) { + addTagsCriterion("tags between", value1, value2, "tags"); return (Criteria) this; } - public Criteria andTagsNotBetween(String value1, String value2) { - addCriterion("tags not between", value1, value2, "tags"); + public Criteria andTagsNotBetween(List value1, List value2) { + addTagsCriterion("tags not between", value1, value2, "tags"); return (Criteria) this; } diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMock.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMock.java index 19acdedbc7..6948cb3e8a 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMock.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMock.java @@ -1,12 +1,16 @@ package io.metersphere.api.domain; -import io.metersphere.validation.groups.*; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; -import lombok.Data; +import java.util.List; @Data public class ApiDefinitionMock implements Serializable { @@ -30,7 +34,7 @@ public class ApiDefinitionMock implements Serializable { private String name; @Schema(description = "自定义标签") - private String tags; + private List tags; @Schema(description = "启用/禁用") private Boolean enable; @@ -107,7 +111,7 @@ public class ApiDefinitionMock implements Serializable { return this.getEscapedColumnName() + " ASC"; } - public static Column[] excludes(Column ... excludes) { + 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))); diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockExample.java index 6db7d015a1..47e82a532a 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockExample.java @@ -64,19 +64,50 @@ public class ApiDefinitionMockExample { } protected abstract static class GeneratedCriteria { + protected List tagsCriteria; + + protected List allCriteria; + protected List criteria; protected GeneratedCriteria() { super(); criteria = new ArrayList(); + tagsCriteria = new ArrayList(); + } + + public List getTagsCriteria() { + return tagsCriteria; + } + + protected void addTagsCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + tagsCriteria.add(new Criterion(condition, value, "io.metersphere.handler.ListTypeHandler")); + allCriteria = null; + } + + protected void addTagsCriterion(String condition, List value1, List value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + tagsCriteria.add(new Criterion(condition, value1, value2, "io.metersphere.handler.ListTypeHandler")); + allCriteria = null; } public boolean isValid() { - return criteria.size() > 0; + return criteria.size() > 0 + || tagsCriteria.size() > 0; } public List getAllCriteria() { - return criteria; + if (allCriteria == null) { + allCriteria = new ArrayList(); + allCriteria.addAll(criteria); + allCriteria.addAll(tagsCriteria); + } + return allCriteria; } public List getCriteria() { @@ -88,6 +119,7 @@ public class ApiDefinitionMockExample { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion(condition)); + allCriteria = null; } protected void addCriterion(String condition, Object value, String property) { @@ -95,6 +127,7 @@ public class ApiDefinitionMockExample { throw new RuntimeException("Value for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value)); + allCriteria = null; } protected void addCriterion(String condition, Object value1, Object value2, String property) { @@ -102,6 +135,7 @@ public class ApiDefinitionMockExample { throw new RuntimeException("Between values for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value1, value2)); + allCriteria = null; } public Criteria andIdIsNull() { @@ -444,63 +478,63 @@ public class ApiDefinitionMockExample { return (Criteria) this; } - public Criteria andTagsEqualTo(String value) { - addCriterion("tags =", value, "tags"); + public Criteria andTagsEqualTo(List value) { + addTagsCriterion("tags =", value, "tags"); return (Criteria) this; } - public Criteria andTagsNotEqualTo(String value) { - addCriterion("tags <>", value, "tags"); + public Criteria andTagsNotEqualTo(List value) { + addTagsCriterion("tags <>", value, "tags"); return (Criteria) this; } - public Criteria andTagsGreaterThan(String value) { - addCriterion("tags >", value, "tags"); + public Criteria andTagsGreaterThan(List value) { + addTagsCriterion("tags >", value, "tags"); return (Criteria) this; } - public Criteria andTagsGreaterThanOrEqualTo(String value) { - addCriterion("tags >=", value, "tags"); + public Criteria andTagsGreaterThanOrEqualTo(List value) { + addTagsCriterion("tags >=", value, "tags"); return (Criteria) this; } - public Criteria andTagsLessThan(String value) { - addCriterion("tags <", value, "tags"); + public Criteria andTagsLessThan(List value) { + addTagsCriterion("tags <", value, "tags"); return (Criteria) this; } - public Criteria andTagsLessThanOrEqualTo(String value) { - addCriterion("tags <=", value, "tags"); + public Criteria andTagsLessThanOrEqualTo(List value) { + addTagsCriterion("tags <=", value, "tags"); return (Criteria) this; } - public Criteria andTagsLike(String value) { - addCriterion("tags like", value, "tags"); + public Criteria andTagsLike(List value) { + addTagsCriterion("tags like", value, "tags"); return (Criteria) this; } - public Criteria andTagsNotLike(String value) { - addCriterion("tags not like", value, "tags"); + public Criteria andTagsNotLike(List value) { + addTagsCriterion("tags not like", value, "tags"); return (Criteria) this; } - public Criteria andTagsIn(List values) { - addCriterion("tags in", values, "tags"); + public Criteria andTagsIn(List> values) { + addTagsCriterion("tags in", values, "tags"); return (Criteria) this; } - public Criteria andTagsNotIn(List values) { - addCriterion("tags not in", values, "tags"); + public Criteria andTagsNotIn(List> values) { + addTagsCriterion("tags not in", values, "tags"); return (Criteria) this; } - public Criteria andTagsBetween(String value1, String value2) { - addCriterion("tags between", value1, value2, "tags"); + public Criteria andTagsBetween(List value1, List value2) { + addTagsCriterion("tags between", value1, value2, "tags"); return (Criteria) this; } - public Criteria andTagsNotBetween(String value1, String value2) { - addCriterion("tags not between", value1, value2, "tags"); + public Criteria andTagsNotBetween(List value1, List value2) { + addTagsCriterion("tags not between", value1, value2, "tags"); return (Criteria) this; } diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCase.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCase.java index 9603c763b1..b7bbe62813 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCase.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCase.java @@ -1,12 +1,17 @@ package io.metersphere.api.domain; -import io.metersphere.validation.groups.*; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; -import lombok.Data; +import java.util.List; @Data public class ApiTestCase implements Serializable { @@ -29,7 +34,7 @@ public class ApiTestCase implements Serializable { private Long num; @Schema(description = "标签") - private String tags; + private List tags; @Schema(description = "用例状态", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{api_test_case.status.not_blank}", groups = {Created.class}) @@ -153,7 +158,7 @@ public class ApiTestCase implements Serializable { return this.getEscapedColumnName() + " ASC"; } - public static Column[] excludes(Column ... excludes) { + 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))); diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCaseExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCaseExample.java index 09cd6862ec..d5ea64e716 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCaseExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiTestCaseExample.java @@ -64,19 +64,50 @@ public class ApiTestCaseExample { } protected abstract static class GeneratedCriteria { + protected List tagsCriteria; + + protected List allCriteria; + protected List criteria; protected GeneratedCriteria() { super(); criteria = new ArrayList(); + tagsCriteria = new ArrayList(); + } + + public List getTagsCriteria() { + return tagsCriteria; + } + + protected void addTagsCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + tagsCriteria.add(new Criterion(condition, value, "io.metersphere.handler.ListTypeHandler")); + allCriteria = null; + } + + protected void addTagsCriterion(String condition, List value1, List value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + tagsCriteria.add(new Criterion(condition, value1, value2, "io.metersphere.handler.ListTypeHandler")); + allCriteria = null; } public boolean isValid() { - return criteria.size() > 0; + return criteria.size() > 0 + || tagsCriteria.size() > 0; } public List getAllCriteria() { - return criteria; + if (allCriteria == null) { + allCriteria = new ArrayList(); + allCriteria.addAll(criteria); + allCriteria.addAll(tagsCriteria); + } + return allCriteria; } public List getCriteria() { @@ -88,6 +119,7 @@ public class ApiTestCaseExample { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion(condition)); + allCriteria = null; } protected void addCriterion(String condition, Object value, String property) { @@ -95,6 +127,7 @@ public class ApiTestCaseExample { throw new RuntimeException("Value for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value)); + allCriteria = null; } protected void addCriterion(String condition, Object value1, Object value2, String property) { @@ -102,6 +135,7 @@ public class ApiTestCaseExample { throw new RuntimeException("Between values for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value1, value2)); + allCriteria = null; } public Criteria andIdIsNull() { @@ -384,63 +418,63 @@ public class ApiTestCaseExample { return (Criteria) this; } - public Criteria andTagsEqualTo(String value) { - addCriterion("tags =", value, "tags"); + public Criteria andTagsEqualTo(List value) { + addTagsCriterion("tags =", value, "tags"); return (Criteria) this; } - public Criteria andTagsNotEqualTo(String value) { - addCriterion("tags <>", value, "tags"); + public Criteria andTagsNotEqualTo(List value) { + addTagsCriterion("tags <>", value, "tags"); return (Criteria) this; } - public Criteria andTagsGreaterThan(String value) { - addCriterion("tags >", value, "tags"); + public Criteria andTagsGreaterThan(List value) { + addTagsCriterion("tags >", value, "tags"); return (Criteria) this; } - public Criteria andTagsGreaterThanOrEqualTo(String value) { - addCriterion("tags >=", value, "tags"); + public Criteria andTagsGreaterThanOrEqualTo(List value) { + addTagsCriterion("tags >=", value, "tags"); return (Criteria) this; } - public Criteria andTagsLessThan(String value) { - addCriterion("tags <", value, "tags"); + public Criteria andTagsLessThan(List value) { + addTagsCriterion("tags <", value, "tags"); return (Criteria) this; } - public Criteria andTagsLessThanOrEqualTo(String value) { - addCriterion("tags <=", value, "tags"); + public Criteria andTagsLessThanOrEqualTo(List value) { + addTagsCriterion("tags <=", value, "tags"); return (Criteria) this; } - public Criteria andTagsLike(String value) { - addCriterion("tags like", value, "tags"); + public Criteria andTagsLike(List value) { + addTagsCriterion("tags like", value, "tags"); return (Criteria) this; } - public Criteria andTagsNotLike(String value) { - addCriterion("tags not like", value, "tags"); + public Criteria andTagsNotLike(List value) { + addTagsCriterion("tags not like", value, "tags"); return (Criteria) this; } - public Criteria andTagsIn(List values) { - addCriterion("tags in", values, "tags"); + public Criteria andTagsIn(List> values) { + addTagsCriterion("tags in", values, "tags"); return (Criteria) this; } - public Criteria andTagsNotIn(List values) { - addCriterion("tags not in", values, "tags"); + public Criteria andTagsNotIn(List> values) { + addTagsCriterion("tags not in", values, "tags"); return (Criteria) this; } - public Criteria andTagsBetween(String value1, String value2) { - addCriterion("tags between", value1, value2, "tags"); + public Criteria andTagsBetween(List value1, List value2) { + addTagsCriterion("tags between", value1, value2, "tags"); return (Criteria) this; } - public Criteria andTagsNotBetween(String value1, String value2) { - addCriterion("tags not between", value1, value2, "tags"); + public Criteria andTagsNotBetween(List value1, List value2) { + addTagsCriterion("tags not between", value1, value2, "tags"); return (Criteria) this; } diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMapper.xml index 1157ffa6a9..0ef69d0ad6 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMapper.xml @@ -9,7 +9,7 @@ - + @@ -49,6 +49,25 @@ + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} and #{criterion.secondValue,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} + + #{listItem,typeHandler=io.metersphere.handler.ListTypeHandler} + + + + @@ -78,6 +97,25 @@ + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} and #{criterion.secondValue,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} + + #{listItem,typeHandler=io.metersphere.handler.ListTypeHandler} + + + + @@ -121,20 +159,20 @@ insert into api_definition (id, `name`, protocol, `method`, `path`, `status`, - num, tags, pos, project_id, - module_id, latest, version_id, - ref_id, description, create_time, - create_user, update_time, update_user, - delete_user, delete_time, deleted - ) + num, tags, + pos, project_id, module_id, + latest, version_id, ref_id, + description, create_time, create_user, + update_time, update_user, delete_user, + delete_time, deleted) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, - #{num,jdbcType=BIGINT}, #{tags,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, - #{moduleId,jdbcType=VARCHAR}, #{latest,jdbcType=BIT}, #{versionId,jdbcType=VARCHAR}, - #{refId,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, - #{createUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, #{updateUser,jdbcType=VARCHAR}, - #{deleteUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleted,jdbcType=BIT} - ) + #{num,jdbcType=BIGINT}, #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, + #{pos,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR}, + #{latest,jdbcType=BIT}, #{versionId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, + #{updateTime,jdbcType=BIGINT}, #{updateUser,jdbcType=VARCHAR}, #{deleteUser,jdbcType=VARCHAR}, + #{deleteTime,jdbcType=BIGINT}, #{deleted,jdbcType=BIT}) insert into api_definition @@ -229,7 +267,7 @@ #{num,jdbcType=BIGINT}, - #{tags,jdbcType=VARCHAR}, + #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, #{pos,jdbcType=BIGINT}, @@ -306,7 +344,7 @@ num = #{record.num,jdbcType=BIGINT}, - tags = #{record.tags,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, pos = #{record.pos,jdbcType=BIGINT}, @@ -364,7 +402,7 @@ `path` = #{record.path,jdbcType=VARCHAR}, `status` = #{record.status,jdbcType=VARCHAR}, num = #{record.num,jdbcType=BIGINT}, - tags = #{record.tags,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, pos = #{record.pos,jdbcType=BIGINT}, project_id = #{record.projectId,jdbcType=VARCHAR}, module_id = #{record.moduleId,jdbcType=VARCHAR}, @@ -405,7 +443,7 @@ num = #{num,jdbcType=BIGINT}, - tags = #{tags,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, pos = #{pos,jdbcType=BIGINT}, @@ -460,7 +498,7 @@ `path` = #{path,jdbcType=VARCHAR}, `status` = #{status,jdbcType=VARCHAR}, num = #{num,jdbcType=BIGINT}, - tags = #{tags,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, pos = #{pos,jdbcType=BIGINT}, project_id = #{projectId,jdbcType=VARCHAR}, module_id = #{moduleId,jdbcType=VARCHAR}, @@ -486,12 +524,12 @@ (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.protocol,jdbcType=VARCHAR}, #{item.method,jdbcType=VARCHAR}, #{item.path,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, - #{item.num,jdbcType=BIGINT}, #{item.tags,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, - #{item.projectId,jdbcType=VARCHAR}, #{item.moduleId,jdbcType=VARCHAR}, #{item.latest,jdbcType=BIT}, - #{item.versionId,jdbcType=VARCHAR}, #{item.refId,jdbcType=VARCHAR}, #{item.description,jdbcType=VARCHAR}, - #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}, - #{item.updateUser,jdbcType=VARCHAR}, #{item.deleteUser,jdbcType=VARCHAR}, #{item.deleteTime,jdbcType=BIGINT}, - #{item.deleted,jdbcType=BIT}) + #{item.num,jdbcType=BIGINT}, #{item.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, + #{item.pos,jdbcType=BIGINT}, #{item.projectId,jdbcType=VARCHAR}, #{item.moduleId,jdbcType=VARCHAR}, + #{item.latest,jdbcType=BIT}, #{item.versionId,jdbcType=VARCHAR}, #{item.refId,jdbcType=VARCHAR}, + #{item.description,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, + #{item.updateTime,jdbcType=BIGINT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.deleteUser,jdbcType=VARCHAR}, + #{item.deleteTime,jdbcType=BIGINT}, #{item.deleted,jdbcType=BIT}) @@ -526,7 +564,7 @@ #{item.num,jdbcType=BIGINT} - #{item.tags,jdbcType=VARCHAR} + #{item.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler} #{item.pos,jdbcType=BIGINT} diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockMapper.xml index 2cfef0a5d0..64a8808413 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockMapper.xml @@ -7,7 +7,7 @@ - + @@ -37,6 +37,25 @@ + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} and #{criterion.secondValue,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} + + #{listItem,typeHandler=io.metersphere.handler.ListTypeHandler} + + + + @@ -66,6 +85,25 @@ + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} and #{criterion.secondValue,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} + + #{listItem,typeHandler=io.metersphere.handler.ListTypeHandler} + + + + @@ -111,7 +149,7 @@ `enable`, expect_num, project_id, api_definition_id) values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, - #{createUser,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, + #{createUser,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, #{enable,jdbcType=BIT}, #{expectNum,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR}) @@ -166,7 +204,7 @@ #{name,jdbcType=VARCHAR}, - #{tags,jdbcType=VARCHAR}, + #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, #{enable,jdbcType=BIT}, @@ -207,7 +245,7 @@ `name` = #{record.name,jdbcType=VARCHAR}, - tags = #{record.tags,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `enable` = #{record.enable,jdbcType=BIT}, @@ -233,7 +271,7 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, create_user = #{record.createUser,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR}, - tags = #{record.tags,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `enable` = #{record.enable,jdbcType=BIT}, expect_num = #{record.expectNum,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR}, @@ -258,7 +296,7 @@ `name` = #{name,jdbcType=VARCHAR}, - tags = #{tags,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `enable` = #{enable,jdbcType=BIT}, @@ -281,7 +319,7 @@ update_time = #{updateTime,jdbcType=BIGINT}, create_user = #{createUser,jdbcType=VARCHAR}, `name` = #{name,jdbcType=VARCHAR}, - tags = #{tags,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `enable` = #{enable,jdbcType=BIT}, expect_num = #{expectNum,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR}, @@ -295,7 +333,7 @@ values (#{item.id,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.updateTime,jdbcType=BIGINT}, - #{item.createUser,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.tags,jdbcType=VARCHAR}, + #{item.createUser,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, #{item.enable,jdbcType=BIT}, #{item.expectNum,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.apiDefinitionId,jdbcType=VARCHAR}) @@ -326,7 +364,7 @@ #{item.name,jdbcType=VARCHAR} - #{item.tags,jdbcType=VARCHAR} + #{item.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler} #{item.enable,jdbcType=BIT} diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiTestCaseMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiTestCaseMapper.xml index e3b75dce79..5e21da4a6c 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiTestCaseMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiTestCaseMapper.xml @@ -6,7 +6,7 @@ - + @@ -47,6 +47,25 @@ + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} and #{criterion.secondValue,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} + + #{listItem,typeHandler=io.metersphere.handler.ListTypeHandler} + + + + @@ -76,6 +95,25 @@ + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} #{criterion.value,typeHandler=io.metersphere.handler.ListTypeHandler} and #{criterion.secondValue,typeHandler=io.metersphere.handler.ListTypeHandler} + + + and ${criterion.condition} + + #{listItem,typeHandler=io.metersphere.handler.ListTypeHandler} + + + + @@ -118,19 +156,21 @@ insert into api_test_case (id, `name`, priority, - num, tags, `status`, last_report_status, - last_report_id, pos, project_id, - api_definition_id, version_id, environment_id, - create_time, create_user, update_time, - update_user, delete_time, delete_user, - deleted) + num, tags, + `status`, last_report_status, last_report_id, + pos, project_id, api_definition_id, + version_id, environment_id, create_time, + create_user, update_time, update_user, + delete_time, delete_user, deleted + ) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, - #{num,jdbcType=BIGINT}, #{tags,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{lastReportStatus,jdbcType=VARCHAR}, - #{lastReportId,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, - #{apiDefinitionId,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR}, - #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, - #{updateUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR}, - #{deleted,jdbcType=BIT}) + #{num,jdbcType=BIGINT}, #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, + #{status,jdbcType=VARCHAR}, #{lastReportStatus,jdbcType=VARCHAR}, #{lastReportId,jdbcType=VARCHAR}, + #{pos,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR}, + #{versionId,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, + #{createUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, #{updateUser,jdbcType=VARCHAR}, + #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT} + ) insert into api_test_case @@ -210,7 +250,7 @@ #{num,jdbcType=BIGINT}, - #{tags,jdbcType=VARCHAR}, + #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, #{status,jdbcType=VARCHAR}, @@ -281,7 +321,7 @@ num = #{record.num,jdbcType=BIGINT}, - tags = #{record.tags,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `status` = #{record.status,jdbcType=VARCHAR}, @@ -339,7 +379,7 @@ `name` = #{record.name,jdbcType=VARCHAR}, priority = #{record.priority,jdbcType=VARCHAR}, num = #{record.num,jdbcType=BIGINT}, - tags = #{record.tags,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `status` = #{record.status,jdbcType=VARCHAR}, last_report_status = #{record.lastReportStatus,jdbcType=VARCHAR}, last_report_id = #{record.lastReportId,jdbcType=VARCHAR}, @@ -372,7 +412,7 @@ num = #{num,jdbcType=BIGINT}, - tags = #{tags,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `status` = #{status,jdbcType=VARCHAR}, @@ -427,7 +467,7 @@ set `name` = #{name,jdbcType=VARCHAR}, priority = #{priority,jdbcType=VARCHAR}, num = #{num,jdbcType=BIGINT}, - tags = #{tags,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, `status` = #{status,jdbcType=VARCHAR}, last_report_status = #{lastReportStatus,jdbcType=VARCHAR}, last_report_id = #{lastReportId,jdbcType=VARCHAR}, @@ -453,8 +493,8 @@ values (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.priority,jdbcType=VARCHAR}, - #{item.num,jdbcType=BIGINT}, #{item.tags,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, - #{item.lastReportStatus,jdbcType=VARCHAR}, #{item.lastReportId,jdbcType=VARCHAR}, + #{item.num,jdbcType=BIGINT}, #{item.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler}, + #{item.status,jdbcType=VARCHAR}, #{item.lastReportStatus,jdbcType=VARCHAR}, #{item.lastReportId,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, #{item.projectId,jdbcType=VARCHAR}, #{item.apiDefinitionId,jdbcType=VARCHAR}, #{item.versionId,jdbcType=VARCHAR}, #{item.environmentId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}, #{item.updateUser,jdbcType=VARCHAR}, @@ -485,7 +525,7 @@ #{item.num,jdbcType=BIGINT} - #{item.tags,jdbcType=VARCHAR} + #{item.tags,jdbcType=VARCHAR,typeHandler=io.metersphere.handler.ListTypeHandler} #{item.status,jdbcType=VARCHAR} diff --git a/backend/framework/provider/src/main/java/io/metersphere/dto/TestCaseProviderDTO.java b/backend/framework/provider/src/main/java/io/metersphere/dto/TestCaseProviderDTO.java index d0fcc40e8f..b38bfbf357 100644 --- a/backend/framework/provider/src/main/java/io/metersphere/dto/TestCaseProviderDTO.java +++ b/backend/framework/provider/src/main/java/io/metersphere/dto/TestCaseProviderDTO.java @@ -8,6 +8,8 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.Data; +import java.util.List; + @Data public class TestCaseProviderDTO { @@ -30,7 +32,7 @@ public class TestCaseProviderDTO { private Long num; @Schema(description = "标签") - private String tags; + private List tags; @Schema(description = "自定义排序", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "{api_test_case.pos.not_blank}", groups = {Created.class}) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseBatchEditRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseBatchEditRequest.java index 713d5b69d7..afb5465222 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseBatchEditRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseBatchEditRequest.java @@ -6,7 +6,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.util.ArrayList; import java.util.LinkedHashSet; +import java.util.List; @Data @EqualsAndHashCode(callSuper = false) @@ -30,4 +32,12 @@ public class ApiCaseBatchEditRequest extends ApiTestCaseBatchRequest implements @Schema(description = "用例等级") private String priority; + public List getTags() { + if (tags == null) { + return new ArrayList<>(0); + } else { + return new ArrayList<>(tags); + } + } + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionAddRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionAddRequest.java index 357e9a1885..992925473e 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionAddRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionAddRequest.java @@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils; import java.io.Serial; import java.io.Serializable; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -23,11 +24,11 @@ public class ApiDefinitionAddRequest implements Serializable { private static final long serialVersionUID = 1L; - @Schema(description = "接口名称", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "接口名称", requiredMode = Schema.RequiredMode.REQUIRED) @Size(min = 1, max = 255, message = "{api_definition.name.length_range}") private String name; - @Schema(description = "接口协议", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "接口协议", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{api_definition.protocol.not_blank}") @Size(min = 1, max = 20, message = "{api_definition.protocol.length_range}") private String protocol = ModuleConstants.NODE_PROTOCOL_HTTP; @@ -89,4 +90,12 @@ public class ApiDefinitionAddRequest implements Serializable { public void setPath(String path) { this.path = StringUtils.trim(path); } + + public List getTags() { + if (tags == null) { + return new ArrayList<>(0); + } else { + return new ArrayList<>(tags); + } + } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionBatchUpdateRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionBatchUpdateRequest.java index 192055512a..671c19fd16 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionBatchUpdateRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionBatchUpdateRequest.java @@ -7,7 +7,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serial; +import java.util.ArrayList; import java.util.LinkedHashSet; +import java.util.List; /** * @author lan @@ -42,4 +44,12 @@ public class ApiDefinitionBatchUpdateRequest extends ApiDefinitionBatchRequest { @Schema(description = "是否追加", requiredMode = Schema.RequiredMode.REQUIRED) private boolean append = false; + public List getTags() { + if (tags == null) { + return new ArrayList<>(0); + } else { + return new ArrayList<>(tags); + } + } + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java index c68c2f34d7..8c2873172d 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java @@ -6,6 +6,7 @@ import jakarta.validation.constraints.Size; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -63,4 +64,12 @@ public class ApiTestCaseAddRequest implements Serializable { @Schema(description = "关联文件ID") private List linkFileIds; + public List getTags() { + if (tags == null) { + return new ArrayList<>(0); + } else { + return new ArrayList<>(tags); + } + } + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java index 28dc81c46c..4ab18b1703 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java @@ -4,7 +4,6 @@ import io.metersphere.plugin.api.spi.AbstractMsTestElement; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.util.ArrayList; import java.util.List; @Data @@ -79,7 +78,7 @@ public class ApiTestCaseDTO { private String deleteName; @Schema(description = "标签") - private List tags = new ArrayList<>(); + private List tags; @Schema(description = "用例通过率") private String passRate; diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java index fca49d1dcc..62ae706aa6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java @@ -6,6 +6,7 @@ import jakarta.validation.constraints.Size; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; @Data @@ -70,4 +71,12 @@ public class ApiTestCaseUpdateRequest implements Serializable { @Schema(description = "取消关联文件ID") private List unLinkRefIds; + public List getTags() { + if (tags == null) { + return new ArrayList<>(0); + } else { + return new ArrayList<>(tags); + } + } + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/importdto/ScheduleRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/importdto/ScheduleRequest.java new file mode 100644 index 0000000000..efd6c3b413 --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/importdto/ScheduleRequest.java @@ -0,0 +1,40 @@ +package io.metersphere.api.dto.definition.importdto; + + +import io.metersphere.api.dto.request.http.Header; +import io.metersphere.api.dto.request.http.QueryParam; +import io.metersphere.api.dto.request.http.auth.HTTPAuth; +import io.metersphere.system.domain.Schedule; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +public class ScheduleRequest extends Schedule { + + //定时任务来源: 测试计划/测试场景 + private String scheduleFrom; + + private String projectId; + + private String moduleId; + + private String modulePath; + + private String modeId; + + private String swaggerUrl; + + private String taskId; + + // 鉴权相关 + @Schema(description = "swagger的请求头参数") + private List
headers; + @Schema(description = "swagger的请求参数") + private List arguments; + @Schema(description = "swagger的认证参数") + private HTTPAuth authManager; + private Boolean coverModule = false; + +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/request/ApiDefinitionMockAddRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/request/ApiDefinitionMockAddRequest.java index 9c3610296e..7712145db6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/request/ApiDefinitionMockAddRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/request/ApiDefinitionMockAddRequest.java @@ -7,6 +7,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -24,7 +25,7 @@ public class ApiDefinitionMockAddRequest implements Serializable { @Size(min = 1, max = 50, message = "{api_definition_mock.project_id.length_range}") private String projectId; - @Schema(description = "接口 mock 名称", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "接口 mock 名称", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{api_definition_mock.name.not_blank}") @Size(min = 1, max = 255, message = "{api_definition_mock.name.length_range}") private String name; @@ -58,4 +59,12 @@ public class ApiDefinitionMockAddRequest implements Serializable { @Schema(description = "关联文件ID") private List linkFileIds; + public List getTags() { + if (tags == null) { + return new ArrayList<>(0); + } else { + return new ArrayList<>(tags); + } + } + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml index 17094291cb..31d4f64a28 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml @@ -2,7 +2,13 @@ + + + + + + update api_definition set delete_user = #{userId},delete_time = #{time}, deleted = 1 , module_id = 'root' @@ -11,7 +17,7 @@ #{v} - select api_definition.id, api_definition.`name`, api_definition.protocol, api_definition.`method`, api_definition.`path`, api_definition.`status`, api_definition.num, api_definition.tags, api_definition.pos, @@ -26,7 +32,7 @@ - select api_definition.id, api_definition.`name`, api_definition.protocol, api_definition.`method`, api_definition.`path`, api_definition.`status`, api_definition.num, api_definition.tags, api_definition.pos, @@ -121,7 +127,7 @@ WHERE ref_id = #{refId} - select id, tags from api_definition where id in diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMockMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMockMapper.xml index de47828cde..fe405c56da 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMockMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMockMapper.xml @@ -2,7 +2,11 @@ - select m.id, m.create_time, m.update_time, m.create_user, m.`name`, m.tags, m.`enable`, m.expect_num, m.project_id, m.api_definition_id, u.name as create_user_name diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml index bcec337ca1..06b7d42e30 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml @@ -2,6 +2,13 @@ + + + + + + + UPDATE api_test_case SET deleted = 1, @@ -21,7 +28,7 @@ LIMIT 1; - SELECT t1.id, t1.project_id, @@ -39,6 +46,7 @@ t1.last_report_status, t1.last_report_id, t1.environment_id, + t1.tags, a.module_id FROM api_test_case t1 @@ -153,7 +161,7 @@ - SELECT t1.id, t1.project_id, diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionMockService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionMockService.java index 96a90f1add..d383c76511 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionMockService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionMockService.java @@ -23,7 +23,6 @@ import io.metersphere.sdk.constants.DefaultRepositoryDir; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.FileAssociationSourceUtil; -import io.metersphere.sdk.util.JSON; import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.NumGenerator; @@ -79,7 +78,7 @@ public class ApiDefinitionMockService { apiDefinitionMockConfigOptional.ifPresent(config -> { apiDefinitionMockDTO.setMatching(ApiDataUtils.parseObject(new String(config.getMatching()), AbstractMsTestElement.class)); apiDefinitionMockDTO.setResponse(ApiDataUtils.parseArray(new String(config.getResponse()), HttpResponse.class)); - }); + }); } public void handleApiDefinition(String id, ApiDefinitionMockDTO apiDefinitionMockDTO) { @@ -97,7 +96,7 @@ public class ApiDefinitionMockService { * @param id mock id */ private ApiDefinitionMock checkApiDefinitionMock(String id) { - return ServiceUtils.checkResourceExist(apiDefinitionMockMapper.selectByPrimaryKey(id),"permission.api_mock.name"); + return ServiceUtils.checkResourceExist(apiDefinitionMockMapper.selectByPrimaryKey(id), "permission.api_mock.name"); } public ApiDefinitionMock create(ApiDefinitionMockAddRequest request, String userId) { @@ -111,7 +110,7 @@ public class ApiDefinitionMockService { apiDefinitionMock.setUpdateTime(System.currentTimeMillis()); apiDefinitionMock.setCreateUser(userId); if (CollectionUtils.isNotEmpty(request.getTags())) { - apiDefinitionMock.setTags(JSON.toJSONString(request.getTags())); + apiDefinitionMock.setTags(request.getTags()); } apiDefinitionMock.setEnable(true); ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(apiDefinitionMock.getApiDefinitionId()); @@ -172,7 +171,7 @@ public class ApiDefinitionMockService { checkUpdateExist(apiDefinitionMock); apiDefinitionMock.setUpdateTime(System.currentTimeMillis()); if (CollectionUtils.isNotEmpty(request.getTags())) { - apiDefinitionMock.setTags(JSON.toJSONString(request.getTags())); + apiDefinitionMock.setTags(request.getTags()); } apiDefinitionMockMapper.updateByPrimaryKeySelective(apiDefinitionMock); ApiDefinitionMockConfig apiDefinitionMockConfig = new ApiDefinitionMockConfig(); @@ -229,7 +228,7 @@ public class ApiDefinitionMockService { } private String getCopyName(String name) { - String copyName = "copy_" + name ; + String copyName = "copy_" + name; if (copyName.length() > 200) { copyName = copyName.substring(0, 195) + copyName.substring(copyName.length() - 5); } @@ -255,7 +254,7 @@ public class ApiDefinitionMockService { List apiDefinitionMocks = apiDefinitionMockMapper.selectByExample(apiDefinitionMockExample); - if(!apiDefinitionMocks.isEmpty()){ + if (!apiDefinitionMocks.isEmpty()) { apiDefinitionMocks.forEach(item -> { String apiDefinitionMockDir = DefaultRepositoryDir.getApiDefinitionDir(item.getProjectId(), item.getId()); apiFileResourceService.deleteByResourceId(apiDefinitionMockDir, item.getId(), item.getProjectId(), userId, OperationLogModule.API_DEFINITION_MOCK); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java index 06d681c467..47904710d6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java @@ -170,7 +170,7 @@ public class ApiDefinitionService { apiDefinition.setVersionId(StringUtils.defaultIfBlank(request.getVersionId(), extBaseProjectVersionMapper.getDefaultVersion(request.getProjectId()))); apiDefinition.setRefId(apiDefinition.getId()); if (CollectionUtils.isNotEmpty(request.getTags())) { - apiDefinition.setTags(JSON.toJSONString(request.getTags())); + apiDefinition.setTags(request.getTags()); } apiDefinitionMapper.insertSelective(apiDefinition); ApiDefinitionBlob apiDefinitionBlob = new ApiDefinitionBlob(); @@ -222,7 +222,7 @@ public class ApiDefinitionService { apiDefinition.setUpdateTime(System.currentTimeMillis()); apiDefinition.setVersionId(request.getVersionId()); if (CollectionUtils.isNotEmpty(request.getTags())) { - apiDefinition.setTags(JSON.toJSONString(request.getTags())); + apiDefinition.setTags(request.getTags()); } apiDefinitionMapper.updateByPrimaryKeySelective(apiDefinition); ApiDefinitionBlob apiDefinitionBlob = new ApiDefinitionBlob(); @@ -529,12 +529,12 @@ public class ApiDefinitionService { ApiDefinitionMapper definitionMapper = sqlSession.getMapper(ApiDefinitionMapper.class); ids.forEach(id -> { ApiDefinition apiDefinition = new ApiDefinition(); - if (StringUtils.isNotBlank(collect.get(id).getTags())) { - LinkedHashSet tags = new LinkedHashSet<>((JSON.parseArray(collect.get(id).getTags(), String.class))); + if (CollectionUtils.isNotEmpty(collect.get(id).getTags())) { + List tags = collect.get(id).getTags(); tags.addAll(request.getTags()); - apiDefinition.setTags(JSON.toJSONString(tags)); + apiDefinition.setTags(tags); } else { - apiDefinition.setTags(JSON.toJSONString(request.getTags())); + apiDefinition.setTags(request.getTags()); } apiDefinition.setId(id); apiDefinition.setUpdateTime(System.currentTimeMillis()); @@ -547,7 +547,7 @@ public class ApiDefinitionService { } else { //替换标签 ApiDefinition apiDefinition = new ApiDefinition(); - apiDefinition.setTags(JSON.toJSONString(request.getTags())); + apiDefinition.setTags(request.getTags()); apiDefinition.setProjectId(request.getProjectId()); apiDefinition.setUpdateTime(System.currentTimeMillis()); apiDefinition.setUpdateUser(userId); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseLogService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseLogService.java index 7f2e92071e..83e158a768 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseLogService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseLogService.java @@ -9,11 +9,11 @@ import io.metersphere.api.dto.definition.ApiTestCaseLogDTO; import io.metersphere.api.dto.definition.ApiTestCaseUpdateRequest; import io.metersphere.api.mapper.ApiTestCaseBlobMapper; import io.metersphere.api.mapper.ApiTestCaseMapper; +import io.metersphere.api.utils.ApiDataUtils; import io.metersphere.plugin.api.spi.AbstractMsTestElement; import io.metersphere.project.domain.Project; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.HttpMethodConstants; -import io.metersphere.api.utils.ApiDataUtils; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Translator; @@ -112,7 +112,7 @@ public class ApiTestCaseLogService { OperationLogType.RECOVER.name(), OperationLogModule.API_DEFINITION_CASE, apiTestCase.getName()); - dto.setHistory(true); + dto.setHistory(false); dto.setPath("/api/case/recover/" + id); dto.setMethod(HttpMethodConstants.GET.name()); dto.setOriginalValue(JSON.toJSONBytes(apiTestCase)); @@ -231,7 +231,7 @@ public class ApiTestCaseLogService { } public void batchRecoverLog(List apiTestCases, String operator, String projectId) { - saveBatchLog(projectId, apiTestCases, "/api/case/recover", operator, OperationLogType.RECOVER.name(), true); + saveBatchLog(projectId, apiTestCases, "/api/case/recover", operator, OperationLogType.RECOVER.name(), false); } private void saveBatchLog(String projectId, List apiTestCases, String path, String operator, String operationType, boolean isHistory) { @@ -267,7 +267,7 @@ public class ApiTestCaseLogService { .createUser(operator) .originalValue(JSON.toJSONBytes(apiTestCaseDTO)) .build().getLogDTO(); - dto.setHistory(isHistory); + dto.setHistory(isHistory); logs.add(dto); } ); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java index b5cb8bf3ba..a9261216ef 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java @@ -16,7 +16,10 @@ import io.metersphere.sdk.domain.Environment; import io.metersphere.sdk.domain.EnvironmentExample; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.mapper.EnvironmentMapper; -import io.metersphere.sdk.util.*; +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.sdk.util.FileAssociationSourceUtil; +import io.metersphere.sdk.util.SubListUtils; +import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.sdk.request.PosRequest; import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.service.UserLoginService; @@ -36,7 +39,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.util.ArrayList; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -143,7 +145,7 @@ public class ApiTestCaseService { testCase.setCreateTime(System.currentTimeMillis()); testCase.setUpdateTime(System.currentTimeMillis()); if (CollectionUtils.isNotEmpty(request.getTags())) { - testCase.setTags(JSON.toJSONString(request.getTags())); + testCase.setTags(request.getTags()); } apiTestCaseMapper.insertSelective(testCase); @@ -159,6 +161,7 @@ public class ApiTestCaseService { apiFileResourceService.addFileResource(resourceUpdateRequest); return testCase; } + private ApiTestCase checkResourceExist(String id) { ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(id); if (testCase == null) { @@ -172,8 +175,8 @@ public class ApiTestCaseService { ApiTestCase testCase = checkResourceExist(id); ApiTestCaseBlob testCaseBlob = apiTestCaseBlobMapper.selectByPrimaryKey(id); BeanUtils.copyBean(apiTestCaseDTO, testCase); - if (StringUtils.isNotBlank(testCase.getTags())) { - apiTestCaseDTO.setTags(JSON.parseArray(testCase.getTags(), String.class)); + if (CollectionUtils.isNotEmpty(testCase.getTags())) { + apiTestCaseDTO.setTags(testCase.getTags()); } else { apiTestCaseDTO.setTags(new ArrayList<>()); } @@ -225,7 +228,7 @@ public class ApiTestCaseService { testCase.setUpdateUser(userId); testCase.setUpdateTime(System.currentTimeMillis()); if (CollectionUtils.isNotEmpty(request.getTags())) { - testCase.setTags(JSON.toJSONString(request.getTags())); + testCase.setTags(request.getTags()); } else { testCase.setTags(null); } @@ -432,7 +435,7 @@ public class ApiTestCaseService { } private void batchUpdateTags(ApiTestCaseExample example, ApiTestCase updateCase, - LinkedHashSet tags, boolean appendTag, + List tags, boolean appendTag, SqlSession sqlSession, ApiTestCaseMapper mapper) { if (CollectionUtils.isEmpty(tags)) { throw new MSException(Translator.get("tags_is_null")); @@ -441,12 +444,12 @@ public class ApiTestCaseService { List caseList = apiTestCaseMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(caseList)) { caseList.forEach(apiTestCase -> { - if (StringUtils.isNotBlank(apiTestCase.getTags())) { - LinkedHashSet orgTags = ApiDataUtils.parseObject(apiTestCase.getTags(), LinkedHashSet.class); + if (CollectionUtils.isNotEmpty(apiTestCase.getTags())) { + List orgTags = apiTestCase.getTags(); orgTags.addAll(tags); - apiTestCase.setTags(JSON.toJSONString(orgTags)); + apiTestCase.setTags(orgTags); } else { - apiTestCase.setTags(JSON.toJSONString(tags)); + apiTestCase.setTags(tags); } mapper.updateByPrimaryKey(apiTestCase); }); @@ -456,7 +459,7 @@ public class ApiTestCaseService { } } } else { - updateCase.setTags(JSON.toJSONString(tags)); + updateCase.setTags(tags); apiTestCaseMapper.updateByExampleSelective(updateCase, example); } } diff --git a/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml b/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml index 865ed4c47b..29b03e1e09 100644 --- a/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml +++ b/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml @@ -73,7 +73,6 @@
-
@@ -94,13 +93,19 @@
-
-
- +
+ +
+ + +
+ + +
diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java index d3db81a0db..60e9378554 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java @@ -528,9 +528,9 @@ public class ApiDefinitionControllerTests extends BaseTest { } if (request.getTags() != null) { if (request.isAppend()) { - Assertions.assertTrue(JSON.parseArray(item.getTags(), String.class).containsAll(request.getTags())); + Assertions.assertTrue(item.getTags().containsAll(request.getTags())); } else { - Assertions.assertEquals(item.getTags(), JSON.toJSONString(request.getTags())); + Assertions.assertTrue(item.getTags().containsAll(request.getTags())); } } }); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java index 204c11f697..4bddfdd3a9 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java @@ -372,8 +372,8 @@ public class ApiTestCaseControllerTests extends BaseTest { // 校验数据是否正确 ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()); ApiTestCaseDTO copyApiDebugDTO = BeanUtils.copyBean(new ApiTestCaseDTO(), testCase); - if (StringUtils.isNotEmpty(testCase.getTags())) { - copyApiDebugDTO.setTags(JSON.parseArray(testCase.getTags(), String.class)); + if (CollectionUtils.isNotEmpty(testCase.getTags())) { + copyApiDebugDTO.setTags(testCase.getTags()); } else { copyApiDebugDTO.setTags(new ArrayList<>()); } @@ -679,7 +679,7 @@ public class ApiTestCaseControllerTests extends BaseTest { request.setAppendTag(false); responsePost(BATCH_EDIT, request); apiTestCaseMapper.selectByExample(example).forEach(apiTestCase -> { - Assertions.assertEquals(apiTestCase.getTags(), "[\"tag1\"]"); + Assertions.assertEquals(apiTestCase.getTags(), List.of("tag1")); }); //标签为空 报错 request.setTags(new LinkedHashSet<>()); @@ -858,6 +858,7 @@ public class ApiTestCaseControllerTests extends BaseTest { request.setSelectAll(true); request.setSelectIds(List.of(apiTestCase.getId())); request.setExcludeIds(List.of(apiTestCase.getId())); + request.setApiDefinitionId("apiDefinitionId"); request.setModuleIds(List.of("case-moduleId")); responsePost(BATCH_RECOVER, request); ApiTestCaseExample example = new ApiTestCaseExample(); @@ -873,7 +874,16 @@ public class ApiTestCaseControllerTests extends BaseTest { checkLog(apiTestCase.getId(), OperationLogType.DELETE); //校验权限 requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_RECOVER, BATCH_RECOVER, request); - this.batchMoveGc(); + ApiTestCaseBatchRequest gcRequest = new ApiTestCaseBatchRequest(); + gcRequest.setProjectId(DEFAULT_PROJECT_ID); + gcRequest.setSelectAll(true); + gcRequest.setExcludeIds(new ArrayList<>()); + gcRequest.setApiDefinitionId("apiDefinitionId"); + responsePost(BATCH_MOVE_GC, gcRequest); + ApiTestCaseExample example1 = new ApiTestCaseExample(); + example1.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andApiDefinitionIdEqualTo("apiDefinitionId").andDeletedEqualTo(true); + List caseList1 = apiTestCaseMapper.selectByExample(example1); + caseList1.forEach(apiTestCase -> Assertions.assertTrue(apiTestCase.getDeleted())); } @@ -916,7 +926,6 @@ public class ApiTestCaseControllerTests extends BaseTest { responsePost(BATCH_DELETE, request); request.setProjectId(DEFAULT_PROJECT_ID); request.setSelectAll(true); - request.setModuleIds(List.of("case-moduleId")); request.setApiDefinitionId("apiDefinitionId"); responsePost(BATCH_DELETE, request); ApiTestCaseExample example = new ApiTestCaseExample();