refactor(接口测试): 支持场景循环步骤排序

This commit is contained in:
fit2-zhao 2024-03-28 10:47:48 +08:00 committed by Craftsman
parent 203fcaeed6
commit 2157d8670d
4 changed files with 96 additions and 7 deletions

View File

@ -48,6 +48,10 @@ public class ApiScenarioReportDetail implements Serializable {
@Schema(description = "脚本标识") @Schema(description = "脚本标识")
private String scriptIdentifier; private String scriptIdentifier;
@Schema(description = "用于循环请求排序", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{api_scenario_report_detail.sort.not_blank}", groups = {Created.class})
private Long sort;
@Schema(description = "执行结果") @Schema(description = "执行结果")
private byte[] content; private byte[] content;
@ -64,6 +68,7 @@ public class ApiScenarioReportDetail implements Serializable {
code("code", "code", "VARCHAR", false), code("code", "code", "VARCHAR", false),
responseSize("response_size", "responseSize", "BIGINT", false), responseSize("response_size", "responseSize", "BIGINT", false),
scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false), scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false),
sort("sort", "sort", "BIGINT", false),
content("content", "content", "LONGVARBINARY", false); content("content", "content", "LONGVARBINARY", false);
private static final String BEGINNING_DELIMITER = "`"; private static final String BEGINNING_DELIMITER = "`";

View File

@ -783,6 +783,66 @@ public class ApiScenarioReportDetailExample {
addCriterion("script_identifier not between", value1, value2, "scriptIdentifier"); addCriterion("script_identifier not between", value1, value2, "scriptIdentifier");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andSortIsNull() {
addCriterion("sort is null");
return (Criteria) this;
}
public Criteria andSortIsNotNull() {
addCriterion("sort is not null");
return (Criteria) this;
}
public Criteria andSortEqualTo(Long value) {
addCriterion("sort =", value, "sort");
return (Criteria) this;
}
public Criteria andSortNotEqualTo(Long value) {
addCriterion("sort <>", value, "sort");
return (Criteria) this;
}
public Criteria andSortGreaterThan(Long value) {
addCriterion("sort >", value, "sort");
return (Criteria) this;
}
public Criteria andSortGreaterThanOrEqualTo(Long value) {
addCriterion("sort >=", value, "sort");
return (Criteria) this;
}
public Criteria andSortLessThan(Long value) {
addCriterion("sort <", value, "sort");
return (Criteria) this;
}
public Criteria andSortLessThanOrEqualTo(Long value) {
addCriterion("sort <=", value, "sort");
return (Criteria) this;
}
public Criteria andSortIn(List<Long> values) {
addCriterion("sort in", values, "sort");
return (Criteria) this;
}
public Criteria andSortNotIn(List<Long> values) {
addCriterion("sort not in", values, "sort");
return (Criteria) this;
}
public Criteria andSortBetween(Long value1, Long value2) {
addCriterion("sort between", value1, value2, "sort");
return (Criteria) this;
}
public Criteria andSortNotBetween(Long value1, Long value2) {
addCriterion("sort not between", value1, value2, "sort");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -12,6 +12,7 @@
<result column="code" jdbcType="VARCHAR" property="code" /> <result column="code" jdbcType="VARCHAR" property="code" />
<result column="response_size" jdbcType="BIGINT" property="responseSize" /> <result column="response_size" jdbcType="BIGINT" property="responseSize" />
<result column="script_identifier" jdbcType="VARCHAR" property="scriptIdentifier" /> <result column="script_identifier" jdbcType="VARCHAR" property="scriptIdentifier" />
<result column="sort" jdbcType="BIGINT" property="sort" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.api.domain.ApiScenarioReportDetail"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.api.domain.ApiScenarioReportDetail">
<result column="content" jdbcType="LONGVARBINARY" property="content" /> <result column="content" jdbcType="LONGVARBINARY" property="content" />
@ -76,7 +77,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, report_id, step_id, `status`, fake_code, request_name, request_time, code, response_size, id, report_id, step_id, `status`, fake_code, request_name, request_time, code, response_size,
script_identifier script_identifier, sort
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
content content
@ -133,11 +134,13 @@
insert into api_scenario_report_detail (id, report_id, step_id, insert into api_scenario_report_detail (id, report_id, step_id,
`status`, fake_code, request_name, `status`, fake_code, request_name,
request_time, code, response_size, request_time, code, response_size,
script_identifier, content) script_identifier, sort, content
)
values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{stepId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{stepId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{fakeCode,jdbcType=VARCHAR}, #{requestName,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{fakeCode,jdbcType=VARCHAR}, #{requestName,jdbcType=VARCHAR},
#{requestTime,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{responseSize,jdbcType=BIGINT}, #{requestTime,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{responseSize,jdbcType=BIGINT},
#{scriptIdentifier,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARBINARY}) #{scriptIdentifier,jdbcType=VARCHAR}, #{sort,jdbcType=BIGINT}, #{content,jdbcType=LONGVARBINARY}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiScenarioReportDetail"> <insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiScenarioReportDetail">
insert into api_scenario_report_detail insert into api_scenario_report_detail
@ -172,6 +175,9 @@
<if test="scriptIdentifier != null"> <if test="scriptIdentifier != null">
script_identifier, script_identifier,
</if> </if>
<if test="sort != null">
sort,
</if>
<if test="content != null"> <if test="content != null">
content, content,
</if> </if>
@ -207,6 +213,9 @@
<if test="scriptIdentifier != null"> <if test="scriptIdentifier != null">
#{scriptIdentifier,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR},
</if> </if>
<if test="sort != null">
#{sort,jdbcType=BIGINT},
</if>
<if test="content != null"> <if test="content != null">
#{content,jdbcType=LONGVARBINARY}, #{content,jdbcType=LONGVARBINARY},
</if> </if>
@ -251,6 +260,9 @@
<if test="record.scriptIdentifier != null"> <if test="record.scriptIdentifier != null">
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR}, script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
</if> </if>
<if test="record.sort != null">
sort = #{record.sort,jdbcType=BIGINT},
</if>
<if test="record.content != null"> <if test="record.content != null">
content = #{record.content,jdbcType=LONGVARBINARY}, content = #{record.content,jdbcType=LONGVARBINARY},
</if> </if>
@ -271,6 +283,7 @@
code = #{record.code,jdbcType=VARCHAR}, code = #{record.code,jdbcType=VARCHAR},
response_size = #{record.responseSize,jdbcType=BIGINT}, response_size = #{record.responseSize,jdbcType=BIGINT},
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR}, script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARBINARY} content = #{record.content,jdbcType=LONGVARBINARY}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -287,7 +300,8 @@
request_time = #{record.requestTime,jdbcType=BIGINT}, request_time = #{record.requestTime,jdbcType=BIGINT},
code = #{record.code,jdbcType=VARCHAR}, code = #{record.code,jdbcType=VARCHAR},
response_size = #{record.responseSize,jdbcType=BIGINT}, response_size = #{record.responseSize,jdbcType=BIGINT},
script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR} script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=BIGINT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -322,6 +336,9 @@
<if test="scriptIdentifier != null"> <if test="scriptIdentifier != null">
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR}, script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
</if> </if>
<if test="sort != null">
sort = #{sort,jdbcType=BIGINT},
</if>
<if test="content != null"> <if test="content != null">
content = #{content,jdbcType=LONGVARBINARY}, content = #{content,jdbcType=LONGVARBINARY},
</if> </if>
@ -339,6 +356,7 @@
code = #{code,jdbcType=VARCHAR}, code = #{code,jdbcType=VARCHAR},
response_size = #{responseSize,jdbcType=BIGINT}, response_size = #{responseSize,jdbcType=BIGINT},
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR}, script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
sort = #{sort,jdbcType=BIGINT},
content = #{content,jdbcType=LONGVARBINARY} content = #{content,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -352,19 +370,20 @@
request_time = #{requestTime,jdbcType=BIGINT}, request_time = #{requestTime,jdbcType=BIGINT},
code = #{code,jdbcType=VARCHAR}, code = #{code,jdbcType=VARCHAR},
response_size = #{responseSize,jdbcType=BIGINT}, response_size = #{responseSize,jdbcType=BIGINT},
script_identifier = #{scriptIdentifier,jdbcType=VARCHAR} script_identifier = #{scriptIdentifier,jdbcType=VARCHAR},
sort = #{sort,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
insert into api_scenario_report_detail insert into api_scenario_report_detail
(id, report_id, step_id, `status`, fake_code, request_name, request_time, code, response_size, (id, report_id, step_id, `status`, fake_code, request_name, request_time, code, response_size,
script_identifier, content) script_identifier, sort, content)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.reportId,jdbcType=VARCHAR}, #{item.stepId,jdbcType=VARCHAR}, (#{item.id,jdbcType=VARCHAR}, #{item.reportId,jdbcType=VARCHAR}, #{item.stepId,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.fakeCode,jdbcType=VARCHAR}, #{item.requestName,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, #{item.fakeCode,jdbcType=VARCHAR}, #{item.requestName,jdbcType=VARCHAR},
#{item.requestTime,jdbcType=BIGINT}, #{item.code,jdbcType=VARCHAR}, #{item.responseSize,jdbcType=BIGINT}, #{item.requestTime,jdbcType=BIGINT}, #{item.code,jdbcType=VARCHAR}, #{item.responseSize,jdbcType=BIGINT},
#{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.content,jdbcType=LONGVARBINARY} #{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.sort,jdbcType=BIGINT}, #{item.content,jdbcType=LONGVARBINARY}
) )
</foreach> </foreach>
</insert> </insert>
@ -408,6 +427,9 @@
<if test="'script_identifier'.toString() == column.value"> <if test="'script_identifier'.toString() == column.value">
#{item.scriptIdentifier,jdbcType=VARCHAR} #{item.scriptIdentifier,jdbcType=VARCHAR}
</if> </if>
<if test="'sort'.toString() == column.value">
#{item.sort,jdbcType=BIGINT}
</if>
<if test="'content'.toString() == column.value"> <if test="'content'.toString() == column.value">
#{item.content,jdbcType=LONGVARBINARY} #{item.content,jdbcType=LONGVARBINARY}
</if> </if>

View File

@ -396,6 +396,8 @@ CREATE TABLE IF NOT EXISTS api_scenario_report_detail(
`response_size` BIGINT NOT NULL DEFAULT 0 COMMENT '响应内容大小' , `response_size` BIGINT NOT NULL DEFAULT 0 COMMENT '响应内容大小' ,
`script_identifier` VARCHAR(255) COMMENT '脚本标识' , `script_identifier` VARCHAR(255) COMMENT '脚本标识' ,
`content` LONGBLOB COMMENT '执行结果' , `content` LONGBLOB COMMENT '执行结果' ,
`sort` BIGINT NOT NULL COMMENT '用于循环请求排序' ,
PRIMARY KEY (id) PRIMARY KEY (id)
) ENGINE = InnoDB ) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 DEFAULT CHARSET = utf8mb4