build(接口测试): 调整mock对应表结构

This commit is contained in:
fit2-zhao 2023-12-05 10:17:11 +08:00 committed by Craftsman
parent 970c9cf053
commit 2ee166f00e
7 changed files with 65 additions and 247 deletions

View File

@ -15,12 +15,6 @@ public class ApiDefinitionMock implements Serializable {
@Size(min = 1, max = 50, message = "{api_definition_mock.id.length_range}", groups = {Created.class, Updated.class})
private String id;
@Schema(description = "接口路径")
private String apiPath;
@Schema(description = "接口类型")
private String apiMethod;
@Schema(description = "创建时间")
private Long createTime;
@ -30,7 +24,7 @@ public class ApiDefinitionMock implements Serializable {
@Schema(description = "创建人")
private String createUser;
@Schema(description = "mock 名称", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "mock名称", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{api_definition_mock.name.not_blank}", groups = {Created.class})
@Size(min = 1, max = 200, message = "{api_definition_mock.name.length_range}", groups = {Created.class, Updated.class})
private String name;
@ -60,8 +54,6 @@ public class ApiDefinitionMock implements Serializable {
public enum Column {
id("id", "id", "VARCHAR", false),
apiPath("api_path", "apiPath", "VARCHAR", false),
apiMethod("api_method", "apiMethod", "VARCHAR", false),
createTime("create_time", "createTime", "BIGINT", false),
updateTime("update_time", "updateTime", "BIGINT", false),
createUser("create_user", "createUser", "VARCHAR", false),

View File

@ -10,13 +10,13 @@ import lombok.Data;
@Data
public class ApiDefinitionMockConfig implements Serializable {
@Schema(description = "接口mock pk", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "mock pk", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{api_definition_mock_config.id.not_blank}", groups = {Updated.class})
@Size(min = 1, max = 50, message = "{api_definition_mock_config.id.length_range}", groups = {Created.class, Updated.class})
private String id;
@Schema(description = "请求内容")
private byte[] request;
@Schema(description = "匹配规则")
private byte[] matching;
@Schema(description = "响应内容")
private byte[] response;
@ -25,7 +25,7 @@ public class ApiDefinitionMockConfig implements Serializable {
public enum Column {
id("id", "id", "VARCHAR", false),
request("request", "request", "LONGVARBINARY", false),
matching("matching", "matching", "LONGVARBINARY", false),
response("response", "response", "LONGVARBINARY", false);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -174,146 +174,6 @@ public class ApiDefinitionMockExample {
return (Criteria) this;
}
public Criteria andApiPathIsNull() {
addCriterion("api_path is null");
return (Criteria) this;
}
public Criteria andApiPathIsNotNull() {
addCriterion("api_path is not null");
return (Criteria) this;
}
public Criteria andApiPathEqualTo(String value) {
addCriterion("api_path =", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathNotEqualTo(String value) {
addCriterion("api_path <>", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathGreaterThan(String value) {
addCriterion("api_path >", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathGreaterThanOrEqualTo(String value) {
addCriterion("api_path >=", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathLessThan(String value) {
addCriterion("api_path <", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathLessThanOrEqualTo(String value) {
addCriterion("api_path <=", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathLike(String value) {
addCriterion("api_path like", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathNotLike(String value) {
addCriterion("api_path not like", value, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathIn(List<String> values) {
addCriterion("api_path in", values, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathNotIn(List<String> values) {
addCriterion("api_path not in", values, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathBetween(String value1, String value2) {
addCriterion("api_path between", value1, value2, "apiPath");
return (Criteria) this;
}
public Criteria andApiPathNotBetween(String value1, String value2) {
addCriterion("api_path not between", value1, value2, "apiPath");
return (Criteria) this;
}
public Criteria andApiMethodIsNull() {
addCriterion("api_method is null");
return (Criteria) this;
}
public Criteria andApiMethodIsNotNull() {
addCriterion("api_method is not null");
return (Criteria) this;
}
public Criteria andApiMethodEqualTo(String value) {
addCriterion("api_method =", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodNotEqualTo(String value) {
addCriterion("api_method <>", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodGreaterThan(String value) {
addCriterion("api_method >", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodGreaterThanOrEqualTo(String value) {
addCriterion("api_method >=", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodLessThan(String value) {
addCriterion("api_method <", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodLessThanOrEqualTo(String value) {
addCriterion("api_method <=", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodLike(String value) {
addCriterion("api_method like", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodNotLike(String value) {
addCriterion("api_method not like", value, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodIn(List<String> values) {
addCriterion("api_method in", values, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodNotIn(List<String> values) {
addCriterion("api_method not in", values, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodBetween(String value1, String value2) {
addCriterion("api_method between", value1, value2, "apiMethod");
return (Criteria) this;
}
public Criteria andApiMethodNotBetween(String value1, String value2) {
addCriterion("api_method not between", value1, value2, "apiMethod");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;

View File

@ -5,7 +5,7 @@
<id column="id" jdbcType="VARCHAR" property="id" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.api.domain.ApiDefinitionMockConfig">
<result column="request" jdbcType="LONGVARBINARY" property="request" />
<result column="matching" jdbcType="LONGVARBINARY" property="matching" />
<result column="response" jdbcType="LONGVARBINARY" property="response" />
</resultMap>
<sql id="Example_Where_Clause">
@ -70,7 +70,7 @@
id
</sql>
<sql id="Blob_Column_List">
request, response
matching, response
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.api.domain.ApiDefinitionMockConfigExample" resultMap="ResultMapWithBLOBs">
select
@ -121,9 +121,9 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.api.domain.ApiDefinitionMockConfig">
insert into api_definition_mock_config (id, request, response
insert into api_definition_mock_config (id, matching, response
)
values (#{id,jdbcType=VARCHAR}, #{request,jdbcType=LONGVARBINARY}, #{response,jdbcType=LONGVARBINARY}
values (#{id,jdbcType=VARCHAR}, #{matching,jdbcType=LONGVARBINARY}, #{response,jdbcType=LONGVARBINARY}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiDefinitionMockConfig">
@ -132,8 +132,8 @@
<if test="id != null">
id,
</if>
<if test="request != null">
request,
<if test="matching != null">
matching,
</if>
<if test="response != null">
response,
@ -143,8 +143,8 @@
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="request != null">
#{request,jdbcType=LONGVARBINARY},
<if test="matching != null">
#{matching,jdbcType=LONGVARBINARY},
</if>
<if test="response != null">
#{response,jdbcType=LONGVARBINARY},
@ -163,8 +163,8 @@
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.request != null">
request = #{record.request,jdbcType=LONGVARBINARY},
<if test="record.matching != null">
matching = #{record.matching,jdbcType=LONGVARBINARY},
</if>
<if test="record.response != null">
response = #{record.response,jdbcType=LONGVARBINARY},
@ -177,7 +177,7 @@
<update id="updateByExampleWithBLOBs" parameterType="map">
update api_definition_mock_config
set id = #{record.id,jdbcType=VARCHAR},
request = #{record.request,jdbcType=LONGVARBINARY},
matching = #{record.matching,jdbcType=LONGVARBINARY},
response = #{record.response,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -193,8 +193,8 @@
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.api.domain.ApiDefinitionMockConfig">
update api_definition_mock_config
<set>
<if test="request != null">
request = #{request,jdbcType=LONGVARBINARY},
<if test="matching != null">
matching = #{matching,jdbcType=LONGVARBINARY},
</if>
<if test="response != null">
response = #{response,jdbcType=LONGVARBINARY},
@ -204,16 +204,16 @@
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.api.domain.ApiDefinitionMockConfig">
update api_definition_mock_config
set request = #{request,jdbcType=LONGVARBINARY},
set matching = #{matching,jdbcType=LONGVARBINARY},
response = #{response,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
insert into api_definition_mock_config
(id, request, response)
(id, matching, response)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.request,jdbcType=LONGVARBINARY}, #{item.response,jdbcType=LONGVARBINARY}
(#{item.id,jdbcType=VARCHAR}, #{item.matching,jdbcType=LONGVARBINARY}, #{item.response,jdbcType=LONGVARBINARY}
)
</foreach>
</insert>
@ -230,8 +230,8 @@
<if test="'id'.toString() == column.value">
#{item.id,jdbcType=VARCHAR}
</if>
<if test="'request'.toString() == column.value">
#{item.request,jdbcType=LONGVARBINARY}
<if test="'matching'.toString() == column.value">
#{item.matching,jdbcType=LONGVARBINARY}
</if>
<if test="'response'.toString() == column.value">
#{item.response,jdbcType=LONGVARBINARY}

View File

@ -3,8 +3,6 @@
<mapper namespace="io.metersphere.api.mapper.ApiDefinitionMockMapper">
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiDefinitionMock">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="api_path" jdbcType="VARCHAR" property="apiPath" />
<result column="api_method" jdbcType="VARCHAR" property="apiMethod" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
@ -74,8 +72,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, api_path, api_method, create_time, update_time, create_user, `name`, tags, `enable`,
expect_num, project_id, api_definition_id
id, create_time, update_time, create_user, `name`, tags, `enable`, expect_num, project_id,
api_definition_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiDefinitionMockExample" resultMap="BaseResultMap">
select
@ -108,14 +106,14 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.api.domain.ApiDefinitionMock">
insert into api_definition_mock (id, api_path, api_method,
create_time, update_time, create_user,
`name`, tags, `enable`, expect_num,
project_id, api_definition_id)
values (#{id,jdbcType=VARCHAR}, #{apiPath,jdbcType=VARCHAR}, #{apiMethod,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{enable,jdbcType=BIT}, #{expectNum,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR})
insert into api_definition_mock (id, create_time, update_time,
create_user, `name`, tags,
`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},
#{enable,jdbcType=BIT}, #{expectNum,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
#{apiDefinitionId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiDefinitionMock">
insert into api_definition_mock
@ -123,12 +121,6 @@
<if test="id != null">
id,
</if>
<if test="apiPath != null">
api_path,
</if>
<if test="apiMethod != null">
api_method,
</if>
<if test="createTime != null">
create_time,
</if>
@ -161,12 +153,6 @@
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="apiPath != null">
#{apiPath,jdbcType=VARCHAR},
</if>
<if test="apiMethod != null">
#{apiMethod,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
@ -208,12 +194,6 @@
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.apiPath != null">
api_path = #{record.apiPath,jdbcType=VARCHAR},
</if>
<if test="record.apiMethod != null">
api_method = #{record.apiMethod,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
@ -249,8 +229,6 @@
<update id="updateByExample" parameterType="map">
update api_definition_mock
set id = #{record.id,jdbcType=VARCHAR},
api_path = #{record.apiPath,jdbcType=VARCHAR},
api_method = #{record.apiMethod,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR},
@ -267,12 +245,6 @@
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.api.domain.ApiDefinitionMock">
update api_definition_mock
<set>
<if test="apiPath != null">
api_path = #{apiPath,jdbcType=VARCHAR},
</if>
<if test="apiMethod != null">
api_method = #{apiMethod,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
@ -305,9 +277,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.api.domain.ApiDefinitionMock">
update api_definition_mock
set api_path = #{apiPath,jdbcType=VARCHAR},
api_method = #{apiMethod,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
set create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
@ -320,15 +290,14 @@
</update>
<insert id="batchInsert" parameterType="map">
insert into api_definition_mock
(id, api_path, api_method, create_time, update_time, create_user, `name`, tags, `enable`,
expect_num, project_id, api_definition_id)
(id, create_time, update_time, create_user, `name`, tags, `enable`, expect_num, project_id,
api_definition_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.apiPath,jdbcType=VARCHAR}, #{item.apiMethod,jdbcType=VARCHAR},
#{item.createTime,jdbcType=BIGINT}, #{item.updateTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR}, #{item.tags,jdbcType=VARCHAR}, #{item.enable,jdbcType=BIT},
#{item.expectNum,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.apiDefinitionId,jdbcType=VARCHAR}
)
(#{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.enable,jdbcType=BIT}, #{item.expectNum,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR},
#{item.apiDefinitionId,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -344,12 +313,6 @@
<if test="'id'.toString() == column.value">
#{item.id,jdbcType=VARCHAR}
</if>
<if test="'api_path'.toString() == column.value">
#{item.apiPath,jdbcType=VARCHAR}
</if>
<if test="'api_method'.toString() == column.value">
#{item.apiMethod,jdbcType=VARCHAR}
</if>
<if test="'create_time'.toString() == column.value">
#{item.createTime,jdbcType=BIGINT}
</if>

View File

@ -391,35 +391,35 @@ CREATE TABLE IF NOT EXISTS api_test_case_follower(
COLLATE = utf8mb4_general_ci COMMENT = '接口用例关注人';
CREATE TABLE IF NOT EXISTS api_definition_mock(
`id` VARCHAR(50) NOT NULL COMMENT 'mock pk' ,
`api_path` VARCHAR(500) COMMENT '接口路径' ,
`api_method` VARCHAR(50) COMMENT '接口类型' ,
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
`update_time` BIGINT NOT NULL COMMENT '修改时间' ,
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
`name` VARCHAR(200) NOT NULL COMMENT 'mock 名称' ,
`tags` VARCHAR(500) COMMENT '自定义标签' ,
`enable` BIT(1) NOT NULL DEFAULT 1 COMMENT '启用/禁用' ,
`expect_num` VARCHAR(50) NOT NULL COMMENT 'mock编号' ,
`project_id` VARCHAR(50) NOT NULL COMMENT '项目fk' ,
`api_definition_id` VARCHAR(50) NOT NULL COMMENT '接口fk' ,
PRIMARY KEY (id)
) ENGINE = InnoDB
`id` VARCHAR(50) NOT NULL COMMENT 'mock pk' ,
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
`update_time` BIGINT NOT NULL COMMENT '修改时间' ,
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
`name` VARCHAR(200) NOT NULL COMMENT 'mock名称' ,
`tags` VARCHAR(500) COMMENT '自定义标签' ,
`enable` BIT(1) NOT NULL DEFAULT 1 COMMENT '启用/禁用' ,
`expect_num` VARCHAR(50) NOT NULL COMMENT 'mock编号' ,
`project_id` VARCHAR(50) NOT NULL COMMENT '项目fk' ,
`api_definition_id` VARCHAR(50) NOT NULL COMMENT '接口fk' ,
PRIMARY KEY (id)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = 'mock 配置-暂留';
COLLATE = utf8mb4_general_ci COMMENT = 'mock配置';
CREATE INDEX idx_api_definition_id ON api_definition_mock(api_definition_id);
CREATE INDEX idx_project_id ON api_definition_mock(project_id);
CREATE TABLE IF NOT EXISTS api_definition_mock_config(
`id` VARCHAR(50) NOT NULL COMMENT '接口mock pk' ,
`request` LONGBLOB COMMENT '请求内容' ,
`response` LONGBLOB COMMENT '响应内容' ,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = 'mock期望值配置-暂留';
`id` VARCHAR(50) NOT NULL COMMENT 'mock pk' ,
`matching` LONGBLOB COMMENT '匹配规则' ,
`response` LONGBLOB COMMENT '响应内容' ,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci
COMMENT = 'mock期望值配置';
CREATE TABLE IF NOT EXISTS api_definition_swagger(
`id` VARCHAR(50) NOT NULL COMMENT '主键' ,

View File

@ -97,6 +97,9 @@
<table tableName="api_test_case"/>
<table tableName="api_test_case_blob"/>
<table tableName="api_test_case_follower"/>
<table tableName="api_definition_mock"/>
<table tableName="api_definition_mock_config"/>
</context>
</generatorConfiguration>