feat(测试用例): ID字段自定义

This commit is contained in:
shiziyuan9527 2021-04-26 18:18:38 +08:00 committed by 刘瑞斌
parent 6e1992c9f5
commit 8ab5782b64
20 changed files with 312 additions and 33 deletions

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class Project implements Serializable {
@ -30,5 +29,7 @@ public class Project implements Serializable {
private String issueTemplateId;
private Boolean customNum;
private static final long serialVersionUID = 1L;
}
}

View File

@ -913,6 +913,66 @@ public class ProjectExample {
addCriterion("issue_template_id not between", value1, value2, "issueTemplateId");
return (Criteria) this;
}
public Criteria andCustomNumIsNull() {
addCriterion("custom_num is null");
return (Criteria) this;
}
public Criteria andCustomNumIsNotNull() {
addCriterion("custom_num is not null");
return (Criteria) this;
}
public Criteria andCustomNumEqualTo(Boolean value) {
addCriterion("custom_num =", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotEqualTo(Boolean value) {
addCriterion("custom_num <>", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumGreaterThan(Boolean value) {
addCriterion("custom_num >", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumGreaterThanOrEqualTo(Boolean value) {
addCriterion("custom_num >=", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumLessThan(Boolean value) {
addCriterion("custom_num <", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumLessThanOrEqualTo(Boolean value) {
addCriterion("custom_num <=", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumIn(List<Boolean> values) {
addCriterion("custom_num in", values, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotIn(List<Boolean> values) {
addCriterion("custom_num not in", values, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumBetween(Boolean value1, Boolean value2) {
addCriterion("custom_num between", value1, value2, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotBetween(Boolean value1, Boolean value2) {
addCriterion("custom_num not between", value1, value2, "customNum");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -49,5 +49,7 @@ public class TestCase implements Serializable {
private String status;
private String customNum;
private static final long serialVersionUID = 1L;
}

View File

@ -1603,6 +1603,76 @@ public class TestCaseExample {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andCustomNumIsNull() {
addCriterion("custom_num is null");
return (Criteria) this;
}
public Criteria andCustomNumIsNotNull() {
addCriterion("custom_num is not null");
return (Criteria) this;
}
public Criteria andCustomNumEqualTo(String value) {
addCriterion("custom_num =", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotEqualTo(String value) {
addCriterion("custom_num <>", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumGreaterThan(String value) {
addCriterion("custom_num >", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumGreaterThanOrEqualTo(String value) {
addCriterion("custom_num >=", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumLessThan(String value) {
addCriterion("custom_num <", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumLessThanOrEqualTo(String value) {
addCriterion("custom_num <=", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumLike(String value) {
addCriterion("custom_num like", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotLike(String value) {
addCriterion("custom_num not like", value, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumIn(List<String> values) {
addCriterion("custom_num in", values, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotIn(List<String> values) {
addCriterion("custom_num not in", values, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumBetween(String value1, String value2) {
addCriterion("custom_num between", value1, value2, "customNum");
return (Criteria) this;
}
public Criteria andCustomNumNotBetween(String value1, String value2) {
addCriterion("custom_num not between", value1, value2, "customNum");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -14,6 +14,7 @@
<result column="repeatable" jdbcType="BIT" property="repeatable" />
<result column="case_template_id" jdbcType="VARCHAR" property="caseTemplateId" />
<result column="issue_template_id" jdbcType="VARCHAR" property="issueTemplateId" />
<result column="custom_num" jdbcType="BIT" property="customNum" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -75,7 +76,7 @@
</sql>
<sql id="Base_Column_List">
id, workspace_id, `name`, description, create_time, update_time, tapd_id, jira_key,
zentao_id, `repeatable`, case_template_id, issue_template_id
zentao_id, `repeatable`, case_template_id, issue_template_id, custom_num
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ProjectExample" resultMap="BaseResultMap">
select
@ -111,13 +112,13 @@
insert into project (id, workspace_id, `name`,
description, create_time, update_time,
tapd_id, jira_key, zentao_id,
`repeatable`, case_template_id, issue_template_id
)
`repeatable`, case_template_id, issue_template_id,
custom_num)
values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR}, #{zentaoId,jdbcType=VARCHAR},
#{repeatable,jdbcType=BIT}, #{caseTemplateId,jdbcType=VARCHAR}, #{issueTemplateId,jdbcType=VARCHAR}
)
#{repeatable,jdbcType=BIT}, #{caseTemplateId,jdbcType=VARCHAR}, #{issueTemplateId,jdbcType=VARCHAR},
#{customNum,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Project">
insert into project
@ -158,6 +159,9 @@
<if test="issueTemplateId != null">
issue_template_id,
</if>
<if test="customNum != null">
custom_num,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -196,6 +200,9 @@
<if test="issueTemplateId != null">
#{issueTemplateId,jdbcType=VARCHAR},
</if>
<if test="customNum != null">
#{customNum,jdbcType=BIT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ProjectExample" resultType="java.lang.Long">
@ -243,6 +250,9 @@
<if test="record.issueTemplateId != null">
issue_template_id = #{record.issueTemplateId,jdbcType=VARCHAR},
</if>
<if test="record.customNum != null">
custom_num = #{record.customNum,jdbcType=BIT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -261,7 +271,8 @@
zentao_id = #{record.zentaoId,jdbcType=VARCHAR},
`repeatable` = #{record.repeatable,jdbcType=BIT},
case_template_id = #{record.caseTemplateId,jdbcType=VARCHAR},
issue_template_id = #{record.issueTemplateId,jdbcType=VARCHAR}
issue_template_id = #{record.issueTemplateId,jdbcType=VARCHAR},
custom_num = #{record.customNum,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -302,6 +313,9 @@
<if test="issueTemplateId != null">
issue_template_id = #{issueTemplateId,jdbcType=VARCHAR},
</if>
<if test="customNum != null">
custom_num = #{customNum,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -317,7 +331,8 @@
zentao_id = #{zentaoId,jdbcType=VARCHAR},
`repeatable` = #{repeatable,jdbcType=BIT},
case_template_id = #{caseTemplateId,jdbcType=VARCHAR},
issue_template_id = #{issueTemplateId,jdbcType=VARCHAR}
issue_template_id = #{issueTemplateId,jdbcType=VARCHAR},
custom_num = #{customNum,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -24,6 +24,7 @@
<result column="demand_name" jdbcType="VARCHAR" property="demandName" />
<result column="follow_people" jdbcType="VARCHAR" property="followPeople" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="custom_num" jdbcType="VARCHAR" property="customNum" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs">
<result column="remark" jdbcType="LONGVARCHAR" property="remark" />
@ -93,7 +94,7 @@
<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,
tags, demand_id, demand_name, follow_people, `status`
tags, demand_id, demand_name, follow_people, `status`, custom_num
</sql>
<sql id="Blob_Column_List">
remark, steps, step_description, expected_result, custom_fields
@ -154,8 +155,8 @@
test_id, sort, num,
other_test_name, review_status, tags,
demand_id, demand_name, follow_people,
`status`, remark, steps,
step_description, expected_result,
`status`, custom_num, remark,
steps, step_description, expected_result,
custom_fields)
values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
@ -164,8 +165,8 @@
#{testId,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{num,jdbcType=INTEGER},
#{otherTestName,jdbcType=VARCHAR}, #{reviewStatus,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR},
#{demandId,jdbcType=VARCHAR}, #{demandName,jdbcType=VARCHAR}, #{followPeople,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR},
#{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR},
#{status,jdbcType=VARCHAR}, #{customNum,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR},
#{steps,jdbcType=LONGVARCHAR}, #{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR},
#{customFields,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
@ -237,6 +238,9 @@
<if test="status != null">
`status`,
</if>
<if test="customNum != null">
custom_num,
</if>
<if test="remark != null">
remark,
</if>
@ -320,6 +324,9 @@
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="customNum != null">
#{customNum,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=LONGVARCHAR},
</if>
@ -412,6 +419,9 @@
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.customNum != null">
custom_num = #{record.customNum,jdbcType=VARCHAR},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=LONGVARCHAR},
</if>
@ -456,6 +466,7 @@
demand_name = #{record.demandName,jdbcType=VARCHAR},
follow_people = #{record.followPeople,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
custom_num = #{record.customNum,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=LONGVARCHAR},
steps = #{record.steps,jdbcType=LONGVARCHAR},
step_description = #{record.stepDescription,jdbcType=LONGVARCHAR},
@ -488,7 +499,8 @@
demand_id = #{record.demandId,jdbcType=VARCHAR},
demand_name = #{record.demandName,jdbcType=VARCHAR},
follow_people = #{record.followPeople,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR}
`status` = #{record.status,jdbcType=VARCHAR},
custom_num = #{record.customNum,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -559,6 +571,9 @@
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="customNum != null">
custom_num = #{customNum,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=LONGVARCHAR},
</if>
@ -600,6 +615,7 @@
demand_name = #{demandName,jdbcType=VARCHAR},
follow_people = #{followPeople,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
custom_num = #{customNum,jdbcType=VARCHAR},
remark = #{remark,jdbcType=LONGVARCHAR},
steps = #{steps,jdbcType=LONGVARCHAR},
step_description = #{stepDescription,jdbcType=LONGVARCHAR},
@ -629,7 +645,8 @@
demand_id = #{demandId,jdbcType=VARCHAR},
demand_name = #{demandName,jdbcType=VARCHAR},
follow_people = #{followPeople,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR}
`status` = #{status,jdbcType=VARCHAR},
custom_num = #{customNum,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -4,7 +4,7 @@
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
select p.id, p.workspace_id, p.name, p.description, p.update_time, p.issue_template_id, p.case_template_id,
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key, p.zentao_id,p.repeatable
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key, p.zentao_id,p.repeatable, p.custom_num
from project p
join workspace w on p.workspace_id = w.id
<where>

View File

@ -88,4 +88,6 @@ public interface ExtTestCaseMapper {
List<TestCaseWithBLOBs> listForMinder(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> getTestCaseByIds(@Param("ids")List<String> ids);
void updateTestCaseCustomNumByProjectId(@Param("projectId") String projectId);
}

View File

@ -71,6 +71,9 @@
</include>
</if>
</sql>
<update id="updateTestCaseCustomNumByProjectId">
update test_case set custom_num = num where custom_num is null and project_id = #{projectId}
</update>
<select id="getTestCaseByNotInReview" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status from test_case
@ -297,7 +300,8 @@
<if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%')
or test_case.num like CONCAT('%', #{request.name},'%')
or test_case.tags like CONCAT('%', #{request.name},'%'))
or test_case.tags like CONCAT('%', #{request.name},'%')
or test_case.custom_num like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.relevanceCreateTime >0">
and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >= #{request.createTime})

View File

@ -138,7 +138,7 @@
<select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_plan_test_case.id as id, test_case.id as caseId, test_case.name, test_case.priority,
test_case.type,test_case.test_id as testId,test_case.node_id, test_case.tags, test_case.maintainer,
test_case.node_path, test_case.method, test_case.num, test_plan_test_case.executor, test_plan_test_case.status, test_plan_test_case.actual_result,
test_case.node_path, test_case.method, if(project.custom_num = 0, cast(test_case.num as char), test_case.custom_num) as customNum, test_plan_test_case.executor, test_plan_test_case.status, test_plan_test_case.actual_result,
test_plan_test_case.update_time, test_case_node.name as model, project.name as projectName,
test_plan_test_case.plan_id as planId
from test_plan_test_case
@ -154,8 +154,10 @@
</include>
</if>
<if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like
CONCAT('%',#{request.name},'%') or test_case.tags like CONCAT('%', #{request.name},'%'))
and (test_case.name like CONCAT('%', #{request.name},'%')
or test_case.num like CONCAT('%',#{request.name},'%')
or test_case.custom_num like CONCAT('%',#{request.name},'%')
or test_case.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.id != null">
and test_case.id = #{request.id}
@ -227,8 +229,11 @@
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'num'">
test_case.num ${order.type}
<!-- <when test="order.name == 'num'">-->
<!-- test_case.num ${order.type}-->
<!-- </when>-->
<when test="order.name == 'custom_num'">
test_case.num ${order.type}, test_case.custom_num ${order.type}
</when>
<otherwise>
test_plan_test_case.${order.name} ${order.type}

View File

@ -100,7 +100,7 @@
select test_case_review_test_case.id as id, test_case_review_test_case.reviewer,
test_case_review_test_case.update_time, test_case_review_test_case.review_id as reviewId,
test_case.id as caseId, test_case.name, test_case.priority, test_case.test_id as testId,
test_case.type, test_case.node_path, test_case.method, test_case.num, test_case.review_status,
test_case.type, test_case.node_path, test_case.method, if(project.custom_num = 0, cast(test_case.num as char), test_case.custom_num) as customNum, test_case.review_status,
test_case.remark as remark, test_case.steps as steps, test_case.node_id as nodeId,
test_case_node.name as model,
project.name as projectName
@ -116,7 +116,10 @@
</include>
</if>
<if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%', #{request.name},'%'))
and (test_case.name like CONCAT('%', #{request.name},'%')
or test_case.num like CONCAT('%', #{request.name},'%')
or test_case.custom_num like CONCAT('%', #{request.name},'%')
)
</if>
<if test="request.id != null">
and test_case.id = #{request.id}
@ -176,8 +179,11 @@
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'num'">
test_case.num ${order.type}
<!-- <when test="order.name == 'num'">-->
<!-- test_case.num ${order.type}-->
<!-- </when>-->
<when test="order.name == 'custom_num'">
test_case.num ${order.type}, test_case.custom_num ${order.type}
</when>
<otherwise>
test_case_review_test_case.${order.name} ${order.type}

View File

@ -145,6 +145,9 @@ public class ProjectService {
project.setCreateTime(null);
project.setUpdateTime(System.currentTimeMillis());
checkProjectExist(project);
if (project.getCustomNum()) {
testCaseService.updateTestCaseCustomNumByProjectId(project.getId());
}
projectMapper.updateByPrimaryKeySelective(project);
}

View File

@ -115,6 +115,7 @@ public class TestCaseService {
testCase.setId(UUID.randomUUID().toString());
testCase.setCreateTime(System.currentTimeMillis());
testCase.setUpdateTime(System.currentTimeMillis());
checkTestCustomNum(testCase);
testCase.setNum(getNextNum(testCase.getProjectId()));
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
testCase.setDemandId(testCase.getDemandId());
@ -124,6 +125,34 @@ public class TestCaseService {
return testCase;
}
private void checkTestCustomNum(TestCaseWithBLOBs testCase) {
if (StringUtils.isNotBlank(testCase.getCustomNum())) {
String projectId = testCase.getProjectId();
Project project = projectService.getProjectById(projectId);
if (project != null) {
Boolean customNum = project.getCustomNum();
// 未开启自定义ID
if (!customNum) {
testCase.setCustomNum(null);
} else {
checkCustomNumExist(testCase);
}
} else {
MSException.throwException("add test case fail, project is not find.");
}
}
}
private void checkCustomNumExist(TestCaseWithBLOBs testCase) {
TestCaseExample example = new TestCaseExample();
example.createCriteria().andCustomNumEqualTo(testCase.getCustomNum())
.andIdNotEqualTo(testCase.getId());
List<TestCase> list = testCaseMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(list)) {
MSException.throwException("test case custom num is exist.");
}
}
public List<TestCase> getTestCaseByNodeId(List<String> nodeIds) {
TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andNodeIdIn(nodeIds);
@ -135,6 +164,7 @@ public class TestCaseService {
}
public int editTestCase(TestCaseWithBLOBs testCase) {
checkTestCustomNum(testCase);
testCase.setUpdateTime(System.currentTimeMillis());
return testCaseMapper.updateByPrimaryKeySelective(testCase);
}
@ -439,6 +469,7 @@ public class TestCaseService {
public void saveImportData(List<TestCaseWithBLOBs> testCases, String projectId) {
Map<String, String> nodePathMap = testCaseNodeService.createNodeByTestCases(testCases, projectId);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
Project project = projectService.getProjectById(projectId);
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
if (!testCases.isEmpty()) {
AtomicInteger sort = new AtomicInteger();
@ -450,7 +481,11 @@ public class TestCaseService {
testcase.setUpdateTime(System.currentTimeMillis());
testcase.setNodeId(nodePathMap.get(testcase.getNodePath()));
testcase.setSort(sort.getAndIncrement());
testcase.setNum(num.decrementAndGet());
int number = num.decrementAndGet();
testcase.setNum(number);
if (project.getCustomNum()) {
testcase.setCustomNum(String.valueOf(number));
}
testcase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
mapper.insert(testcase);
});
@ -969,4 +1004,12 @@ public class TestCaseService {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
return getTestCaseByNotInIssue(request);
}
/**
* 更新项目下用例的CustomNum值
* @param projectId 项目ID
*/
public void updateTestCaseCustomNumByProjectId(String projectId) {
extTestCaseMapper.updateTestCaseCustomNumByProjectId(projectId);
}
}

View File

@ -247,3 +247,7 @@ ALTER TABLE test_case_template MODIFY COLUMN case_name varchar(64) NULL COMMENT
UPDATE system_header
SET props='[{"id":"num","label":"ID"},{"id":"name","label":"名称"},{"id":"priority","label":"用例等级"},{"id":"type","label":"类型"},{"id":"tags","label":"标签"},{"id":"nodePath","label":"所属模块"},{"id":"projectName","label":"所属项目"},{"id":"issuesContent","label":"缺陷"},{"id":"executorName","label":"执行人"},{"id":"status","label":"执行结果"},{"id":"updateTime","label":"更新时间"},{"id":"maintainer","label":"责任人"}]'
WHERE `type`='test_plan_function_test_case';
-- 自定义用例ID
alter table project add custom_num tinyint(1) default 0 null comment '是否开启自定义ID(默认关闭)';
alter table test_case add custom_num varchar(64) null comment 'custom num';

View File

@ -84,6 +84,9 @@
<el-form-item :label="$t('project.repeatable')" prop="repeatable">
<el-switch v-model="form.repeatable"></el-switch>
</el-form-item>
<el-form-item label="测试用例自定义ID" prop="customNum">
<el-switch v-model="form.customNum"></el-switch>
</el-form-item>
</el-form>
<template v-slot:footer>
<div class="dialog-footer">

View File

@ -37,6 +37,7 @@
@refresh="refresh"
@refreshAll="refreshAll"
@setCondition="setCondition"
:custom-num="custom_num"
ref="testCaseList">
</test-case-list>
<test-case-minder
@ -63,6 +64,7 @@
:select-node="selectNode"
:select-condition="condition"
:type="type"
:custom-num="custom_num"
@addTab="addTab"
ref="testCaseEdit">
</test-case-edit>
@ -128,9 +130,11 @@ export default {
loading: false,
type:'',
activeDom: 'left',
custom_num: false
}
},
mounted() {
this.getProject();
this.init(this.$route);
},
watch: {
@ -372,6 +376,14 @@ export default {
},
setCondition(data) {
this.condition = data;
},
getProject() {
this.$get("/project/get/" + this.projectId, result => {
let data = result.data;
if (data) {
this.custom_num = data.customNum;
}
})
}
}
}

View File

@ -60,6 +60,15 @@
</el-row>
</el-form>
<el-row v-if="customNum">
<el-col :span="7">
<el-form-item label="ID" :label-width="formLabelWidth" prop="customNum">
<el-input :disabled="readOnly" v-model="form.customNum" size="small" class="ms-case-input"></el-input>
</el-form-item>
</el-col>
</el-row>
<ms-form-divider :title="$t('步骤信息')"/>
<div class="step-info">
@ -180,6 +189,7 @@ export default {
demandName: '',
status: 'Prepare',
reviewStatus: 'Prepare',
customNum: ''
},
readOnly: false,
maintainerOptions: [],
@ -191,6 +201,10 @@ export default {
{max: 255, message: this.$t('test_track.length_less_than') + '255', trigger: 'blur'}
],
module: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
customNum: [
{required: true, message: "ID必填", trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
demandName: [{required: true, message: this.$t('test_track.case.input_demand_name'), trigger: 'change'}],
maintainer: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
priority: [{required: true, message: this.$t('test_track.case.input_priority'), trigger: 'change'}],
@ -231,7 +245,11 @@ export default {
selectCondition: {
type: Object
},
type: String
type: String,
customNum: {
type: Boolean,
default: false
}
},
computed: {
projectIds() {
@ -689,6 +707,7 @@ export default {
desc: '',
result: ''
}];
this.form.customNum = '';
},
addListener() {
document.addEventListener("keydown", this.createCtrlSHandle);

View File

@ -36,7 +36,7 @@
<template v-for="(item, index) in tableLabel">
<el-table-column
v-if="item.id == 'num'"
v-if="item.id === 'num' && !customNum"
prop="num"
sortable="custom"
:label="$t('commons.id')"
@ -44,6 +44,15 @@
width="80"
show-overflow-tooltip>
</el-table-column>
<el-table-column
v-if="item.id === 'num' && customNum"
prop="customNum"
sortable="custom"
:label="$t('commons.id')"
:key="index"
width="80"
show-overflow-tooltip>
</el-table-column>
<el-table-column
v-if="item.id == 'name'"
prop="name"
@ -293,6 +302,10 @@ export default {
trashEnable: {
type: Boolean,
default: false,
},
customNum: {
type: Boolean,
default: false
}
},
computed: {

View File

@ -53,7 +53,7 @@
<template v-for="(item, index) in tableLabel">
<el-table-column
v-if="item.id == 'num'"
prop="num"
prop="customNum"
sortable="custom"
:label="$t('commons.id')"
min-width="120px"

View File

@ -46,7 +46,7 @@
<template v-for="(item, index) in tableLabel">
<el-table-column
v-if="item.id == 'num'"
prop="num"
prop="customNum"
sortable="custom"
min-width="100"
:label="$t('commons.id')"