From 13c89fe56b2b45475828a4e4ea4585f9fe6cf21a Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 8 Mar 2022 14:15:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=88=97=E8=A1=A8=E6=9C=AA=E6=8C=89=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E9=97=B4/=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=99=8D=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1010846 --user=李玉号 【系统设置】-环境管理-创建环境-创建成功记录未按创建时间/更新时间降序排列 https://www.tapd.cn/55049933/s/1115069 --- .../service/ApiTestEnvironmentService.java | 5 + .../base/domain/ApiTestEnvironment.java | 4 + .../domain/ApiTestEnvironmentExample.java | 120 ++++++++++++++++++ .../domain/ApiTestEnvironmentWithBLOBs.java | 3 +- .../base/mapper/ApiTestEnvironmentMapper.xml | 53 ++++++-- .../db/migration/V110__v1.19_release.sql | 9 ++ .../src/main/resources/generatorConfig.xml | 31 +++-- 7 files changed, 200 insertions(+), 25 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java index d0d5c3140d..5bcfcf88ae 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -51,6 +51,7 @@ public class ApiTestEnvironmentService { public List list(String projectId) { ApiTestEnvironmentExample example = new ApiTestEnvironmentExample(); example.createCriteria().andProjectIdEqualTo(projectId); + example.setOrderByClause("update_time desc"); return apiTestEnvironmentMapper.selectByExampleWithBLOBs(example); } @@ -65,6 +66,7 @@ public class ApiTestEnvironmentService { environmentRequest.setName(StringUtils.wrapIfMissing(environmentRequest.getName(), '%')); //使搜索文本变成数据库中的正则表达式 criteria.andNameLike(environmentRequest.getName()); } + example.setOrderByClause("update_time desc"); return apiTestEnvironmentMapper.selectByExampleWithBLOBs(example); } @@ -101,6 +103,8 @@ public class ApiTestEnvironmentService { FileUtils.createFiles(request.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl"); //检查Config,判断isMock参数是否给True request = this.updateConfig(request,false); + request.setCreateTime(System.currentTimeMillis()); + request.setUpdateTime(System.currentTimeMillis()); apiTestEnvironmentMapper.insert(request); return request.getId(); } @@ -123,6 +127,7 @@ public class ApiTestEnvironmentService { public void update(ApiTestEnvironmentDTO apiTestEnvironment,List sslFiles) { checkEnvironmentExist(apiTestEnvironment); FileUtils.createFiles(apiTestEnvironment.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl"); + apiTestEnvironment.setUpdateTime(System.currentTimeMillis()); apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment); } private void checkEnvironmentExist(ApiTestEnvironmentWithBLOBs environment) { diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironment.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironment.java index 009ee18358..a8b08239d2 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironment.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironment.java @@ -21,5 +21,9 @@ public class ApiTestEnvironment implements Serializable { private String createUser; + private Long createTime; + + private Long updateTime; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentExample.java index d523ec6b7b..eeaddb1f61 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentExample.java @@ -653,6 +653,126 @@ public class ApiTestEnvironmentExample { addCriterion("create_user not between", value1, value2, "createUser"); return (Criteria) this; } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Long value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Long value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Long value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Long value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Long value1, Long value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentWithBLOBs.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentWithBLOBs.java index 1e00c158a7..d64fe59265 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentWithBLOBs.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestEnvironmentWithBLOBs.java @@ -1,11 +1,10 @@ package io.metersphere.base.domain; +import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.io.Serializable; - @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestEnvironmentMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestEnvironmentMapper.xml index a9c923bf3a..72e936d5be 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiTestEnvironmentMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestEnvironmentMapper.xml @@ -10,6 +10,8 @@ + + @@ -76,7 +78,8 @@ - id, `name`, project_id, protocol, socket, `domain`, port, create_user + id, `name`, project_id, protocol, socket, `domain`, port, create_user, create_time, + update_time `variables`, headers, config, `hosts` @@ -132,14 +135,14 @@ insert into api_test_environment (id, `name`, project_id, protocol, socket, `domain`, - port, create_user, `variables`, - headers, config, `hosts` - ) + port, create_user, create_time, + update_time, `variables`, headers, + config, `hosts`) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, #{socket,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR}, - #{port,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{variables,jdbcType=LONGVARCHAR}, - #{headers,jdbcType=LONGVARCHAR}, #{config,jdbcType=LONGVARCHAR}, #{hosts,jdbcType=LONGVARCHAR} - ) + #{port,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, + #{updateTime,jdbcType=BIGINT}, #{variables,jdbcType=LONGVARCHAR}, #{headers,jdbcType=LONGVARCHAR}, + #{config,jdbcType=LONGVARCHAR}, #{hosts,jdbcType=LONGVARCHAR}) insert into api_test_environment @@ -168,6 +171,12 @@ create_user, + + create_time, + + + update_time, + `variables`, @@ -206,6 +215,12 @@ #{createUser,jdbcType=VARCHAR}, + + #{createTime,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=BIGINT}, + #{variables,jdbcType=LONGVARCHAR}, @@ -253,6 +268,12 @@ create_user = #{record.createUser,jdbcType=VARCHAR}, + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=BIGINT}, + `variables` = #{record.variables,jdbcType=LONGVARCHAR}, @@ -280,6 +301,8 @@ `domain` = #{record.domain,jdbcType=VARCHAR}, port = #{record.port,jdbcType=INTEGER}, create_user = #{record.createUser,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT}, `variables` = #{record.variables,jdbcType=LONGVARCHAR}, headers = #{record.headers,jdbcType=LONGVARCHAR}, config = #{record.config,jdbcType=LONGVARCHAR}, @@ -297,7 +320,9 @@ socket = #{record.socket,jdbcType=VARCHAR}, `domain` = #{record.domain,jdbcType=VARCHAR}, port = #{record.port,jdbcType=INTEGER}, - create_user = #{record.createUser,jdbcType=VARCHAR} + create_user = #{record.createUser,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT} @@ -326,6 +351,12 @@ create_user = #{createUser,jdbcType=VARCHAR}, + + create_time = #{createTime,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + `variables` = #{variables,jdbcType=LONGVARCHAR}, @@ -350,6 +381,8 @@ `domain` = #{domain,jdbcType=VARCHAR}, port = #{port,jdbcType=INTEGER}, create_user = #{createUser,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, `variables` = #{variables,jdbcType=LONGVARCHAR}, headers = #{headers,jdbcType=LONGVARCHAR}, config = #{config,jdbcType=LONGVARCHAR}, @@ -364,7 +397,9 @@ socket = #{socket,jdbcType=VARCHAR}, `domain` = #{domain,jdbcType=VARCHAR}, port = #{port,jdbcType=INTEGER}, - create_user = #{createUser,jdbcType=VARCHAR} + create_user = #{createUser,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/resources/db/migration/V110__v1.19_release.sql b/backend/src/main/resources/db/migration/V110__v1.19_release.sql index 3cdd1115fd..d2115f476e 100644 --- a/backend/src/main/resources/db/migration/V110__v1.19_release.sql +++ b/backend/src/main/resources/db/migration/V110__v1.19_release.sql @@ -642,3 +642,12 @@ alter table project drop column clean_load_report; alter table project drop column clean_load_report_expr; + +alter table api_test_environment + add create_time bigint(13) null; + +alter table api_test_environment + add update_time bigint(13) null; + +update api_test_environment set create_time = unix_timestamp() * 1000 where create_time is null; +update api_test_environment set update_time = unix_timestamp() * 1000 where update_time is null; diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index 2957b36245..3bea2f7187 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -71,20 +71,23 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
+