fix(系统设置): 环境列表未按创建时间/更新时间降序排列

--bug=1010846 --user=李玉号 【系统设置】-环境管理-创建环境-创建成功记录未按创建时间/更新时间降序排列
https://www.tapd.cn/55049933/s/1115069
This commit is contained in:
shiziyuan9527 2022-03-08 14:15:27 +08:00 committed by shiziyuan9527
parent 0c8d75080b
commit 13c89fe56b
7 changed files with 200 additions and 25 deletions

View File

@ -51,6 +51,7 @@ public class ApiTestEnvironmentService {
public List<ApiTestEnvironmentWithBLOBs> list(String projectId) { public List<ApiTestEnvironmentWithBLOBs> list(String projectId) {
ApiTestEnvironmentExample example = new ApiTestEnvironmentExample(); ApiTestEnvironmentExample example = new ApiTestEnvironmentExample();
example.createCriteria().andProjectIdEqualTo(projectId); example.createCriteria().andProjectIdEqualTo(projectId);
example.setOrderByClause("update_time desc");
return apiTestEnvironmentMapper.selectByExampleWithBLOBs(example); return apiTestEnvironmentMapper.selectByExampleWithBLOBs(example);
} }
@ -65,6 +66,7 @@ public class ApiTestEnvironmentService {
environmentRequest.setName(StringUtils.wrapIfMissing(environmentRequest.getName(), '%')); //使搜索文本变成数据库中的正则表达式 environmentRequest.setName(StringUtils.wrapIfMissing(environmentRequest.getName(), '%')); //使搜索文本变成数据库中的正则表达式
criteria.andNameLike(environmentRequest.getName()); criteria.andNameLike(environmentRequest.getName());
} }
example.setOrderByClause("update_time desc");
return apiTestEnvironmentMapper.selectByExampleWithBLOBs(example); return apiTestEnvironmentMapper.selectByExampleWithBLOBs(example);
} }
@ -101,6 +103,8 @@ public class ApiTestEnvironmentService {
FileUtils.createFiles(request.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl"); FileUtils.createFiles(request.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl");
//检查Config判断isMock参数是否给True //检查Config判断isMock参数是否给True
request = this.updateConfig(request,false); request = this.updateConfig(request,false);
request.setCreateTime(System.currentTimeMillis());
request.setUpdateTime(System.currentTimeMillis());
apiTestEnvironmentMapper.insert(request); apiTestEnvironmentMapper.insert(request);
return request.getId(); return request.getId();
} }
@ -123,6 +127,7 @@ public class ApiTestEnvironmentService {
public void update(ApiTestEnvironmentDTO apiTestEnvironment,List<MultipartFile> sslFiles) { public void update(ApiTestEnvironmentDTO apiTestEnvironment,List<MultipartFile> sslFiles) {
checkEnvironmentExist(apiTestEnvironment); checkEnvironmentExist(apiTestEnvironment);
FileUtils.createFiles(apiTestEnvironment.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl"); FileUtils.createFiles(apiTestEnvironment.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl");
apiTestEnvironment.setUpdateTime(System.currentTimeMillis());
apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment); apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment);
} }
private void checkEnvironmentExist(ApiTestEnvironmentWithBLOBs environment) { private void checkEnvironmentExist(ApiTestEnvironmentWithBLOBs environment) {

View File

@ -21,5 +21,9 @@ public class ApiTestEnvironment implements Serializable {
private String createUser; private String createUser;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -653,6 +653,126 @@ public class ApiTestEnvironmentExample {
addCriterion("create_user not between", value1, value2, "createUser"); addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this; 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<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> 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<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> 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 { public static class Criteria extends GeneratedCriteria {

View File

@ -1,11 +1,10 @@
package io.metersphere.base.domain; package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import java.io.Serializable;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)

View File

@ -10,6 +10,8 @@
<result column="domain" jdbcType="VARCHAR" property="domain" /> <result column="domain" jdbcType="VARCHAR" property="domain" />
<result column="port" jdbcType="INTEGER" property="port" /> <result column="port" jdbcType="INTEGER" property="port" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" /> <result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs">
<result column="variables" jdbcType="LONGVARCHAR" property="variables" /> <result column="variables" jdbcType="LONGVARCHAR" property="variables" />
@ -76,7 +78,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `name`, project_id, protocol, socket, `domain`, port, create_user id, `name`, project_id, protocol, socket, `domain`, port, create_user, create_time,
update_time
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
`variables`, headers, config, `hosts` `variables`, headers, config, `hosts`
@ -132,14 +135,14 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs"> <insert id="insert" parameterType="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs">
insert into api_test_environment (id, `name`, project_id, insert into api_test_environment (id, `name`, project_id,
protocol, socket, `domain`, protocol, socket, `domain`,
port, create_user, `variables`, port, create_user, create_time,
headers, config, `hosts` update_time, `variables`, headers,
) config, `hosts`)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
#{protocol,jdbcType=VARCHAR}, #{socket,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, #{socket,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR},
#{port,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{variables,jdbcType=LONGVARCHAR}, #{port,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{headers,jdbcType=LONGVARCHAR}, #{config,jdbcType=LONGVARCHAR}, #{hosts,jdbcType=LONGVARCHAR} #{updateTime,jdbcType=BIGINT}, #{variables,jdbcType=LONGVARCHAR}, #{headers,jdbcType=LONGVARCHAR},
) #{config,jdbcType=LONGVARCHAR}, #{hosts,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs">
insert into api_test_environment insert into api_test_environment
@ -168,6 +171,12 @@
<if test="createUser != null"> <if test="createUser != null">
create_user, create_user,
</if> </if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="variables != null"> <if test="variables != null">
`variables`, `variables`,
</if> </if>
@ -206,6 +215,12 @@
<if test="createUser != null"> <if test="createUser != null">
#{createUser,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR},
</if> </if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="variables != null"> <if test="variables != null">
#{variables,jdbcType=LONGVARCHAR}, #{variables,jdbcType=LONGVARCHAR},
</if> </if>
@ -253,6 +268,12 @@
<if test="record.createUser != null"> <if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR},
</if> </if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.variables != null"> <if test="record.variables != null">
`variables` = #{record.variables,jdbcType=LONGVARCHAR}, `variables` = #{record.variables,jdbcType=LONGVARCHAR},
</if> </if>
@ -280,6 +301,8 @@
`domain` = #{record.domain,jdbcType=VARCHAR}, `domain` = #{record.domain,jdbcType=VARCHAR},
port = #{record.port,jdbcType=INTEGER}, 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},
`variables` = #{record.variables,jdbcType=LONGVARCHAR}, `variables` = #{record.variables,jdbcType=LONGVARCHAR},
headers = #{record.headers,jdbcType=LONGVARCHAR}, headers = #{record.headers,jdbcType=LONGVARCHAR},
config = #{record.config,jdbcType=LONGVARCHAR}, config = #{record.config,jdbcType=LONGVARCHAR},
@ -297,7 +320,9 @@
socket = #{record.socket,jdbcType=VARCHAR}, socket = #{record.socket,jdbcType=VARCHAR},
`domain` = #{record.domain,jdbcType=VARCHAR}, `domain` = #{record.domain,jdbcType=VARCHAR},
port = #{record.port,jdbcType=INTEGER}, 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}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -326,6 +351,12 @@
<if test="createUser != null"> <if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR},
</if> </if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="variables != null"> <if test="variables != null">
`variables` = #{variables,jdbcType=LONGVARCHAR}, `variables` = #{variables,jdbcType=LONGVARCHAR},
</if> </if>
@ -350,6 +381,8 @@
`domain` = #{domain,jdbcType=VARCHAR}, `domain` = #{domain,jdbcType=VARCHAR},
port = #{port,jdbcType=INTEGER}, port = #{port,jdbcType=INTEGER},
create_user = #{createUser,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
`variables` = #{variables,jdbcType=LONGVARCHAR}, `variables` = #{variables,jdbcType=LONGVARCHAR},
headers = #{headers,jdbcType=LONGVARCHAR}, headers = #{headers,jdbcType=LONGVARCHAR},
config = #{config,jdbcType=LONGVARCHAR}, config = #{config,jdbcType=LONGVARCHAR},
@ -364,7 +397,9 @@
socket = #{socket,jdbcType=VARCHAR}, socket = #{socket,jdbcType=VARCHAR},
`domain` = #{domain,jdbcType=VARCHAR}, `domain` = #{domain,jdbcType=VARCHAR},
port = #{port,jdbcType=INTEGER}, 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} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -642,3 +642,12 @@ alter table project drop column clean_load_report;
alter table project drop column clean_load_report_expr; 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;

View File

@ -71,20 +71,23 @@
<!--<table tableName="test_plan"/>--> <!--<table tableName="test_plan"/>-->
<!--<table tableName="api_scenario_report"/>--> <!--<table tableName="api_scenario_report"/>-->
<!--<table tableName="test_case_review"/>--> <!--<table tableName="test_case_review"/>-->
<table tableName="project"> <!-- <table tableName="project">-->
<ignoreColumn column="custom_num"/> <!-- <ignoreColumn column="custom_num"/>-->
<ignoreColumn column="scenario_custom_num"/> <!-- <ignoreColumn column="scenario_custom_num"/>-->
<ignoreColumn column="mock_tcp_port"/> <!-- <ignoreColumn column="mock_tcp_port"/>-->
<ignoreColumn column="is_mock_tcp_open"/> <!-- <ignoreColumn column="is_mock_tcp_open"/>-->
<ignoreColumn column="api_quick"/> <!-- <ignoreColumn column="api_quick"/>-->
<ignoreColumn column="case_public"/> <!-- <ignoreColumn column="case_public"/>-->
<ignoreColumn column="clean_track_report"/> <!-- <ignoreColumn column="clean_track_report"/>-->
<ignoreColumn column="clean_track_report_expr"/> <!-- <ignoreColumn column="clean_track_report_expr"/>-->
<ignoreColumn column="clean_api_report"/> <!-- <ignoreColumn column="clean_api_report"/>-->
<ignoreColumn column="clean_api_report_expr"/> <!-- <ignoreColumn column="clean_api_report_expr"/>-->
<ignoreColumn column="clean_load_report"/> <!-- <ignoreColumn column="clean_load_report"/>-->
<ignoreColumn column="clean_load_report_expr"/> <!-- <ignoreColumn column="clean_load_report_expr"/>-->
<ignoreColumn column="repeatable"/> <!-- <ignoreColumn column="repeatable"/>-->
<!-- </table>-->
<table tableName="api_test_environment">
</table> </table>
<!--<table tableName="enterprise_test_report_send_record"/>--> <!--<table tableName="enterprise_test_report_send_record"/>-->
<!--<table tableName="test_case_review_api_case"/> <!--<table tableName="test_case_review_api_case"/>