对模板导入的测试用例进行排序

This commit is contained in:
shiziyuan9527 2020-06-30 15:27:12 +08:00
parent 56d25dfcd8
commit 1c16353180
6 changed files with 169 additions and 76 deletions

View File

@ -31,5 +31,7 @@ public class TestCase implements Serializable {
private String testId;
private Integer sort;
private static final long serialVersionUID = 1L;
}

View File

@ -385,142 +385,142 @@ public class TestCaseExample {
}
public Criteria andNameIsNull() {
addCriterion("name is null");
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
@ -665,72 +665,72 @@ public class TestCaseExample {
}
public Criteria andMethodIsNull() {
addCriterion("method is null");
addCriterion("`method` is null");
return (Criteria) this;
}
public Criteria andMethodIsNotNull() {
addCriterion("method is not null");
addCriterion("`method` is not null");
return (Criteria) this;
}
public Criteria andMethodEqualTo(String value) {
addCriterion("method =", value, "method");
addCriterion("`method` =", value, "method");
return (Criteria) this;
}
public Criteria andMethodNotEqualTo(String value) {
addCriterion("method <>", value, "method");
addCriterion("`method` <>", value, "method");
return (Criteria) this;
}
public Criteria andMethodGreaterThan(String value) {
addCriterion("method >", value, "method");
addCriterion("`method` >", value, "method");
return (Criteria) this;
}
public Criteria andMethodGreaterThanOrEqualTo(String value) {
addCriterion("method >=", value, "method");
addCriterion("`method` >=", value, "method");
return (Criteria) this;
}
public Criteria andMethodLessThan(String value) {
addCriterion("method <", value, "method");
addCriterion("`method` <", value, "method");
return (Criteria) this;
}
public Criteria andMethodLessThanOrEqualTo(String value) {
addCriterion("method <=", value, "method");
addCriterion("`method` <=", value, "method");
return (Criteria) this;
}
public Criteria andMethodLike(String value) {
addCriterion("method like", value, "method");
addCriterion("`method` like", value, "method");
return (Criteria) this;
}
public Criteria andMethodNotLike(String value) {
addCriterion("method not like", value, "method");
addCriterion("`method` not like", value, "method");
return (Criteria) this;
}
public Criteria andMethodIn(List<String> values) {
addCriterion("method in", values, "method");
addCriterion("`method` in", values, "method");
return (Criteria) this;
}
public Criteria andMethodNotIn(List<String> values) {
addCriterion("method not in", values, "method");
addCriterion("`method` not in", values, "method");
return (Criteria) this;
}
public Criteria andMethodBetween(String value1, String value2) {
addCriterion("method between", value1, value2, "method");
addCriterion("`method` between", value1, value2, "method");
return (Criteria) this;
}
public Criteria andMethodNotBetween(String value1, String value2) {
addCriterion("method not between", value1, value2, "method");
addCriterion("`method` not between", value1, value2, "method");
return (Criteria) this;
}
@ -993,6 +993,66 @@ public class TestCaseExample {
addCriterion("test_id not between", value1, value2, "testId");
return (Criteria) this;
}
public Criteria andSortIsNull() {
addCriterion("sort is null");
return (Criteria) this;
}
public Criteria andSortIsNotNull() {
addCriterion("sort is not null");
return (Criteria) this;
}
public Criteria andSortEqualTo(Integer value) {
addCriterion("sort =", value, "sort");
return (Criteria) this;
}
public Criteria andSortNotEqualTo(Integer value) {
addCriterion("sort <>", value, "sort");
return (Criteria) this;
}
public Criteria andSortGreaterThan(Integer value) {
addCriterion("sort >", value, "sort");
return (Criteria) this;
}
public Criteria andSortGreaterThanOrEqualTo(Integer value) {
addCriterion("sort >=", value, "sort");
return (Criteria) this;
}
public Criteria andSortLessThan(Integer value) {
addCriterion("sort <", value, "sort");
return (Criteria) this;
}
public Criteria andSortLessThanOrEqualTo(Integer value) {
addCriterion("sort <=", value, "sort");
return (Criteria) this;
}
public Criteria andSortIn(List<Integer> values) {
addCriterion("sort in", values, "sort");
return (Criteria) this;
}
public Criteria andSortNotIn(List<Integer> values) {
addCriterion("sort not in", values, "sort");
return (Criteria) this;
}
public Criteria andSortBetween(Integer value1, Integer value2) {
addCriterion("sort between", value1, value2, "sort");
return (Criteria) this;
}
public Criteria andSortNotBetween(Integer value1, Integer value2) {
addCriterion("sort not between", value1, value2, "sort");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -15,6 +15,7 @@
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="test_id" jdbcType="VARCHAR" property="testId" />
<result column="sort" jdbcType="INTEGER" property="sort" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs">
<result column="remark" jdbcType="LONGVARCHAR" property="remark" />
@ -79,8 +80,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, node_id, node_path, project_id, name, type, maintainer, priority, method, prerequisite,
create_time, update_time, test_id
id, node_id, node_path, project_id, `name`, `type`, maintainer, priority, `method`,
prerequisite, create_time, update_time, test_id, sort
</sql>
<sql id="Blob_Column_List">
remark, steps
@ -135,17 +136,17 @@
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
insert into test_case (id, node_id, node_path,
project_id, name, type,
maintainer, priority, method,
project_id, `name`, `type`,
maintainer, priority, `method`,
prerequisite, create_time, update_time,
test_id, remark, steps
)
test_id, sort, remark,
steps)
values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR},
#{prerequisite,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{testId,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR}
)
#{testId,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{remark,jdbcType=LONGVARCHAR},
#{steps,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
insert into test_case
@ -163,10 +164,10 @@
project_id,
</if>
<if test="name != null">
name,
`name`,
</if>
<if test="type != null">
type,
`type`,
</if>
<if test="maintainer != null">
maintainer,
@ -175,7 +176,7 @@
priority,
</if>
<if test="method != null">
method,
`method`,
</if>
<if test="prerequisite != null">
prerequisite,
@ -189,6 +190,9 @@
<if test="testId != null">
test_id,
</if>
<if test="sort != null">
sort,
</if>
<if test="remark != null">
remark,
</if>
@ -236,6 +240,9 @@
<if test="testId != null">
#{testId,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="remark != null">
#{remark,jdbcType=LONGVARCHAR},
</if>
@ -266,10 +273,10 @@
project_id = #{record.projectId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.maintainer != null">
maintainer = #{record.maintainer,jdbcType=VARCHAR},
@ -278,7 +285,7 @@
priority = #{record.priority,jdbcType=VARCHAR},
</if>
<if test="record.method != null">
method = #{record.method,jdbcType=VARCHAR},
`method` = #{record.method,jdbcType=VARCHAR},
</if>
<if test="record.prerequisite != null">
prerequisite = #{record.prerequisite,jdbcType=VARCHAR},
@ -292,6 +299,9 @@
<if test="record.testId != null">
test_id = #{record.testId,jdbcType=VARCHAR},
</if>
<if test="record.sort != null">
sort = #{record.sort,jdbcType=INTEGER},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=LONGVARCHAR},
</if>
@ -309,15 +319,16 @@
node_id = #{record.nodeId,jdbcType=VARCHAR},
node_path = #{record.nodePath,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
maintainer = #{record.maintainer,jdbcType=VARCHAR},
priority = #{record.priority,jdbcType=VARCHAR},
method = #{record.method,jdbcType=VARCHAR},
`method` = #{record.method,jdbcType=VARCHAR},
prerequisite = #{record.prerequisite,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
test_id = #{record.testId,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=INTEGER},
remark = #{record.remark,jdbcType=LONGVARCHAR},
steps = #{record.steps,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -330,15 +341,16 @@
node_id = #{record.nodeId,jdbcType=VARCHAR},
node_path = #{record.nodePath,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
maintainer = #{record.maintainer,jdbcType=VARCHAR},
priority = #{record.priority,jdbcType=VARCHAR},
method = #{record.method,jdbcType=VARCHAR},
`method` = #{record.method,jdbcType=VARCHAR},
prerequisite = #{record.prerequisite,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
test_id = #{record.testId,jdbcType=VARCHAR}
test_id = #{record.testId,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -356,10 +368,10 @@
project_id = #{projectId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="maintainer != null">
maintainer = #{maintainer,jdbcType=VARCHAR},
@ -368,7 +380,7 @@
priority = #{priority,jdbcType=VARCHAR},
</if>
<if test="method != null">
method = #{method,jdbcType=VARCHAR},
`method` = #{method,jdbcType=VARCHAR},
</if>
<if test="prerequisite != null">
prerequisite = #{prerequisite,jdbcType=VARCHAR},
@ -382,6 +394,9 @@
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=LONGVARCHAR},
</if>
@ -396,15 +411,16 @@
set node_id = #{nodeId,jdbcType=VARCHAR},
node_path = #{nodePath,jdbcType=VARCHAR},
project_id = #{projectId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
maintainer = #{maintainer,jdbcType=VARCHAR},
priority = #{priority,jdbcType=VARCHAR},
method = #{method,jdbcType=VARCHAR},
`method` = #{method,jdbcType=VARCHAR},
prerequisite = #{prerequisite,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
test_id = #{testId,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
remark = #{remark,jdbcType=LONGVARCHAR},
steps = #{steps,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
@ -414,15 +430,16 @@
set node_id = #{nodeId,jdbcType=VARCHAR},
node_path = #{nodePath,jdbcType=VARCHAR},
project_id = #{projectId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
maintainer = #{maintainer,jdbcType=VARCHAR},
priority = #{priority,jdbcType=VARCHAR},
method = #{method,jdbcType=VARCHAR},
`method` = #{method,jdbcType=VARCHAR},
prerequisite = #{prerequisite,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
test_id = #{testId,jdbcType=VARCHAR}
test_id = #{testId,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -10,6 +10,7 @@ import io.metersphere.i18n.Translator;
import io.metersphere.track.service.TestCaseService;
import org.apache.commons.lang3.StringUtils;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@ -72,6 +73,8 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
return;
}
Collections.reverse(list);
List<TestCaseWithBLOBs> result = list.stream()
.map(item -> this.convert2TestCase(item))
.collect(Collectors.toList());

View File

@ -35,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Service
@ -121,7 +122,13 @@ public class TestCaseService {
}
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<OrderRequest> orderList = ServiceUtils.getDefaultOrder(request.getOrders());
OrderRequest order = new OrderRequest();
// 对模板导入的测试用例排序
order.setName("sort");
order.setType("desc");
orderList.add(order);
request.setOrders(orderList);
return extTestCaseMapper.list(request);
}
@ -176,7 +183,7 @@ public class TestCaseService {
TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andProjectIdIn(projectIds);
testCaseExample.setOrderByClause("update_time desc");
testCaseExample.setOrderByClause("update_time desc, sort desc");
return testCaseMapper.selectByExample(testCaseExample);
}
@ -235,8 +242,10 @@ public class TestCaseService {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
if (!testCases.isEmpty()) {
AtomicInteger sort = new AtomicInteger();
testCases.forEach(testcase -> {
testcase.setNodeId(nodePathMap.get(testcase.getNodePath()));
testcase.setSort(sort.getAndIncrement());
mapper.insert(testcase);
});
}

View File

@ -170,4 +170,6 @@ ALTER TABLE `load_test` DROP COLUMN `schedule`;
ALTER TABLE `api_test_report` ADD `trigger_mode` varchar(64) NULL;
ALTER TABLE `load_test_report` ADD `trigger_mode` varchar(64) NULL;
UPDATE `api_test_report` SET `trigger_mode` = 'MANUAL' WHERE 1;
UPDATE `load_test_report` SET `trigger_mode` = 'MANUAL' WHERE 1;
UPDATE `load_test_report` SET `trigger_mode` = 'MANUAL' WHERE 1;
alter table test_case add sort int null comment 'Import test case sort';