From 280723aee0620aebb3e21d464e338710993cb7cb Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 18 Jan 2024 16:14:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=94=AF=E6=8C=81=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/domain/ApiReport.java | 8 +- .../api/domain/ApiReportExample.java | 70 ++++++++++++++ .../api/domain/ApiScenarioReport.java | 6 ++ .../api/domain/ApiScenarioReportExample.java | 70 ++++++++++++++ .../api/mapper/ApiReportMapper.xml | 95 +++++++++++-------- .../api/mapper/ApiScenarioReportMapper.xml | 95 +++++++++++-------- .../3.0.0/ddl/V3.0.0_5__api_test.sql | 11 ++- 7 files changed, 277 insertions(+), 78 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java index 324087845c..54d87ce0ba 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java @@ -20,11 +20,16 @@ public class ApiReport implements Serializable { @Size(min = 1, max = 255, message = "{api_report.name.length_range}", groups = {Created.class, Updated.class}) private String name; - @Schema(description = "接口资源fk/api_definition_id/api_test_case_id", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{api_report.resource_id.not_blank}", groups = {Created.class}) @Size(min = 1, max = 50, message = "{api_report.resource_id.length_range}", groups = {Created.class, Updated.class}) private String resourceId; + @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_report.test_plan_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{api_report.test_plan_id.length_range}", groups = {Created.class, Updated.class}) + private String testPlanId; + @Schema(description = "创建人") private String createUser; @@ -138,6 +143,7 @@ public class ApiReport implements Serializable { id("id", "id", "VARCHAR", false), name("name", "name", "VARCHAR", true), resourceId("resource_id", "resourceId", "VARCHAR", false), + testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), createUser("create_user", "createUser", "VARCHAR", false), deleteTime("delete_time", "deleteTime", "BIGINT", false), deleteUser("delete_user", "deleteUser", "VARCHAR", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java index 8f49ddfcb2..7c53d3a2cb 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java @@ -314,6 +314,76 @@ public class ApiReportExample { return (Criteria) this; } + public Criteria andTestPlanIdIsNull() { + addCriterion("test_plan_id is null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIsNotNull() { + addCriterion("test_plan_id is not null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdEqualTo(String value) { + addCriterion("test_plan_id =", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotEqualTo(String value) { + addCriterion("test_plan_id <>", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThan(String value) { + addCriterion("test_plan_id >", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) { + addCriterion("test_plan_id >=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThan(String value) { + addCriterion("test_plan_id <", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThanOrEqualTo(String value) { + addCriterion("test_plan_id <=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLike(String value) { + addCriterion("test_plan_id like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotLike(String value) { + addCriterion("test_plan_id not like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIn(List values) { + addCriterion("test_plan_id in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotIn(List values) { + addCriterion("test_plan_id not in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdBetween(String value1, String value2) { + addCriterion("test_plan_id between", value1, value2, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotBetween(String value1, String value2) { + addCriterion("test_plan_id not between", value1, value2, "testPlanId"); + return (Criteria) this; + } + public Criteria andCreateUserIsNull() { addCriterion("create_user is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java index 269f964a85..d1b574b57f 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java @@ -25,6 +25,11 @@ public class ApiScenarioReport implements Serializable { @Size(min = 1, max = 50, message = "{api_scenario_report.scenario_id.length_range}", groups = {Created.class, Updated.class}) private String scenarioId; + @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_scenario_report.test_plan_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{api_scenario_report.test_plan_id.length_range}", groups = {Created.class, Updated.class}) + private String testPlanId; + @Schema(description = "创建人") private String createUser; @@ -138,6 +143,7 @@ public class ApiScenarioReport implements Serializable { id("id", "id", "VARCHAR", false), name("name", "name", "VARCHAR", true), scenarioId("scenario_id", "scenarioId", "VARCHAR", false), + testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), createUser("create_user", "createUser", "VARCHAR", false), deleteTime("delete_time", "deleteTime", "BIGINT", false), deleteUser("delete_user", "deleteUser", "VARCHAR", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java index 468903b70f..03bf95c4de 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java @@ -314,6 +314,76 @@ public class ApiScenarioReportExample { return (Criteria) this; } + public Criteria andTestPlanIdIsNull() { + addCriterion("test_plan_id is null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIsNotNull() { + addCriterion("test_plan_id is not null"); + return (Criteria) this; + } + + public Criteria andTestPlanIdEqualTo(String value) { + addCriterion("test_plan_id =", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotEqualTo(String value) { + addCriterion("test_plan_id <>", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThan(String value) { + addCriterion("test_plan_id >", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) { + addCriterion("test_plan_id >=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThan(String value) { + addCriterion("test_plan_id <", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLessThanOrEqualTo(String value) { + addCriterion("test_plan_id <=", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdLike(String value) { + addCriterion("test_plan_id like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotLike(String value) { + addCriterion("test_plan_id not like", value, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdIn(List values) { + addCriterion("test_plan_id in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotIn(List values) { + addCriterion("test_plan_id not in", values, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdBetween(String value1, String value2) { + addCriterion("test_plan_id between", value1, value2, "testPlanId"); + return (Criteria) this; + } + + public Criteria andTestPlanIdNotBetween(String value1, String value2) { + addCriterion("test_plan_id not between", value1, value2, "testPlanId"); + return (Criteria) this; + } + public Criteria andCreateUserIsNull() { addCriterion("create_user is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml index 186bf511ca..0646c4b635 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml @@ -5,6 +5,7 @@ + @@ -92,11 +93,11 @@ - id, `name`, resource_id, create_user, delete_time, delete_user, deleted, update_user, - update_time, start_time, end_time, request_duration, `status`, trigger_mode, run_mode, - pool_id, version_id, integrated, project_id, environment_id, error_count, fake_error_count, - pending_count, success_count, assertion_count, assertion_success_count, request_execution_rate, - request_pass_rate, assertion_pass_rate, script_identifier + id, `name`, resource_id, test_plan_id, create_user, delete_time, delete_user, deleted, + update_user, update_time, start_time, end_time, request_duration, `status`, trigger_mode, + run_mode, pool_id, version_id, integrated, project_id, environment_id, error_count, + fake_error_count, pending_count, success_count, assertion_count, assertion_success_count, + request_execution_rate, request_pass_rate, assertion_pass_rate, script_identifier select @@ -130,27 +131,27 @@ insert into api_scenario_report (id, `name`, scenario_id, - create_user, delete_time, delete_user, - deleted, update_user, update_time, - start_time, end_time, request_duration, - `status`, trigger_mode, run_mode, - pool_id, version_id, integrated, - project_id, environment_id, error_count, - fake_error_count, pending_count, success_count, - assertion_count, assertion_success_count, request_execution_rate, - request_pass_rate, assertion_pass_rate, script_identifier - ) + test_plan_id, create_user, delete_time, + delete_user, deleted, update_user, + update_time, start_time, end_time, + request_duration, `status`, trigger_mode, + run_mode, pool_id, version_id, + integrated, project_id, environment_id, + error_count, fake_error_count, pending_count, + success_count, assertion_count, assertion_success_count, + request_execution_rate, request_pass_rate, + assertion_pass_rate, script_identifier) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{scenarioId,jdbcType=VARCHAR}, - #{createUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUser,jdbcType=VARCHAR}, - #{deleted,jdbcType=BIT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, - #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{requestDuration,jdbcType=BIGINT}, - #{status,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{runMode,jdbcType=VARCHAR}, - #{poolId,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{integrated,jdbcType=BIT}, - #{projectId,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR}, #{errorCount,jdbcType=BIGINT}, - #{fakeErrorCount,jdbcType=BIGINT}, #{pendingCount,jdbcType=BIGINT}, #{successCount,jdbcType=BIGINT}, - #{assertionCount,jdbcType=BIGINT}, #{assertionSuccessCount,jdbcType=BIGINT}, #{requestExecutionRate,jdbcType=VARCHAR}, - #{requestPassRate,jdbcType=VARCHAR}, #{assertionPassRate,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR} - ) + #{testPlanId,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, + #{deleteUser,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}, #{updateUser,jdbcType=VARCHAR}, + #{updateTime,jdbcType=BIGINT}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, + #{requestDuration,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, + #{runMode,jdbcType=VARCHAR}, #{poolId,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, + #{integrated,jdbcType=BIT}, #{projectId,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR}, + #{errorCount,jdbcType=BIGINT}, #{fakeErrorCount,jdbcType=BIGINT}, #{pendingCount,jdbcType=BIGINT}, + #{successCount,jdbcType=BIGINT}, #{assertionCount,jdbcType=BIGINT}, #{assertionSuccessCount,jdbcType=BIGINT}, + #{requestExecutionRate,jdbcType=VARCHAR}, #{requestPassRate,jdbcType=VARCHAR}, + #{assertionPassRate,jdbcType=VARCHAR}, #{scriptIdentifier,jdbcType=VARCHAR}) insert into api_scenario_report @@ -164,6 +165,9 @@ scenario_id, + + test_plan_id, + create_user, @@ -256,6 +260,9 @@ #{scenarioId,jdbcType=VARCHAR}, + + #{testPlanId,jdbcType=VARCHAR}, + #{createUser,jdbcType=VARCHAR}, @@ -357,6 +364,9 @@ scenario_id = #{record.scenarioId,jdbcType=VARCHAR}, + + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR}, @@ -448,6 +458,7 @@ set id = #{record.id,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR}, scenario_id = #{record.scenarioId,jdbcType=VARCHAR}, + test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, delete_time = #{record.deleteTime,jdbcType=BIGINT}, delete_user = #{record.deleteUser,jdbcType=VARCHAR}, @@ -488,6 +499,9 @@ scenario_id = #{scenarioId,jdbcType=VARCHAR}, + + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR}, @@ -576,6 +590,7 @@ update api_scenario_report set `name` = #{name,jdbcType=VARCHAR}, scenario_id = #{scenarioId,jdbcType=VARCHAR}, + test_plan_id = #{testPlanId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, delete_time = #{deleteTime,jdbcType=BIGINT}, delete_user = #{deleteUser,jdbcType=VARCHAR}, @@ -607,22 +622,23 @@ insert into api_scenario_report - (id, `name`, scenario_id, create_user, delete_time, delete_user, deleted, update_user, - update_time, start_time, end_time, request_duration, `status`, trigger_mode, run_mode, - pool_id, version_id, integrated, project_id, environment_id, error_count, fake_error_count, - pending_count, success_count, assertion_count, assertion_success_count, request_execution_rate, - request_pass_rate, assertion_pass_rate, script_identifier) + (id, `name`, scenario_id, test_plan_id, create_user, delete_time, delete_user, deleted, + update_user, update_time, start_time, end_time, request_duration, `status`, trigger_mode, + run_mode, pool_id, version_id, integrated, project_id, environment_id, error_count, + fake_error_count, pending_count, success_count, assertion_count, assertion_success_count, + request_execution_rate, request_pass_rate, assertion_pass_rate, script_identifier + ) values (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.scenarioId,jdbcType=VARCHAR}, - #{item.createUser,jdbcType=VARCHAR}, #{item.deleteTime,jdbcType=BIGINT}, #{item.deleteUser,jdbcType=VARCHAR}, - #{item.deleted,jdbcType=BIT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}, - #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, #{item.requestDuration,jdbcType=BIGINT}, - #{item.status,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR}, #{item.runMode,jdbcType=VARCHAR}, - #{item.poolId,jdbcType=VARCHAR}, #{item.versionId,jdbcType=VARCHAR}, #{item.integrated,jdbcType=BIT}, - #{item.projectId,jdbcType=VARCHAR}, #{item.environmentId,jdbcType=VARCHAR}, #{item.errorCount,jdbcType=BIGINT}, - #{item.fakeErrorCount,jdbcType=BIGINT}, #{item.pendingCount,jdbcType=BIGINT}, #{item.successCount,jdbcType=BIGINT}, - #{item.assertionCount,jdbcType=BIGINT}, #{item.assertionSuccessCount,jdbcType=BIGINT}, + #{item.testPlanId,jdbcType=VARCHAR}, #{item.createUser,jdbcType=VARCHAR}, #{item.deleteTime,jdbcType=BIGINT}, + #{item.deleteUser,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.updateUser,jdbcType=VARCHAR}, + #{item.updateTime,jdbcType=BIGINT}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, + #{item.requestDuration,jdbcType=BIGINT}, #{item.status,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR}, + #{item.runMode,jdbcType=VARCHAR}, #{item.poolId,jdbcType=VARCHAR}, #{item.versionId,jdbcType=VARCHAR}, + #{item.integrated,jdbcType=BIT}, #{item.projectId,jdbcType=VARCHAR}, #{item.environmentId,jdbcType=VARCHAR}, + #{item.errorCount,jdbcType=BIGINT}, #{item.fakeErrorCount,jdbcType=BIGINT}, #{item.pendingCount,jdbcType=BIGINT}, + #{item.successCount,jdbcType=BIGINT}, #{item.assertionCount,jdbcType=BIGINT}, #{item.assertionSuccessCount,jdbcType=BIGINT}, #{item.requestExecutionRate,jdbcType=VARCHAR}, #{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR}, #{item.scriptIdentifier,jdbcType=VARCHAR} ) @@ -647,6 +663,9 @@ #{item.scenarioId,jdbcType=VARCHAR} + + #{item.testPlanId,jdbcType=VARCHAR} + #{item.createUser,jdbcType=VARCHAR} 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 bd7e23bd56..1cdcdb504c 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 @@ -101,7 +101,8 @@ CREATE INDEX idx_name ON api_definition(name); CREATE TABLE IF NOT EXISTS api_report( `id` VARCHAR(50) NOT NULL COMMENT '接口报告pk' , `name` VARCHAR(255) NOT NULL COMMENT '接口报告名称' , - `resource_id` VARCHAR(50) NOT NULL COMMENT '接口资源fk/api_definition_id/api_test_case_id' , + `resource_id` VARCHAR(50) NOT NULL COMMENT '用例id' , + `test_plan_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划id' , `create_user` VARCHAR(50) NOT NULL COMMENT '创建人' , `delete_time` BIGINT COMMENT '删除时间' , `delete_user` VARCHAR(50) COMMENT '删除人' , @@ -144,6 +145,10 @@ CREATE INDEX idx_update_time ON api_report(update_time); CREATE INDEX idx_create_user ON api_report(create_user); CREATE INDEX idx_name ON api_report(name); CREATE INDEX idx_pool_id ON api_report(pool_id); +CREATE INDEX idx_start_time ON api_report(start_time); +CREATE INDEX idx_integrated ON api_report(integrated); +CREATE INDEX idx_test_plan_id ON api_report(test_plan_id); +DROP TABLE IF EXISTS api_scenario_report; CREATE TABLE IF NOT EXISTS api_report_step( `step_id` VARCHAR(50) NOT NULL COMMENT '步骤id' , @@ -333,6 +338,7 @@ CREATE TABLE IF NOT EXISTS api_scenario_report( `id` VARCHAR(50) NOT NULL COMMENT '场景报告pk' , `name` VARCHAR(255) NOT NULL COMMENT '报告名称' , `scenario_id` VARCHAR(50) NOT NULL COMMENT '场景fk' , + `test_plan_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划id' , `create_user` VARCHAR(50) NOT NULL COMMENT '创建人' , `delete_time` BIGINT COMMENT '删除时间' , `delete_user` VARCHAR(50) COMMENT '删除人' , @@ -374,6 +380,9 @@ CREATE INDEX idx_update_time ON api_scenario_report(update_time); CREATE INDEX idx_create_user ON api_scenario_report(create_user); CREATE INDEX idx_name ON api_scenario_report(name); CREATE INDEX idx_pool_id ON api_scenario_report(pool_id); +CREATE INDEX idx_integrated ON api_scenario_report(integrated); +CREATE INDEX idx_start_time ON api_scenario_report(start_time); +CREATE INDEX idx_test_plan_id ON api_scenario_report(test_plan_id); CREATE TABLE IF NOT EXISTS api_scenario_report_detail( `id` VARCHAR(50) NOT NULL COMMENT 'ID' ,