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 bd9643d928..19acdedbc7 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 @@ -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), diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockConfig.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockConfig.java index c5bd88d823..908b0e17b2 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockConfig.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionMockConfig.java @@ -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 = "`"; 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 81eac38045..6db7d015a1 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 @@ -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 values) { - addCriterion("api_path in", values, "apiPath"); - return (Criteria) this; - } - - public Criteria andApiPathNotIn(List 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 values) { - addCriterion("api_method in", values, "apiMethod"); - return (Criteria) this; - } - - public Criteria andApiMethodNotIn(List 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; diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockConfigMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockConfigMapper.xml index bebceaf087..5aebf39e70 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockConfigMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionMockConfigMapper.xml @@ -5,7 +5,7 @@ - + @@ -70,7 +70,7 @@ id - request, response + matching, response select @@ -108,14 +106,14 @@ - 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 into api_definition_mock @@ -123,12 +121,6 @@ id, - - api_path, - - - api_method, - create_time, @@ -161,12 +153,6 @@ #{id,jdbcType=VARCHAR}, - - #{apiPath,jdbcType=VARCHAR}, - - - #{apiMethod,jdbcType=VARCHAR}, - #{createTime,jdbcType=BIGINT}, @@ -208,12 +194,6 @@ id = #{record.id,jdbcType=VARCHAR}, - - api_path = #{record.apiPath,jdbcType=VARCHAR}, - - - api_method = #{record.apiMethod,jdbcType=VARCHAR}, - create_time = #{record.createTime,jdbcType=BIGINT}, @@ -249,8 +229,6 @@ 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 api_definition_mock - - api_path = #{apiPath,jdbcType=VARCHAR}, - - - api_method = #{apiMethod,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=BIGINT}, @@ -305,9 +277,7 @@ 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 @@ 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 - (#{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}) @@ -344,12 +313,6 @@ #{item.id,jdbcType=VARCHAR} - - #{item.apiPath,jdbcType=VARCHAR} - - - #{item.apiMethod,jdbcType=VARCHAR} - #{item.createTime,jdbcType=BIGINT} 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 d6ac709eb6..35a734b510 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 @@ -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 '主键' , diff --git a/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml b/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml index 60bcbb3d43..5bc06be643 100644 --- a/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml +++ b/backend/services/api-test/src/main/resources/apiGeneratorConfig.xml @@ -97,6 +97,9 @@
+
+
+