feat: 测试用例保存tag

This commit is contained in:
Captain.B 2021-01-07 16:03:02 +08:00
parent 18340d16e5
commit a2c1baece6
8 changed files with 179 additions and 10 deletions

View File

@ -1,8 +1,9 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
import java.io.Serializable;
@Data
public class TestCase implements Serializable {
private String id;
@ -39,5 +40,7 @@ public class TestCase implements Serializable {
private String reviewStatus;
private String tags;
private static final long serialVersionUID = 1L;
}

View File

@ -1253,6 +1253,76 @@ public class TestCaseExample {
addCriterion("review_status not between", value1, value2, "reviewStatus");
return (Criteria) this;
}
public Criteria andTagsIsNull() {
addCriterion("tags is null");
return (Criteria) this;
}
public Criteria andTagsIsNotNull() {
addCriterion("tags is not null");
return (Criteria) this;
}
public Criteria andTagsEqualTo(String value) {
addCriterion("tags =", value, "tags");
return (Criteria) this;
}
public Criteria andTagsNotEqualTo(String value) {
addCriterion("tags <>", value, "tags");
return (Criteria) this;
}
public Criteria andTagsGreaterThan(String value) {
addCriterion("tags >", value, "tags");
return (Criteria) this;
}
public Criteria andTagsGreaterThanOrEqualTo(String value) {
addCriterion("tags >=", value, "tags");
return (Criteria) this;
}
public Criteria andTagsLessThan(String value) {
addCriterion("tags <", value, "tags");
return (Criteria) this;
}
public Criteria andTagsLessThanOrEqualTo(String value) {
addCriterion("tags <=", value, "tags");
return (Criteria) this;
}
public Criteria andTagsLike(String value) {
addCriterion("tags like", value, "tags");
return (Criteria) this;
}
public Criteria andTagsNotLike(String value) {
addCriterion("tags not like", value, "tags");
return (Criteria) this;
}
public Criteria andTagsIn(List<String> values) {
addCriterion("tags in", values, "tags");
return (Criteria) this;
}
public Criteria andTagsNotIn(List<String> values) {
addCriterion("tags not in", values, "tags");
return (Criteria) this;
}
public Criteria andTagsBetween(String value1, String value2) {
addCriterion("tags between", value1, value2, "tags");
return (Criteria) this;
}
public Criteria andTagsNotBetween(String value1, String value2) {
addCriterion("tags not between", value1, value2, "tags");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -19,6 +19,7 @@
<result column="num" jdbcType="INTEGER" property="num" />
<result column="other_test_name" jdbcType="VARCHAR" property="otherTestName" />
<result column="review_status" jdbcType="VARCHAR" property="reviewStatus" />
<result column="tags" jdbcType="VARCHAR" property="tags" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs">
<result column="remark" jdbcType="LONGVARCHAR" property="remark" />
@ -84,7 +85,8 @@
</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, sort, num, other_test_name, review_status
prerequisite, create_time, update_time, test_id, sort, num, other_test_name, review_status,
tags
</sql>
<sql id="Blob_Column_List">
remark, steps
@ -143,15 +145,15 @@
maintainer, priority, `method`,
prerequisite, create_time, update_time,
test_id, sort, num,
other_test_name, review_status, remark,
steps)
other_test_name, review_status, tags,
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}, #{sort,jdbcType=INTEGER}, #{num,jdbcType=INTEGER},
#{otherTestName,jdbcType=VARCHAR}, #{reviewStatus,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR},
#{steps,jdbcType=LONGVARCHAR})
#{otherTestName,jdbcType=VARCHAR}, #{reviewStatus,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR},
#{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
insert into test_case
@ -207,6 +209,9 @@
<if test="reviewStatus != null">
review_status,
</if>
<if test="tags != null">
tags,
</if>
<if test="remark != null">
remark,
</if>
@ -266,6 +271,9 @@
<if test="reviewStatus != null">
#{reviewStatus,jdbcType=VARCHAR},
</if>
<if test="tags != null">
#{tags,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=LONGVARCHAR},
</if>
@ -334,6 +342,9 @@
<if test="record.reviewStatus != null">
review_status = #{record.reviewStatus,jdbcType=VARCHAR},
</if>
<if test="record.tags != null">
tags = #{record.tags,jdbcType=VARCHAR},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=LONGVARCHAR},
</if>
@ -364,6 +375,7 @@
num = #{record.num,jdbcType=INTEGER},
other_test_name = #{record.otherTestName,jdbcType=VARCHAR},
review_status = #{record.reviewStatus,jdbcType=VARCHAR},
tags = #{record.tags,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=LONGVARCHAR},
steps = #{record.steps,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -388,7 +400,8 @@
sort = #{record.sort,jdbcType=INTEGER},
num = #{record.num,jdbcType=INTEGER},
other_test_name = #{record.otherTestName,jdbcType=VARCHAR},
review_status = #{record.reviewStatus,jdbcType=VARCHAR}
review_status = #{record.reviewStatus,jdbcType=VARCHAR},
tags = #{record.tags,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -444,6 +457,9 @@
<if test="reviewStatus != null">
review_status = #{reviewStatus,jdbcType=VARCHAR},
</if>
<if test="tags != null">
tags = #{tags,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=LONGVARCHAR},
</if>
@ -471,6 +487,7 @@
num = #{num,jdbcType=INTEGER},
other_test_name = #{otherTestName,jdbcType=VARCHAR},
review_status = #{reviewStatus,jdbcType=VARCHAR},
tags = #{tags,jdbcType=VARCHAR},
remark = #{remark,jdbcType=LONGVARCHAR},
steps = #{steps,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
@ -492,7 +509,8 @@
sort = #{sort,jdbcType=INTEGER},
num = #{num,jdbcType=INTEGER},
other_test_name = #{otherTestName,jdbcType=VARCHAR},
review_status = #{reviewStatus,jdbcType=VARCHAR}
review_status = #{reviewStatus,jdbcType=VARCHAR},
tags = #{tags,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -4,6 +4,9 @@ import io.metersphere.base.domain.TestCaseWithBLOBs;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
public class TestCaseDTO extends TestCaseWithBLOBs {
@ -12,4 +15,5 @@ public class TestCaseDTO extends TestCaseWithBLOBs {
private String apiName;
private String performName;
private List<String> caseTags = new ArrayList<>();
}

View File

@ -16,4 +16,5 @@ public class EditTestCaseRequest extends TestCaseWithBLOBs {
* 复制测试用例后要进行复制的文件Id list
*/
private List<String> fileIds = new ArrayList<>();
private List<String> caseTags = new ArrayList<>();
}

View File

@ -585,6 +585,7 @@ public class TestCaseService {
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
}
request.setTags(JSON.toJSONString(new HashSet<>(request.getCaseTags())));
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request);
// 复制用例时传入文件ID进行复制
@ -641,6 +642,7 @@ public class TestCaseService {
});
}
request.setTags(JSON.toJSONString(new HashSet<>(request.getCaseTags())));
editTestCase(request);
return request.getId();
}

View File

@ -64,7 +64,7 @@
<!--要生成的数据库表 -->
<table tableName="api_definition"/>
<table tableName="test_case"/>
<!--<table tableName="test_plan_api_scenario"/>-->
<!--<table tableName="test_plan"/>-->
<!--<table tableName="api_scenario_report"/>-->

View File

@ -66,6 +66,33 @@
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
<el-form-item :label="$t('commons.tag')" :label-width="formLabelWidth" prop="tag">
<el-tag
:key="form + '_' + index"
v-for="(tag, index) in form.caseTags"
closable
size="mini"
:disable-transitions="false"
@close="handleClose(tag)">
{{ tag }}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="mini"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" size="mini" @click="showInput">+</el-button>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
@ -296,6 +323,7 @@ export default {
result: ''
}],
remark: '',
caseTags: []
},
moduleOptions: [],
maintainerOptions: [],
@ -326,7 +354,9 @@ export default {
{value: 'auto', label: this.$t('test_track.case.auto')},
{value: 'manual', label: this.$t('test_track.case.manual')}
],
testCase: {}
testCase: {},
inputVisible: false,
inputValue: ''
};
},
props: {
@ -357,6 +387,7 @@ export default {
open(testCase) {
this.testCase = {};
if (testCase) {
testCase.caseTags = JSON.parse(testCase.tags);
//
this.testCase = testCase.isCopy ? {} : testCase;
}
@ -394,6 +425,7 @@ export default {
this.form.type = 'functional';
this.form.method = 'manual';
this.form.maintainer = user.id;
this.form.caseTags = [];
}
this.getSelectOptions();
@ -609,6 +641,7 @@ export default {
desc: '',
result: ''
}];
this.caseTags = [];
this.uploadList = [];
this.fileList = [];
this.tableData = [];
@ -695,6 +728,26 @@ export default {
fileValidator(file) {
/// todo:
return file.size > 0;
},
handleClose(tag) {
this.form.caseTags.splice(this.form.caseTags.indexOf(tag), 1);
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.form.caseTags.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
}
}
}
@ -734,4 +787,22 @@ export default {
.comment-card >>> .el-card__body {
height: calc(100vh - 120px);
}
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 20px;
/*line-height: 30px;*/
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style>