From cbe6c19c458eace0dfa6acc9b5068e4fdc7ac60e Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 17 Jan 2024 12:02:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/ApiDefinitionSwagger.java | 4 ++ .../domain/ApiDefinitionSwaggerExample.java | 60 +++++++++++++++++++ .../metersphere/api/domain/ApiScenario.java | 26 ++++---- .../api/domain/ApiScenarioExample.java | 30 ++++++---- .../api/mapper/ApiDefinitionSwaggerMapper.xml | 48 ++++++++++----- .../api/mapper/ApiScenarioMapper.xml | 18 +++--- .../3.0.0/ddl/V3.0.0_5__api_test.sql | 5 +- .../sdk/constants/ApplicationNumScope.java | 1 + .../ApiDefinitionScheduleService.java | 3 + .../definition/ApiDefinitionService.java | 6 ++ .../definition/ApiTestCaseService.java | 33 +++++++++- .../ApiDefinitionControllerTests.java | 59 ++++++++++++++++++ 12 files changed, 241 insertions(+), 52 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwagger.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwagger.java index 0ebb3ba911..b447a71656 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwagger.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwagger.java @@ -15,6 +15,9 @@ public class ApiDefinitionSwagger implements Serializable { @Size(min = 1, max = 50, message = "{api_definition_swagger.id.length_range}", groups = {Created.class, Updated.class}) private String id; + @Schema(description = "业务id") + private Long num; + @Schema(description = "定时任务名称", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{api_definition_swagger.name.not_blank}", groups = {Created.class}) @Size(min = 1, max = 255, message = "{api_definition_swagger.name.length_range}", groups = {Created.class, Updated.class}) @@ -49,6 +52,7 @@ public class ApiDefinitionSwagger implements Serializable { public enum Column { id("id", "id", "VARCHAR", false), + num("num", "num", "BIGINT", false), name("name", "name", "VARCHAR", true), swaggerUrl("swagger_url", "swaggerUrl", "VARCHAR", false), moduleId("module_id", "moduleId", "VARCHAR", false), diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwaggerExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwaggerExample.java index 30013b5c60..e7a8254dea 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwaggerExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiDefinitionSwaggerExample.java @@ -174,6 +174,66 @@ public class ApiDefinitionSwaggerExample { return (Criteria) this; } + public Criteria andNumIsNull() { + addCriterion("num is null"); + return (Criteria) this; + } + + public Criteria andNumIsNotNull() { + addCriterion("num is not null"); + return (Criteria) this; + } + + public Criteria andNumEqualTo(Long value) { + addCriterion("num =", value, "num"); + return (Criteria) this; + } + + public Criteria andNumNotEqualTo(Long value) { + addCriterion("num <>", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThan(Long value) { + addCriterion("num >", value, "num"); + return (Criteria) this; + } + + public Criteria andNumGreaterThanOrEqualTo(Long value) { + addCriterion("num >=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThan(Long value) { + addCriterion("num <", value, "num"); + return (Criteria) this; + } + + public Criteria andNumLessThanOrEqualTo(Long value) { + addCriterion("num <=", value, "num"); + return (Criteria) this; + } + + public Criteria andNumIn(List values) { + addCriterion("num in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumNotIn(List values) { + addCriterion("num not in", values, "num"); + return (Criteria) this; + } + + public Criteria andNumBetween(Long value1, Long value2) { + addCriterion("num between", value1, value2, "num"); + return (Criteria) this; + } + + public Criteria andNumNotBetween(Long value1, Long value2) { + addCriterion("num not between", value1, value2, "num"); + return (Criteria) this; + } + public Criteria andNameIsNull() { addCriterion("`name` is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenario.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenario.java index 78bb2929c0..b489b45009 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenario.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenario.java @@ -1,16 +1,13 @@ package io.metersphere.api.domain; -import io.metersphere.validation.groups.Created; -import io.metersphere.validation.groups.Updated; +import io.metersphere.validation.groups.*; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import lombok.Data; - +import jakarta.validation.constraints.*; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; +import lombok.Data; @Data public class ApiScenario implements Serializable { @@ -38,14 +35,13 @@ public class ApiScenario implements Serializable { @NotNull(message = "{api_scenario.step_total.not_blank}", groups = {Created.class}) private Integer stepTotal; - @Schema(description = "请求执行率", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{api_scenario.request_execution_rate.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 255, message = "{api_scenario.request_execution_rate.length_range}", groups = {Created.class, Updated.class}) + @Schema(description = "请求执行率") private String requestExecutionRate; - @Schema(description = "通过率", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "{api_scenario.request_pass_rate.not_blank}", groups = {Created.class}) - private Long requestPassRate; + @Schema(description = "请求通过率", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_scenario.request_pass_rate.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 20, message = "{api_scenario.request_pass_rate.length_range}", groups = {Created.class, Updated.class}) + private String requestPassRate; @Schema(description = "最后一次执行的结果状态") private String lastReportStatus; @@ -125,7 +121,7 @@ public class ApiScenario implements Serializable { status("status", "status", "VARCHAR", true), stepTotal("step_total", "stepTotal", "INTEGER", false), requestExecutionRate("request_execution_rate", "requestExecutionRate", "VARCHAR", false), - requestPassRate("request_pass_rate", "requestPassRate", "BIGINT", false), + requestPassRate("request_pass_rate", "requestPassRate", "VARCHAR", false), lastReportStatus("last_report_status", "lastReportStatus", "VARCHAR", false), lastReportId("last_report_id", "lastReportId", "VARCHAR", false), num("num", "num", "BIGINT", false), @@ -189,7 +185,7 @@ public class ApiScenario implements Serializable { return this.getEscapedColumnName() + " ASC"; } - public static Column[] excludes(Column... excludes) { + 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))); diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioExample.java index e4a7ab6ee5..b9a92027ef 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioExample.java @@ -558,52 +558,62 @@ public class ApiScenarioExample { return (Criteria) this; } - public Criteria andRequestPassRateEqualTo(Long value) { + public Criteria andRequestPassRateEqualTo(String value) { addCriterion("request_pass_rate =", value, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateNotEqualTo(Long value) { + public Criteria andRequestPassRateNotEqualTo(String value) { addCriterion("request_pass_rate <>", value, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateGreaterThan(Long value) { + public Criteria andRequestPassRateGreaterThan(String value) { addCriterion("request_pass_rate >", value, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateGreaterThanOrEqualTo(Long value) { + public Criteria andRequestPassRateGreaterThanOrEqualTo(String value) { addCriterion("request_pass_rate >=", value, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateLessThan(Long value) { + public Criteria andRequestPassRateLessThan(String value) { addCriterion("request_pass_rate <", value, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateLessThanOrEqualTo(Long value) { + public Criteria andRequestPassRateLessThanOrEqualTo(String value) { addCriterion("request_pass_rate <=", value, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateIn(List values) { + public Criteria andRequestPassRateLike(String value) { + addCriterion("request_pass_rate like", value, "requestPassRate"); + return (Criteria) this; + } + + public Criteria andRequestPassRateNotLike(String value) { + addCriterion("request_pass_rate not like", value, "requestPassRate"); + return (Criteria) this; + } + + public Criteria andRequestPassRateIn(List values) { addCriterion("request_pass_rate in", values, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateNotIn(List values) { + public Criteria andRequestPassRateNotIn(List values) { addCriterion("request_pass_rate not in", values, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateBetween(Long value1, Long value2) { + public Criteria andRequestPassRateBetween(String value1, String value2) { addCriterion("request_pass_rate between", value1, value2, "requestPassRate"); return (Criteria) this; } - public Criteria andRequestPassRateNotBetween(Long value1, Long value2) { + public Criteria andRequestPassRateNotBetween(String value1, String value2) { addCriterion("request_pass_rate not between", value1, value2, "requestPassRate"); return (Criteria) this; } diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionSwaggerMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionSwaggerMapper.xml index 27c9cfa8f3..bf7168471f 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionSwaggerMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiDefinitionSwaggerMapper.xml @@ -3,6 +3,7 @@ + @@ -71,7 +72,7 @@ - id, `name`, swagger_url, module_id, config, cover_data, cover_module, project_id, + id, num, `name`, swagger_url, module_id, config, cover_data, cover_module, project_id, version_id