diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioBlob.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioBlob.java new file mode 100644 index 0000000000..80d4ffe4b5 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioBlob.java @@ -0,0 +1,95 @@ +package io.metersphere.api.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 ApiScenarioBlob implements Serializable { + @Schema(description = "场景pk", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_scenario_blob.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{api_scenario_blob.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(description = "场景配置信息", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{api_scenario_blob.config.not_blank}", groups = {Created.class}) + private byte[] config; + + private static final long serialVersionUID = 1L; + + public enum Column { + id("id", "id", "VARCHAR", false), + config("config", "config", "LONGVARBINARY", 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/api/domain/ApiScenarioBlobExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioBlobExample.java new file mode 100644 index 0000000000..38da7bca8a --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioBlobExample.java @@ -0,0 +1,270 @@ +package io.metersphere.api.domain; + +import java.util.ArrayList; +import java.util.List; + +public class ApiScenarioBlobExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public ApiScenarioBlobExample() { + 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 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/api/mapper/ApiScenarioBlobMapper.java b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioBlobMapper.java new file mode 100644 index 0000000000..a2fbf330cc --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioBlobMapper.java @@ -0,0 +1,38 @@ +package io.metersphere.api.mapper; + +import io.metersphere.api.domain.ApiScenarioBlob; +import io.metersphere.api.domain.ApiScenarioBlobExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface ApiScenarioBlobMapper { + long countByExample(ApiScenarioBlobExample example); + + int deleteByExample(ApiScenarioBlobExample example); + + int deleteByPrimaryKey(String id); + + int insert(ApiScenarioBlob record); + + int insertSelective(ApiScenarioBlob record); + + List selectByExampleWithBLOBs(ApiScenarioBlobExample example); + + List selectByExample(ApiScenarioBlobExample example); + + ApiScenarioBlob selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") ApiScenarioBlob record, @Param("example") ApiScenarioBlobExample example); + + int updateByExampleWithBLOBs(@Param("record") ApiScenarioBlob record, @Param("example") ApiScenarioBlobExample example); + + int updateByExample(@Param("record") ApiScenarioBlob record, @Param("example") ApiScenarioBlobExample example); + + int updateByPrimaryKeySelective(ApiScenarioBlob record); + + int updateByPrimaryKeyWithBLOBs(ApiScenarioBlob record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") ApiScenarioBlob.Column ... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioBlobMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioBlobMapper.xml new file mode 100644 index 0000000000..0d3e7e6650 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioBlobMapper.xml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + 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 + + + config + + + + + + delete from api_scenario_blob + where id = #{id,jdbcType=VARCHAR} + + + delete from api_scenario_blob + + + + + + insert into api_scenario_blob (id, config) + values (#{id,jdbcType=VARCHAR}, #{config,jdbcType=LONGVARBINARY}) + + + insert into api_scenario_blob + + + id, + + + config, + + + + + #{id,jdbcType=VARCHAR}, + + + #{config,jdbcType=LONGVARBINARY}, + + + + + + update api_scenario_blob + + + id = #{record.id,jdbcType=VARCHAR}, + + + config = #{record.config,jdbcType=LONGVARBINARY}, + + + + + + + + update api_scenario_blob + set id = #{record.id,jdbcType=VARCHAR}, + config = #{record.config,jdbcType=LONGVARBINARY} + + + + + + update api_scenario_blob + set id = #{record.id,jdbcType=VARCHAR} + + + + + + update api_scenario_blob + + + config = #{config,jdbcType=LONGVARBINARY}, + + + where id = #{id,jdbcType=VARCHAR} + + + update api_scenario_blob + set config = #{config,jdbcType=LONGVARBINARY} + where id = #{id,jdbcType=VARCHAR} + + + insert into api_scenario_blob + (id, config) + values + + (#{item.id,jdbcType=VARCHAR}, #{item.config,jdbcType=LONGVARBINARY}) + + + + insert into api_scenario_blob ( + + ${column.escapedColumnName} + + ) + values + + ( + + + #{item.id,jdbcType=VARCHAR} + + + #{item.config,jdbcType=LONGVARBINARY} + + + ) + + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_5__api_test.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_5__api_test.sql index 3cb3667c05..deb191973a 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_5__api_test.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_5__api_test.sql @@ -524,12 +524,12 @@ CREATE TABLE IF NOT EXISTS api_report_blob( COLLATE = utf8mb4_general_ci COMMENT = 'API/CASE执行结果详情'; CREATE TABLE IF NOT EXISTS api_scenario_blob( - `id` VARCHAR(50) NOT NULL COMMENT '场景pk' , - `content` LONGBLOB COMMENT '场景步骤内容' , + `id` VARCHAR(50) NOT NULL COMMENT '场景pk' , + `config` LONGBLOB COMMENT '场景配置信息' , PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT = '场景步骤详情'; + COLLATE = utf8mb4_general_ci COMMENT = '场景配置信息等详情'; CREATE TABLE IF NOT EXISTS api_test_case_blob( `id` VARCHAR(50) NOT NULL COMMENT '接口用例pk' , diff --git a/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml b/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml index 6407a452c9..52ce0ae23e 100644 --- a/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml +++ b/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml @@ -88,6 +88,7 @@
+
diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/config/interceptor/ApiTestInterceptor.java b/backend/services/system-setting/src/main/java/io/metersphere/system/config/interceptor/ApiTestInterceptor.java index 4bfa241b34..f1e43bacac 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/config/interceptor/ApiTestInterceptor.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/config/interceptor/ApiTestInterceptor.java @@ -27,6 +27,8 @@ public class ApiTestInterceptor { configList.add(new MybatisInterceptorConfig(ApiReportDetail.class, "content", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(ApiReportLog.class, "console", CompressUtils.class, "zip", "unzip")); // ApiScenarioBlob + configList.add(new MybatisInterceptorConfig(ApiScenarioBlob.class, "config", CompressUtils.class, "zip", "unzip")); + // ApiScenarioStepBlob configList.add(new MybatisInterceptorConfig(ApiScenarioStepBlob.class, "content", CompressUtils.class, "zip", "unzip")); // ApiScenarioReportBlob configList.add(new MybatisInterceptorConfig(ApiScenarioReportDetail.class, "content", CompressUtils.class, "zip", "unzip"));