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) {
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<MultipartFile> 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) {

View File

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

View File

@ -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<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 {

View File

@ -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)

View File

@ -10,6 +10,8 @@
<result column="domain" jdbcType="VARCHAR" property="domain" />
<result column="port" jdbcType="INTEGER" property="port" />
<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 extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs">
<result column="variables" jdbcType="LONGVARCHAR" property="variables" />
@ -76,7 +78,8 @@
</where>
</sql>
<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 id="Blob_Column_List">
`variables`, headers, config, `hosts`
@ -132,14 +135,14 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs">
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>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs">
insert into api_test_environment
@ -168,6 +171,12 @@
<if test="createUser != null">
create_user,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="variables != null">
`variables`,
</if>
@ -206,6 +215,12 @@
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="variables != null">
#{variables,jdbcType=LONGVARCHAR},
</if>
@ -253,6 +268,12 @@
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</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">
`variables` = #{record.variables,jdbcType=LONGVARCHAR},
</if>
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -326,6 +351,12 @@
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</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">
`variables` = #{variables,jdbcType=LONGVARCHAR},
</if>
@ -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}
</update>
</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 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="api_scenario_report"/>-->
<!--<table tableName="test_case_review"/>-->
<table tableName="project">
<ignoreColumn column="custom_num"/>
<ignoreColumn column="scenario_custom_num"/>
<ignoreColumn column="mock_tcp_port"/>
<ignoreColumn column="is_mock_tcp_open"/>
<ignoreColumn column="api_quick"/>
<ignoreColumn column="case_public"/>
<ignoreColumn column="clean_track_report"/>
<ignoreColumn column="clean_track_report_expr"/>
<ignoreColumn column="clean_api_report"/>
<ignoreColumn column="clean_api_report_expr"/>
<ignoreColumn column="clean_load_report"/>
<ignoreColumn column="clean_load_report_expr"/>
<ignoreColumn column="repeatable"/>
<!-- <table tableName="project">-->
<!-- <ignoreColumn column="custom_num"/>-->
<!-- <ignoreColumn column="scenario_custom_num"/>-->
<!-- <ignoreColumn column="mock_tcp_port"/>-->
<!-- <ignoreColumn column="is_mock_tcp_open"/>-->
<!-- <ignoreColumn column="api_quick"/>-->
<!-- <ignoreColumn column="case_public"/>-->
<!-- <ignoreColumn column="clean_track_report"/>-->
<!-- <ignoreColumn column="clean_track_report_expr"/>-->
<!-- <ignoreColumn column="clean_api_report"/>-->
<!-- <ignoreColumn column="clean_api_report_expr"/>-->
<!-- <ignoreColumn column="clean_load_report"/>-->
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
<!-- <ignoreColumn column="repeatable"/>-->
<!-- </table>-->
<table tableName="api_test_environment">
</table>
<!--<table tableName="enterprise_test_report_send_record"/>-->
<!--<table tableName="test_case_review_api_case"/>