feat(测试跟踪): 功能用例缺陷与测试计划缺陷分离

This commit is contained in:
chenjianxing 2022-02-16 10:01:23 +08:00 committed by jianxing
parent 063071a305
commit 4cb76a97c2
31 changed files with 551 additions and 265 deletions

View File

@ -7,9 +7,13 @@ import lombok.Data;
public class TestCaseIssues implements Serializable { public class TestCaseIssues implements Serializable {
private String id; private String id;
private String testCaseId; private String resourceId;
private String issuesId; private String issuesId;
private String refId;
private String refType;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -174,73 +174,73 @@ public class TestCaseIssuesExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdIsNull() { public Criteria andResourceIdIsNull() {
addCriterion("test_case_id is null"); addCriterion("resource_id is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdIsNotNull() { public Criteria andResourceIdIsNotNull() {
addCriterion("test_case_id is not null"); addCriterion("resource_id is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdEqualTo(String value) { public Criteria andResourceIdEqualTo(String value) {
addCriterion("test_case_id =", value, "testCaseId"); addCriterion("resource_id =", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdNotEqualTo(String value) { public Criteria andResourceIdNotEqualTo(String value) {
addCriterion("test_case_id <>", value, "testCaseId"); addCriterion("resource_id <>", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdGreaterThan(String value) { public Criteria andResourceIdGreaterThan(String value) {
addCriterion("test_case_id >", value, "testCaseId"); addCriterion("resource_id >", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdGreaterThanOrEqualTo(String value) { public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
addCriterion("test_case_id >=", value, "testCaseId"); addCriterion("resource_id >=", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdLessThan(String value) { public Criteria andResourceIdLessThan(String value) {
addCriterion("test_case_id <", value, "testCaseId"); addCriterion("resource_id <", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdLessThanOrEqualTo(String value) { public Criteria andResourceIdLessThanOrEqualTo(String value) {
addCriterion("test_case_id <=", value, "testCaseId"); addCriterion("resource_id <=", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdLike(String value) { public Criteria andResourceIdLike(String value) {
addCriterion("test_case_id like", value, "testCaseId"); addCriterion("resource_id like", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdNotLike(String value) { public Criteria andResourceIdNotLike(String value) {
addCriterion("test_case_id not like", value, "testCaseId"); addCriterion("resource_id not like", value, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdIn(List<String> values) { public Criteria andResourceIdIn(List<String> values) {
addCriterion("test_case_id in", values, "testCaseId"); addCriterion("resource_id in", values, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdNotIn(List<String> values) { public Criteria andResourceIdNotIn(List<String> values) {
addCriterion("test_case_id not in", values, "testCaseId"); addCriterion("resource_id not in", values, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdBetween(String value1, String value2) { public Criteria andResourceIdBetween(String value1, String value2) {
addCriterion("test_case_id between", value1, value2, "testCaseId"); addCriterion("resource_id between", value1, value2, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestCaseIdNotBetween(String value1, String value2) { public Criteria andResourceIdNotBetween(String value1, String value2) {
addCriterion("test_case_id not between", value1, value2, "testCaseId"); addCriterion("resource_id not between", value1, value2, "resourceId");
return (Criteria) this; return (Criteria) this;
} }
@ -313,6 +313,146 @@ public class TestCaseIssuesExample {
addCriterion("issues_id not between", value1, value2, "issuesId"); addCriterion("issues_id not between", value1, value2, "issuesId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefIdIsNull() {
addCriterion("ref_id is null");
return (Criteria) this;
}
public Criteria andRefIdIsNotNull() {
addCriterion("ref_id is not null");
return (Criteria) this;
}
public Criteria andRefIdEqualTo(String value) {
addCriterion("ref_id =", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdNotEqualTo(String value) {
addCriterion("ref_id <>", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdGreaterThan(String value) {
addCriterion("ref_id >", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdGreaterThanOrEqualTo(String value) {
addCriterion("ref_id >=", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdLessThan(String value) {
addCriterion("ref_id <", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdLessThanOrEqualTo(String value) {
addCriterion("ref_id <=", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdLike(String value) {
addCriterion("ref_id like", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdNotLike(String value) {
addCriterion("ref_id not like", value, "refId");
return (Criteria) this;
}
public Criteria andRefIdIn(List<String> values) {
addCriterion("ref_id in", values, "refId");
return (Criteria) this;
}
public Criteria andRefIdNotIn(List<String> values) {
addCriterion("ref_id not in", values, "refId");
return (Criteria) this;
}
public Criteria andRefIdBetween(String value1, String value2) {
addCriterion("ref_id between", value1, value2, "refId");
return (Criteria) this;
}
public Criteria andRefIdNotBetween(String value1, String value2) {
addCriterion("ref_id not between", value1, value2, "refId");
return (Criteria) this;
}
public Criteria andRefTypeIsNull() {
addCriterion("ref_type is null");
return (Criteria) this;
}
public Criteria andRefTypeIsNotNull() {
addCriterion("ref_type is not null");
return (Criteria) this;
}
public Criteria andRefTypeEqualTo(String value) {
addCriterion("ref_type =", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotEqualTo(String value) {
addCriterion("ref_type <>", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeGreaterThan(String value) {
addCriterion("ref_type >", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeGreaterThanOrEqualTo(String value) {
addCriterion("ref_type >=", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeLessThan(String value) {
addCriterion("ref_type <", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeLessThanOrEqualTo(String value) {
addCriterion("ref_type <=", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeLike(String value) {
addCriterion("ref_type like", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotLike(String value) {
addCriterion("ref_type not like", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeIn(List<String> values) {
addCriterion("ref_type in", values, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotIn(List<String> values) {
addCriterion("ref_type not in", values, "refType");
return (Criteria) this;
}
public Criteria andRefTypeBetween(String value1, String value2) {
addCriterion("ref_type between", value1, value2, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotBetween(String value1, String value2) {
addCriterion("ref_type not between", value1, value2, "refType");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -3,8 +3,10 @@
<mapper namespace="io.metersphere.base.mapper.TestCaseIssuesMapper"> <mapper namespace="io.metersphere.base.mapper.TestCaseIssuesMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestCaseIssues"> <resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestCaseIssues">
<id column="id" jdbcType="VARCHAR" property="id" /> <id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_case_id" jdbcType="VARCHAR" property="testCaseId" /> <result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="issues_id" jdbcType="VARCHAR" property="issuesId" /> <result column="issues_id" jdbcType="VARCHAR" property="issuesId" />
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
<result column="ref_type" jdbcType="VARCHAR" property="refType" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -65,7 +67,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, test_case_id, issues_id id, resource_id, issues_id, ref_id, ref_type
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseIssuesExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseIssuesExample" resultMap="BaseResultMap">
select select
@ -98,10 +100,10 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseIssues"> <insert id="insert" parameterType="io.metersphere.base.domain.TestCaseIssues">
insert into test_case_issues (id, test_case_id, issues_id insert into test_case_issues (id, resource_id, issues_id,
) ref_id, ref_type)
values (#{id,jdbcType=VARCHAR}, #{testCaseId,jdbcType=VARCHAR}, #{issuesId,jdbcType=VARCHAR} values (#{id,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{issuesId,jdbcType=VARCHAR},
) #{refId,jdbcType=VARCHAR}, #{refType,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseIssues"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseIssues">
insert into test_case_issues insert into test_case_issues
@ -109,23 +111,35 @@
<if test="id != null"> <if test="id != null">
id, id,
</if> </if>
<if test="testCaseId != null"> <if test="resourceId != null">
test_case_id, resource_id,
</if> </if>
<if test="issuesId != null"> <if test="issuesId != null">
issues_id, issues_id,
</if> </if>
<if test="refId != null">
ref_id,
</if>
<if test="refType != null">
ref_type,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
#{id,jdbcType=VARCHAR}, #{id,jdbcType=VARCHAR},
</if> </if>
<if test="testCaseId != null"> <if test="resourceId != null">
#{testCaseId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
</if> </if>
<if test="issuesId != null"> <if test="issuesId != null">
#{issuesId,jdbcType=VARCHAR}, #{issuesId,jdbcType=VARCHAR},
</if> </if>
<if test="refId != null">
#{refId,jdbcType=VARCHAR},
</if>
<if test="refType != null">
#{refType,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseIssuesExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseIssuesExample" resultType="java.lang.Long">
@ -140,12 +154,18 @@
<if test="record.id != null"> <if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR}, id = #{record.id,jdbcType=VARCHAR},
</if> </if>
<if test="record.testCaseId != null"> <if test="record.resourceId != null">
test_case_id = #{record.testCaseId,jdbcType=VARCHAR}, resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if> </if>
<if test="record.issuesId != null"> <if test="record.issuesId != null">
issues_id = #{record.issuesId,jdbcType=VARCHAR}, issues_id = #{record.issuesId,jdbcType=VARCHAR},
</if> </if>
<if test="record.refId != null">
ref_id = #{record.refId,jdbcType=VARCHAR},
</if>
<if test="record.refType != null">
ref_type = #{record.refType,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -154,8 +174,10 @@
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update test_case_issues update test_case_issues
set id = #{record.id,jdbcType=VARCHAR}, set id = #{record.id,jdbcType=VARCHAR},
test_case_id = #{record.testCaseId,jdbcType=VARCHAR}, resource_id = #{record.resourceId,jdbcType=VARCHAR},
issues_id = #{record.issuesId,jdbcType=VARCHAR} issues_id = #{record.issuesId,jdbcType=VARCHAR},
ref_id = #{record.refId,jdbcType=VARCHAR},
ref_type = #{record.refType,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -163,19 +185,27 @@
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestCaseIssues"> <update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestCaseIssues">
update test_case_issues update test_case_issues
<set> <set>
<if test="testCaseId != null"> <if test="resourceId != null">
test_case_id = #{testCaseId,jdbcType=VARCHAR}, resource_id = #{resourceId,jdbcType=VARCHAR},
</if> </if>
<if test="issuesId != null"> <if test="issuesId != null">
issues_id = #{issuesId,jdbcType=VARCHAR}, issues_id = #{issuesId,jdbcType=VARCHAR},
</if> </if>
<if test="refId != null">
ref_id = #{refId,jdbcType=VARCHAR},
</if>
<if test="refType != null">
ref_type = #{refType,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestCaseIssues"> <update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestCaseIssues">
update test_case_issues update test_case_issues
set test_case_id = #{testCaseId,jdbcType=VARCHAR}, set resource_id = #{resourceId,jdbcType=VARCHAR},
issues_id = #{issuesId,jdbcType=VARCHAR} issues_id = #{issuesId,jdbcType=VARCHAR},
ref_id = #{refId,jdbcType=VARCHAR},
ref_type = #{refType,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -12,7 +12,7 @@ public interface ExtIssuesMapper {
List<IssuesDao> getIssuesByCaseId(@Param("request") IssuesRequest issuesRequest); List<IssuesDao> getIssuesByCaseId(@Param("request") IssuesRequest issuesRequest);
List<IssuesDao> getIssueForMinder(@Param("caseIds") List<String> caseIds); List<IssuesDao> getIssueForMinder(@Param("caseIds") List<String> caseIds, @Param("refType") String refType);
List<IssuesDao> getIssues(@Param("request") IssuesRequest issuesRequest); List<IssuesDao> getIssues(@Param("request") IssuesRequest issuesRequest);

View File

@ -7,25 +7,33 @@
from issues from issues
inner join test_case_issues inner join test_case_issues
on test_case_issues.issues_id = issues.id on test_case_issues.issues_id = issues.id
<if test="request.projectId != null||request.workspaceId != null">
left join
project on issues.project_id = project.id
</if>
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
and (issues.platform_status != 'delete' or issues.platform_status is NULL) and (issues.platform_status != 'delete' or issues.platform_status is NULL)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select> </select>
<select id="getIssueForMinder" resultType="io.metersphere.base.domain.IssuesDao"> <select id="getIssueForMinder" resultType="io.metersphere.base.domain.IssuesDao">
select issues.id, issues.title , issues.num , test_case_issues.test_case_id as caseId select issues.id, issues.title , issues.num , test_case_issues.resource_id as caseId
from issues from issues
inner join test_case_issues inner join test_case_issues
on test_case_issues.issues_id = issues.id on test_case_issues.issues_id = issues.id
where test_case_id in where (issues.platform_status != 'delete' or issues.platform_status is NULL)
<foreach collection="caseIds" open="(" close=")" item="item" separator=","> <if test="refType == 'FUNCTIONAL'">
#{item} and test_case_issues.resource_id in
</foreach> <foreach collection="caseIds" open="(" close=")" item="item" separator=",">
and (issues.platform_status != 'delete' or issues.platform_status is NULL) #{item}
</foreach>
or test_case_issues.ref_id in
<foreach collection="caseIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="refType == 'PLAN_FUNCTIONAL'">
and test_case_issues.resource_id in
<foreach collection="caseIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
order by num asc order by num asc
</select> </select>
@ -54,13 +62,13 @@
</select> </select>
<select id="getRelateIssues" resultType="io.metersphere.base.domain.IssuesDao"> <select id="getRelateIssues" resultType="io.metersphere.base.domain.IssuesDao">
select issues.id, issues.num, issues.title, issues.project_id, issues.create_time, issues.update_time, select issues.id, issues.num, issues.title, issues.project_id, issues.create_time, issues.update_time,
issues.description, issues.status, issues.platform, issues.custom_fields,test_case_issues.test_case_id,issues.platform_status, issues.description, issues.status, issues.platform, issues.custom_fields,test_case_issues.resource_id,issues.platform_status,
issues.lastmodify issues.lastmodify
from issues from issues
left join left join
test_case_issues on issues.id = test_case_issues.issues_id test_case_issues on issues.id = test_case_issues.issues_id
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
and (test_case_issues.test_case_id is null or test_case_issues.test_case_id != #{request.caseId}) and (test_case_issues.resource_id is null or test_case_issues.resource_id != #{request.caseResourceId})
and (issues.platform_status != 'delete' or issues.platform_status is NULL) and (issues.platform_status != 'delete' or issues.platform_status is NULL)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
group by issues.id group by issues.id
@ -107,8 +115,13 @@
and issues.resource_id = #{request.resourceId} and issues.resource_id = #{request.resourceId}
</if> </if>
<if test="request.testCaseId != null and request.testCaseId != ''"> <if test="request.caseResourceId != null and request.caseResourceId != ''">
and test_case_issues.test_case_id = #{request.testCaseId} <if test="request.refType == 'FUNCTIONAL'">
and (test_case_issues.resource_id = #{request.caseResourceId} or test_case_issues.ref_id = #{request.caseResourceId})
</if>
<if test="request.refType == 'PLAN_FUNCTIONAL'">
and test_case_issues.resource_id = #{request.caseResourceId}
</if>
</if> </if>
<if test="request.platform != null and request.platform != ''"> <if test="request.platform != null and request.platform != ''">
@ -118,13 +131,6 @@
and issues.id = #{request.id} and issues.id = #{request.id}
</if> </if>
<!-- <if test="request.ids != null and request.ids.size() > 0">-->
<!-- and issues.id in-->
<!-- <foreach collection="request.ids" item="id" separator="," open="(" close=")">-->
<!-- #{id}-->
<!-- </foreach>-->
<!-- </if>-->
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values"> <foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0"> <if test="values != null and values.size() > 0">

View File

@ -249,8 +249,8 @@
<select id="getProjectPlanBugSize" resultType="java.lang.Integer"> <select id="getProjectPlanBugSize" resultType="java.lang.Integer">
select count(distinct (tci.issues_id)) select count(distinct (tci.issues_id))
from test_plan_test_case tptc from test_plan_test_case tptc
join test_case_issues tci on tptc.case_id = tci.test_case_id join test_case_issues tci on tptc.case_id = tci.resource_id
right join test_case on test_case.id = tci.test_case_id right join test_case on test_case.id = tci.resource_id
join issues on tci.issues_id = issues.id join issues on tci.issues_id = issues.id
join test_plan on tptc.plan_id = test_plan.id join test_plan on tptc.plan_id = test_plan.id
where test_plan.project_id = #{projectId} where test_plan.project_id = #{projectId}

View File

@ -724,9 +724,9 @@
<select id="getTestPlanBug" resultType="int"> <select id="getTestPlanBug" resultType="int">
select count(distinct (tci.issues_id)) select count(distinct (tci.issues_id))
from test_plan_test_case tptc from test_plan_test_case tptc
join test_case_issues tci on tptc.case_id = tci.test_case_id join test_case_issues tci on tptc.case_id = tci.resource_id
right join test_case right join test_case
on test_case.id = tci.test_case_id on test_case.id = tci.resource_id
join issues join issues
on tci.issues_id = issues.id on tci.issues_id = issues.id
where tptc.plan_id = #{planId} where tptc.plan_id = #{planId}

View File

@ -0,0 +1,5 @@
package io.metersphere.commons.constants;
public enum IssueRefType {
FUNCTIONAL, PLAN_FUNCTIONAL
}

View File

@ -67,10 +67,10 @@ public class IssuesController {
issuesService.updateIssues(issuesRequest); issuesService.updateIssues(issuesRequest);
} }
@GetMapping("/get/case/{id}") @GetMapping("/get/case/{refType}/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<IssuesDao> getIssues(@PathVariable String id) { public List<IssuesDao> getIssues(@PathVariable String refType, @PathVariable String id) {
return issuesService.getIssues(id); return issuesService.getIssues(id, refType);
} }
@GetMapping("/get/{id}") @GetMapping("/get/{id}")
@ -100,13 +100,6 @@ public class IssuesController {
issuesService.closeLocalIssue(id); issuesService.closeLocalIssue(id);
} }
@PostMapping("/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#request.id)", msClass = IssuesService.class)
public void deleteIssue(@RequestBody IssuesRequest request) {
issuesService.deleteIssue(request);
}
@PostMapping("/delete/relate") @PostMapping("/delete/relate")
public void deleteRelate(@RequestBody IssuesRequest request) { public void deleteRelate(@RequestBody IssuesRequest request) {
issuesService.deleteIssueRelate(request); issuesService.deleteIssueRelate(request);

View File

@ -1,10 +1,8 @@
package io.metersphere.track.domain; package io.metersphere.track.domain;
import io.metersphere.base.domain.Project; import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCaseNode;
import io.metersphere.base.domain.TestCaseNodeExample;
import io.metersphere.base.mapper.TestCaseNodeMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper; import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper;
import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.MathUtils; import io.metersphere.commons.utils.MathUtils;
@ -124,7 +122,7 @@ public class ReportResultComponent extends ReportComponent {
if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Blocking.name())) { if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Blocking.name())) {
moduleResult.setBlockingCount(moduleResult.getBlockingCount() + 1); moduleResult.setBlockingCount(moduleResult.getBlockingCount() + 1);
} }
moduleResult.setIssuesCount(moduleResult.getIssuesCount() + issuesService.getIssues(testCase.getCaseId()).size()); moduleResult.setIssuesCount(moduleResult.getIssuesCount() + issuesService.getIssues(testCase.getId(), IssueRefType.PLAN_FUNCTIONAL.name()).size());
moduleResultMap.put(rootNodeId, moduleResult); moduleResultMap.put(rootNodeId, moduleResult);
return; return;
} }

View File

@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.TestCaseIssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper;
import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper;
import io.metersphere.commons.constants.CustomFieldType; import io.metersphere.commons.constants.CustomFieldType;
import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.commons.constants.IssuesStatus; import io.metersphere.commons.constants.IssuesStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
@ -170,52 +171,35 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
return issueConfig; return issueConfig;
} }
protected boolean isIntegratedPlatform(String workspaceId, String platform) {
IntegrationRequest request = new IntegrationRequest();
request.setPlatform(platform);
request.setWorkspaceId(workspaceId);
ServiceIntegration integration = integrationService.get(request);
return StringUtils.isNotBlank(integration.getId());
}
protected void insertTestCaseIssues(String issuesId, String caseId) {
if (StringUtils.isNotBlank(caseId)) {
TestCaseIssues testCaseIssues = new TestCaseIssues();
testCaseIssues.setId(UUID.randomUUID().toString());
testCaseIssues.setIssuesId(issuesId);
testCaseIssues.setTestCaseId(caseId);
testCaseIssuesMapper.insert(testCaseIssues);
testCaseIssueService.updateIssuesCount(caseId);
}
}
protected void handleIssueUpdate(IssuesUpdateRequest request) { protected void handleIssueUpdate(IssuesUpdateRequest request) {
request.setUpdateTime(System.currentTimeMillis()); request.setUpdateTime(System.currentTimeMillis());
issuesMapper.updateByPrimaryKeySelective(request); issuesMapper.updateByPrimaryKeySelective(request);
if (!request.isWithoutTestCaseIssue()) { handleTestCaseIssues(request);
handleTestCaseIssues(request);
}
} }
protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) {
String issuesId = issuesRequest.getId(); String issuesId = issuesRequest.getId();
if (StringUtils.isNotBlank(issuesRequest.getTestCaseId())) { List<String> deleteCaseIds = issuesRequest.getDeleteResourceIds();
insertTestCaseIssues(issuesId, issuesRequest.getTestCaseId());
} else { if (!CollectionUtils.isEmpty(deleteCaseIds)) {
List<String> testCaseIds = issuesRequest.getTestCaseIds();
TestCaseIssuesExample example = new TestCaseIssuesExample(); TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andIssuesIdEqualTo(issuesId); example.createCriteria().andResourceIdIn(deleteCaseIds);
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example); // 测试计划的用例 deleteCaseIds 是空的 不会进到这里
List<String> deleteCaseIds = testCaseIssues.stream().map(TestCaseIssues::getTestCaseId).collect(Collectors.toList()); example.or(example.createCriteria().andRefIdIn(deleteCaseIds));
if (!CollectionUtils.isEmpty(testCaseIds)) {
deleteCaseIds.removeAll(testCaseIds);
}
testCaseIssuesMapper.deleteByExample(example); testCaseIssuesMapper.deleteByExample(example);
deleteCaseIds.forEach(testCaseIssueService::updateIssuesCount); }
if (!CollectionUtils.isEmpty(testCaseIds)) {
testCaseIds.forEach(caseId -> { List<String> addCaseIds = issuesRequest.getAddResourceIds();
insertTestCaseIssues(issuesId, caseId); TestCaseIssueService testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class);
if (!CollectionUtils.isEmpty(addCaseIds)) {
if (issuesRequest.getIsPlanEdit()) {
addCaseIds.forEach(caseId -> {
testCaseIssueService.add(issuesId, caseId, issuesRequest.getRefId(), IssueRefType.PLAN_FUNCTIONAL.name());
testCaseIssueService.updateIssuesCount(caseId);
}); });
} else {
addCaseIds.forEach(caseId -> testCaseIssueService.add(issuesId, caseId, null, IssueRefType.FUNCTIONAL.name()));
} }
} }
} }
@ -380,11 +364,8 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
@Override @Override
public void deleteIssue(String id) { public void deleteIssue(String id) {
issuesMapper.deleteByPrimaryKey(id); IssuesService issuesService = CommonBeanFactory.getBean(IssuesService.class);
TestCaseIssuesExample example = new TestCaseIssuesExample(); issuesService.deleteIssue(id);
example.createCriteria()
.andIssuesIdEqualTo(id);
testCaseIssuesMapper.deleteByExample(example);
} }
protected void addCustomFields(IssuesUpdateRequest issuesRequest, MultiValueMap<String, Object> paramMap) { protected void addCustomFields(IssuesUpdateRequest issuesRequest, MultiValueMap<String, Object> paramMap) {

View File

@ -34,4 +34,9 @@ public class IssuesRelevanceRequest {
private Boolean checked; private Boolean checked;
private String description; private String description;
private String caseResourceId;
private List<String> caseResourceIds;
private Boolean isPlanEdit = false;
private String refId;
} }

View File

@ -15,6 +15,12 @@ public class IssuesRequest extends BaseQueryRequest {
private String testCaseId; private String testCaseId;
private List<String> tapdUsers; private List<String> tapdUsers;
private String userId; private String userId;
/**
* 关联类型
* 如果类型是 FUNCTIONAL 表示是功能用例查询相关缺陷此时需要把该功能用例对应的测试计划中的用例关联的缺陷一并查出
* 如果是 PLAN_FUNCTIONAL 则只查询该测试计划用例所关联的缺陷
*/
private String refType;
/** /**
* zentao bug 处理人 * zentao bug 处理人
*/ */
@ -30,6 +36,10 @@ public class IssuesRequest extends BaseQueryRequest {
private String id; private String id;
private String caseId; private String caseId;
private String resourceId; private String resourceId;
/**
* 查询用例下的缺陷的用例id或者测试计划的用例id
*/
private String caseResourceId;
private String platform; private String platform;
private String customFields; private String customFields;
private List<String> testCaseIds; private List<String> testCaseIds;
@ -37,4 +47,5 @@ public class IssuesRequest extends BaseQueryRequest {
private String requestType; private String requestType;
private String status; private String status;
private String defaultCustomFields; private String defaultCustomFields;
private Boolean isPlanEdit = false;
} }

View File

@ -10,7 +10,6 @@ import java.util.List;
@Setter @Setter
public class IssuesUpdateRequest extends IssuesWithBLOBs { public class IssuesUpdateRequest extends IssuesWithBLOBs {
private String content; private String content;
private String testCaseId;
private String workspaceId; private String workspaceId;
private List<String> tapdUsers; private List<String> tapdUsers;
@ -23,11 +22,12 @@ public class IssuesUpdateRequest extends IssuesWithBLOBs {
* zentao bug 影响版本 * zentao bug 影响版本
*/ */
private List<String> zentaoBuilds; private List<String> zentaoBuilds;
private List<String> testCaseIds;
private boolean thirdPartPlatform; private boolean thirdPartPlatform;
private List<String> follows; private List<String> follows;
private boolean withoutTestCaseIssue; // 不更新用例和缺陷的关联关系 private List<String> addResourceIds;
private List<String> deleteResourceIds;
private Boolean isPlanEdit = false;
private String refId;
} }

View File

@ -8,6 +8,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper;
import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesManagePlatform;
import io.metersphere.commons.constants.IssuesStatus; import io.metersphere.commons.constants.IssuesStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
@ -94,9 +95,11 @@ public class IssuesService {
for (AbstractIssuePlatform platform : platformList) { for (AbstractIssuePlatform platform : platformList) {
issues = platform.addIssue(issuesRequest); issues = platform.addIssue(issuesRequest);
} }
issuesRequest.getTestCaseIds().forEach(l -> { if (issuesRequest.getIsPlanEdit()) {
testCaseIssueService.updateIssuesCount(l); issuesRequest.getAddResourceIds().forEach(l -> {
}); testCaseIssueService.updateIssuesCount(l);
});
}
saveFollows(issuesRequest.getId(), issuesRequest.getFollows()); saveFollows(issuesRequest.getId(), issuesRequest.getFollows());
return issues; return issues;
} }
@ -128,13 +131,13 @@ public class IssuesService {
public List<AbstractIssuePlatform> getAddPlatforms(IssuesUpdateRequest updateRequest) { public List<AbstractIssuePlatform> getAddPlatforms(IssuesUpdateRequest updateRequest) {
List<String> platforms = new ArrayList<>(); List<String> platforms = new ArrayList<>();
if (StringUtils.isNotBlank(updateRequest.getTestCaseId())) { // if (StringUtils.isNotBlank(updateRequest.getTestCaseId())) {
// 测试计划关联 // // 测试计划关联
platforms.add(getPlatformsByCaseId(updateRequest.getTestCaseId())); // platforms.add(getPlatformsByCaseId(updateRequest.getTestCaseId()));
} else { // } else {
// 缺陷管理关联 // 缺陷管理关联
platforms.add(getPlatform(updateRequest.getProjectId())); platforms.add(getPlatform(updateRequest.getProjectId()));
} // }
if (CollectionUtils.isEmpty(platforms)) { if (CollectionUtils.isEmpty(platforms)) {
platforms.add(IssuesManagePlatform.Local.toString()); platforms.add(IssuesManagePlatform.Local.toString());
@ -159,37 +162,18 @@ public class IssuesService {
return IssueFactory.createPlatforms(platforms, issuesRequest); return IssueFactory.createPlatforms(platforms, issuesRequest);
} }
public List<IssuesDao> getIssues(String caseId) { public List<IssuesDao> getIssues(String caseResourceId, String refType) {
IssuesRequest issueRequest = new IssuesRequest(); IssuesRequest issueRequest = new IssuesRequest();
issueRequest.setTestCaseId(caseId); issueRequest.setCaseResourceId(caseResourceId);
ServiceUtils.getDefaultOrder(issueRequest.getOrders()); ServiceUtils.getDefaultOrder(issueRequest.getOrders());
Project project = getProjectByCaseId(caseId); issueRequest.setRefType(refType);
// project 不存在 return extIssuesMapper.getIssuesByCaseId(issueRequest);
if (project == null) {
return null;
}
String workspaceId = project.getWorkspaceId();
TestCase testCase = testCaseMapper.selectByPrimaryKey(caseId);
String userId = testCase.getMaintainer();
issueRequest.setWorkspaceId(workspaceId);
issueRequest.setUserId(userId);
return getIssuesByProjectIdOrCaseId(issueRequest);
} }
public IssuesWithBLOBs getIssue(String id) { public IssuesWithBLOBs getIssue(String id) {
return issuesMapper.selectByPrimaryKey(id); return issuesMapper.selectByPrimaryKey(id);
} }
public List<IssuesDao> getIssuesByProjectIdOrCaseId(IssuesRequest issueRequest) {
List<IssuesDao> issues;
if (StringUtils.isNotBlank(issueRequest.getProjectId())) {
issues = extIssuesMapper.getIssues(issueRequest);
} else {
issues = extIssuesMapper.getIssuesByCaseId(issueRequest);
}
return issues;
}
public String getPlatformsByCaseId(String caseId) { public String getPlatformsByCaseId(String caseId) {
TestCaseWithBLOBs testCase = testCaseService.getTestCase(caseId); TestCaseWithBLOBs testCase = testCaseService.getTestCase(caseId);
Project project = projectService.getProjectById(testCase.getProjectId()); Project project = projectService.getProjectById(testCase.getProjectId());
@ -288,18 +272,28 @@ public class IssuesService {
return platform.getPlatformUser(); return platform.getPlatformUser();
} }
public void deleteIssue(IssuesRequest request) { public void deleteIssue(String id) {
issuesMapper.deleteByPrimaryKey(request.getId()); issuesMapper.deleteByPrimaryKey(id);
deleteIssueRelate(request); TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andIssuesIdEqualTo(id);
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
testCaseIssues.forEach(i -> {
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL)) {
testCaseIssueService.updateIssuesCount(i.getResourceId());
}
});
testCaseIssuesMapper.deleteByExample(example);
} }
public void deleteIssueRelate(IssuesRequest request) { public void deleteIssueRelate(IssuesRequest request) {
String caseId = request.getCaseId(); String caseResourceId = request.getCaseResourceId();
String id = request.getId(); String id = request.getId();
TestCaseIssuesExample example = new TestCaseIssuesExample(); TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andTestCaseIdEqualTo(caseId).andIssuesIdEqualTo(id); example.createCriteria().andResourceIdEqualTo(caseResourceId).andIssuesIdEqualTo(id);
testCaseIssuesMapper.deleteByExample(example); testCaseIssuesMapper.deleteByExample(example);
testCaseIssueService.updateIssuesCount(caseId); if (request.getIsPlanEdit()) {
testCaseIssueService.updateIssuesCount(caseResourceId);
}
} }
public void delete(String id) { public void delete(String id) {
@ -339,8 +333,6 @@ public class IssuesService {
Map<String, String> planMap = testPlans.stream() Map<String, String> planMap = testPlans.stream()
.collect(Collectors.toMap(TestPlan::getId, TestPlan::getName)); .collect(Collectors.toMap(TestPlan::getId, TestPlan::getName));
Project project = projectService.getProjectById(request.getProjectId());
issues.forEach(item -> { issues.forEach(item -> {
User createUser = userMap.get(item.getCreator()); User createUser = userMap.get(item.getCreator());
if (createUser != null) { if (createUser != null) {
@ -353,18 +345,22 @@ public class IssuesService {
example.createCriteria().andIssuesIdEqualTo(item.getId()); example.createCriteria().andIssuesIdEqualTo(item.getId());
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example); List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
List<String> caseIds = testCaseIssues.stream() List<String> caseIds = testCaseIssues.stream()
.map(TestCaseIssues::getTestCaseId) .map(TestCaseIssues::getResourceId)
.collect(Collectors.toList()); .collect(Collectors.toList());
item.setCaseIds(caseIds); item.setCaseIds(caseIds);
item.setCaseCount(testCaseIssues.size()); item.setCaseCount(testCaseIssues.size());
if (IssuesManagePlatform.Tapd.name().equals(project.getPlatform()) && StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Tapd.name())) { try {
TapdPlatform platform = (TapdPlatform) IssueFactory.createPlatform(item.getPlatform(), request); if (StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Tapd.name())) {
List<String> tapdUsers = platform.getTapdUsers(item.getProjectId(), item.getPlatformId()); TapdPlatform platform = (TapdPlatform) IssueFactory.createPlatform(item.getPlatform(), request);
item.setTapdUsers(tapdUsers); List<String> tapdUsers = platform.getTapdUsers(item.getProjectId(), item.getPlatformId());
} item.setTapdUsers(tapdUsers);
if (IssuesManagePlatform.Zentao.name().equals(project.getPlatform()) && StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Zentao.name())) { }
ZentaoPlatform platform = (ZentaoPlatform) IssueFactory.createPlatform(item.getPlatform(), request); if (StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Zentao.name())) {
platform.getZentaoAssignedAndBuilds(item); ZentaoPlatform platform = (ZentaoPlatform) IssueFactory.createPlatform(item.getPlatform(), request);
platform.getZentaoAssignedAndBuilds(item);
}
} catch (Exception e) {
LogUtil.error(e);
} }
}); });
return issues; return issues;

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.IssuesMapper;
import io.metersphere.base.mapper.TestCaseIssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper;
import io.metersphere.base.mapper.TestPlanTestCaseMapper; import io.metersphere.base.mapper.TestPlanTestCaseMapper;
import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.request.issues.IssuesRelevanceRequest; import io.metersphere.track.request.issues.IssuesRelevanceRequest;
@ -16,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -41,13 +43,13 @@ public class TestCaseIssueService {
public void delTestCaseIssues(String testCaseId) { public void delTestCaseIssues(String testCaseId) {
TestCaseIssuesExample example = new TestCaseIssuesExample(); TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andTestCaseIdEqualTo(testCaseId); example.createCriteria().andResourceIdEqualTo(testCaseId);
testCaseIssuesMapper.deleteByExample(example); testCaseIssuesMapper.deleteByExample(example);
} }
public List<TestCaseDTO> list(IssuesRelevanceRequest request) { public List<TestCaseDTO> list(IssuesRelevanceRequest request) {
List<String> testCaseIds = getTestCaseIdsByIssuesId(request.getIssuesId()); List<String> caseIds = getCaseIdsByIssuesId(request.getIssuesId());
List<TestCaseDTO> list = testCaseService.getTestCaseByIds(testCaseIds); List<TestCaseDTO> list = testCaseService.getTestCaseByIds(caseIds);
testCaseService.addProjectName(list); testCaseService.addProjectName(list);
return list; return list;
} }
@ -58,37 +60,56 @@ public class TestCaseIssueService {
return testCaseIssuesMapper.selectByExample(example); return testCaseIssuesMapper.selectByExample(example);
} }
public List<String> getTestCaseIdsByIssuesId(String issuesId) { /**
return getTestCaseIssuesByIssuesId(issuesId).stream() * 测试计划的用例获取对应的功能用例
.map(TestCaseIssues::getTestCaseId) * @param issuesId
.collect(Collectors.toList()); * @return
*/
public List<String> getCaseIdsByIssuesId(String issuesId) {
List<TestCaseIssues> testCaseIssueList = getTestCaseIssuesByIssuesId(issuesId);
List<String> caseIds = new ArrayList<>();
testCaseIssueList.forEach(i -> {
if (StringUtils.equals(i.getRefType(), IssueRefType.PLAN_FUNCTIONAL.name())) {
caseIds.add(i.getRefId());
} else {
caseIds.add(i.getResourceId());
}
});
return caseIds;
} }
public void relate(IssuesRelevanceRequest request) { public void relate(IssuesRelevanceRequest request) {
if (StringUtils.isNotBlank(request.getCaseId())) { if (StringUtils.isNotBlank(request.getCaseResourceId())) {
List<String> issueIds = request.getIssueIds(); List<String> issueIds = request.getIssueIds();
if (!CollectionUtils.isEmpty(issueIds)) { if (!CollectionUtils.isEmpty(issueIds)) {
issueIds.forEach(issueId -> { issueIds.forEach(issueId -> {
create(request.getCaseId(), issueId); relate(request, issueId, request.getCaseResourceId());
}); });
} }
} else if (StringUtils.isNotBlank(request.getIssuesId())) { } else if (StringUtils.isNotBlank(request.getIssuesId())) {
List<String> caseIds = request.getTestCaseIds(); List<String> caseResourceIds = request.getCaseResourceIds();
if (!CollectionUtils.isEmpty(caseIds)) { if (!CollectionUtils.isEmpty(caseResourceIds)) {
caseIds.forEach(caseId -> { caseResourceIds.forEach(caseResourceId -> {
create(caseId, request.getIssuesId()); relate(request, request.getIssuesId(), caseResourceId);
}); });
} }
} }
updateIssuesCount(request.getCaseId());
} }
public void updateIssuesCount(String caseId) { protected void relate(IssuesRelevanceRequest request, String issueId, String caseResourceId) {
List<IssuesDao> issues = issuesService.getIssues(caseId); if (request.getIsPlanEdit()) {
add(issueId, caseResourceId, request.getRefId(), IssueRefType.PLAN_FUNCTIONAL.name());
updateIssuesCount(request.getCaseResourceId());
} else {
add(issueId, caseResourceId, null, IssueRefType.FUNCTIONAL.name());
}
}
public void updateIssuesCount(String resourceId) {
List<IssuesDao> issues = issuesService.getIssues(resourceId, IssueRefType.PLAN_FUNCTIONAL.name());
int issuesCount = issues.size(); int issuesCount = issues.size();
TestPlanTestCaseExample example = new TestPlanTestCaseExample(); TestPlanTestCaseExample example = new TestPlanTestCaseExample();
example.createCriteria().andCaseIdEqualTo(caseId); example.createCriteria().andIdEqualTo(resourceId);
TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs(); TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs();
testPlanTestCase.setIssuesCount(issuesCount); testPlanTestCase.setIssuesCount(issuesCount);
if (!CollectionUtils.isEmpty(issues)) { if (!CollectionUtils.isEmpty(issues)) {
@ -97,15 +118,18 @@ public class TestCaseIssueService {
testPlanTestCaseMapper.updateByExampleSelective(testPlanTestCase, example); testPlanTestCaseMapper.updateByExampleSelective(testPlanTestCase, example);
} }
public void create(String caseId, String issueId) { public void add(String issuesId, String resourceId, String refId, String refType) {
TestCaseIssues testCaseIssues = new TestCaseIssues(); if (StringUtils.isNotBlank(resourceId)) {
testCaseIssues.setId(UUID.randomUUID().toString()); TestCaseIssues testCaseIssues = new TestCaseIssues();
testCaseIssues.setTestCaseId(caseId); testCaseIssues.setId(UUID.randomUUID().toString());
testCaseIssues.setIssuesId(issueId); testCaseIssues.setIssuesId(issuesId);
testCaseIssuesMapper.insert(testCaseIssues); testCaseIssues.setResourceId(resourceId);
testCaseIssues.setRefType(refType);
testCaseIssues.setRefId(refId);
testCaseIssuesMapper.insert(testCaseIssues);
}
} }
public String getLogDetails(IssuesRelevanceRequest request) { public String getLogDetails(IssuesRelevanceRequest request) {
TestCaseWithBLOBs bloBs = testCaseService.getTestCase(request.getCaseId()); TestCaseWithBLOBs bloBs = testCaseService.getTestCase(request.getCaseId());
if (bloBs != null) { if (bloBs != null) {

View File

@ -19,6 +19,7 @@ import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper;
import io.metersphere.base.mapper.ext.ExtProjectVersionMapper; import io.metersphere.base.mapper.ext.ExtProjectVersionMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.constants.TestCaseReviewStatus; import io.metersphere.commons.constants.TestCaseReviewStatus;
import io.metersphere.commons.constants.UserGroupType; import io.metersphere.commons.constants.UserGroupType;
@ -346,12 +347,12 @@ public class TestCaseService {
testCase.setDemandName(null); testCase.setDemandName(null);
} }
if (otherInfoConfig.isRelateIssue()) { if (otherInfoConfig.isRelateIssue()) {
List<IssuesDao> issuesDaos = issuesService.getIssues(oldTestCaseId); List<IssuesDao> issuesDaos = issuesService.getIssues(oldTestCaseId, IssueRefType.FUNCTIONAL.name());
if (CollectionUtils.isNotEmpty(issuesDaos)) { if (CollectionUtils.isNotEmpty(issuesDaos)) {
issuesDaos.forEach(issue -> { issuesDaos.forEach(issue -> {
TestCaseIssues t = new TestCaseIssues(); TestCaseIssues t = new TestCaseIssues();
t.setId(UUID.randomUUID().toString()); t.setId(UUID.randomUUID().toString());
t.setTestCaseId(testCase.getId()); t.setResourceId(testCase.getId());
t.setIssuesId(issue.getId()); t.setIssuesId(issue.getId());
testCaseIssuesMapper.insertSelective(t); testCaseIssuesMapper.insertSelective(t);
}); });
@ -1907,7 +1908,7 @@ public class TestCaseService {
setDefaultOrder(request); setDefaultOrder(request);
List<TestCaseDTO> cases = extTestCaseMapper.listForMinder(request); List<TestCaseDTO> cases = extTestCaseMapper.listForMinder(request);
List<String> caseIds = cases.stream().map(TestCaseDTO::getId).collect(Collectors.toList()); List<String> caseIds = cases.stream().map(TestCaseDTO::getId).collect(Collectors.toList());
HashMap<String, List<IssuesDao>> issueMap = buildMinderIssueMap(caseIds); HashMap<String, List<IssuesDao>> issueMap = buildMinderIssueMap(caseIds, IssueRefType.FUNCTIONAL.name());
for (TestCaseDTO item : cases) { for (TestCaseDTO item : cases) {
List<IssuesDao> issues = issueMap.get(item.getId()); List<IssuesDao> issues = issueMap.get(item.getId());
if (issues != null) { if (issues != null) {
@ -1917,10 +1918,10 @@ public class TestCaseService {
return cases; return cases;
} }
public HashMap<String, List<IssuesDao>> buildMinderIssueMap(List<String> caseIds) { public HashMap<String, List<IssuesDao>> buildMinderIssueMap(List<String> caseIds, String refType) {
HashMap<String, List<IssuesDao>> issueMap = new HashMap<>(); HashMap<String, List<IssuesDao>> issueMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(caseIds)) { if (CollectionUtils.isNotEmpty(caseIds)) {
List<IssuesDao> issues = extIssuesMapper.getIssueForMinder(caseIds); List<IssuesDao> issues = extIssuesMapper.getIssueForMinder(caseIds, refType);
for (IssuesDao item : issues) { for (IssuesDao item : issues) {
List<IssuesDao> list = issueMap.get(item.getCaseId()); List<IssuesDao> list = issueMap.get(item.getCaseId());
if (list == null) { if (list == null) {
@ -2010,7 +2011,7 @@ public class TestCaseService {
//关联缺陷 //关联缺陷
List<String> issuesNames = new LinkedList<>(); List<String> issuesNames = new LinkedList<>();
TestCaseIssuesExample testCaseIssuesExample = new TestCaseIssuesExample(); TestCaseIssuesExample testCaseIssuesExample = new TestCaseIssuesExample();
testCaseIssuesExample.createCriteria().andTestCaseIdEqualTo(bloBs.getId()); testCaseIssuesExample.createCriteria().andResourceIdEqualTo(bloBs.getId());
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(testCaseIssuesExample); List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(testCaseIssuesExample);
if (CollectionUtils.isNotEmpty(testCaseIssues)) { if (CollectionUtils.isNotEmpty(testCaseIssues)) {
List<String> issuesIds = testCaseIssues.stream().map(TestCaseIssues::getIssuesId).collect(Collectors.toList()); List<String> issuesIds = testCaseIssues.stream().map(TestCaseIssues::getIssuesId).collect(Collectors.toList());
@ -2552,7 +2553,7 @@ public class TestCaseService {
TestCaseWithBLOBs tc = getTestCase(caseId); TestCaseWithBLOBs tc = getTestCase(caseId);
if (tc != null) { if (tc != null) {
if (StringUtils.isNotBlank(tc.getRemark()) || StringUtils.isNotBlank(tc.getDemandId()) || CollectionUtils.isNotEmpty(getRelateTest(caseId)) if (StringUtils.isNotBlank(tc.getRemark()) || StringUtils.isNotBlank(tc.getDemandId()) || CollectionUtils.isNotEmpty(getRelateTest(caseId))
|| CollectionUtils.isNotEmpty(issuesService.getIssues(caseId)) || CollectionUtils.isNotEmpty(getRelationshipCase(caseId, "PRE")) || CollectionUtils.isNotEmpty(getRelationshipCase(caseId, "POST")) || CollectionUtils.isNotEmpty(issuesService.getIssues(caseId, IssueRefType.FUNCTIONAL.name())) || CollectionUtils.isNotEmpty(getRelationshipCase(caseId, "PRE")) || CollectionUtils.isNotEmpty(getRelationshipCase(caseId, "POST"))
|| CollectionUtils.isNotEmpty(fileService.getFileMetadataByCaseId(caseId))) { || CollectionUtils.isNotEmpty(fileService.getFileMetadataByCaseId(caseId))) {
return true; return true;
} }

View File

@ -917,7 +917,7 @@ public class TestPlanService {
List<TestPlanCaseDTO> testPlanTestCases = listTestCaseByPlanId(planId); List<TestPlanCaseDTO> testPlanTestCases = listTestCaseByPlanId(planId);
List<IssuesDao> issues = new ArrayList<>(); List<IssuesDao> issues = new ArrayList<>();
for (TestPlanCaseDTO testCase : testPlanTestCases) { for (TestPlanCaseDTO testCase : testPlanTestCases) {
List<IssuesDao> issue = issuesService.getIssues(testCase.getCaseId()); List<IssuesDao> issue = issuesService.getIssues(testCase.getId(), IssueRefType.PLAN_FUNCTIONAL.name());
if (issue.size() > 0) { if (issue.size() > 0) {
for (IssuesDao i : issue) { for (IssuesDao i : issue) {
i.setModel(testCase.getNodePath()); i.setModel(testCase.getNodePath());

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
@ -302,10 +303,10 @@ public class TestPlanTestCaseService {
}); });
request.setOrders(orders); request.setOrders(orders);
List<TestPlanCaseDTO> cases = extTestPlanTestCaseMapper.listForMinder(request); List<TestPlanCaseDTO> cases = extTestPlanTestCaseMapper.listForMinder(request);
List<String> caseIds = cases.stream().map(TestPlanCaseDTO::getCaseId).collect(Collectors.toList()); List<String> caseIds = cases.stream().map(TestPlanCaseDTO::getId).collect(Collectors.toList());
HashMap<String, List<IssuesDao>> issueMap = testCaseService.buildMinderIssueMap(caseIds); HashMap<String, List<IssuesDao>> issueMap = testCaseService.buildMinderIssueMap(caseIds, IssueRefType.PLAN_FUNCTIONAL.name());
for (TestPlanCaseDTO item : cases) { for (TestPlanCaseDTO item : cases) {
List<IssuesDao> issues = issueMap.get(item.getCaseId()); List<IssuesDao> issues = issueMap.get(item.getId());
if (issues != null) { if (issues != null) {
item.setIssueList(issues); item.setIssueList(issues);
} }

View File

@ -63,6 +63,30 @@ DELIMITER ;
CALL test_personal(); CALL test_personal();
DROP PROCEDURE IF EXISTS test_personal; DROP PROCEDURE IF EXISTS test_personal;
-- 测试计划缺陷与用例缺陷分离
ALTER TABLE test_case_issues ADD ref_type varchar(30) DEFAULT 'FUNCTIONAL' NOT NULL;
ALTER TABLE test_case_issues CHANGE test_case_id resource_id varchar(50) NOT NULL;
ALTER TABLE test_case_issues ADD ref_id varchar(50) NULL COMMENT '测试计划的用例所指向的用例的id';
INSERT INTO test_case_issues (id, resource_id, issues_id, ref_id, ref_type)
SELECT uuid(), tptc.id, i.id, tptc.case_id, 'PLAN_FUNCTIONAL'
FROM issues i
INNER JOIN test_case_issues tci
ON tci.issues_id = i.id
INNER JOIN test_plan_test_case tptc
ON tci.resource_id = tptc.case_id AND i.resource_id = tptc.plan_id
DELETE FROM test_case_issues WHERE id IN (
SELECT id FROM (
SELECT tci.id AS id
FROM issues i
INNER JOIN test_case_issues tci
ON tci.issues_id = i.id
INNER JOIN test_plan_test_case tptc
ON tci.resource_id = tptc.case_id AND i.resource_id = tptc.plan_id
) tmp
)
DROP PROCEDURE IF EXISTS project_appl; DROP PROCEDURE IF EXISTS project_appl;
DELIMITER // DELIMITER //

View File

@ -90,7 +90,10 @@ export default {
return getCurrentProjectID(); return getCurrentProjectID();
} }
}, },
props: ['caseId'], props: {
caseId: String,
planCaseId: String,
},
created() { created() {
isThirdPartEnable((data) => { isThirdPartEnable((data) => {
this.isThirdPart = data; this.isThirdPart = data;
@ -103,14 +106,18 @@ export default {
}, },
getIssues() { getIssues() {
this.page.condition.projectId = this.projectId; this.page.condition.projectId = this.projectId;
this.page.condition.caseId = this.caseId; this.page.condition.caseResourceId = this.getCaseResourceId();
this.page.result = getRelateIssues(this.page); this.page.result = getRelateIssues(this.page);
}, },
getCaseResourceId() {
return this.planCaseId ? this.planCaseId : this.caseId;
},
save() { save() {
let param = {}; let param = {};
param.caseId = this.caseId;
param.issueIds = Array.from(this.$refs.table.selectRows).map(i => i.id); param.issueIds = Array.from(this.$refs.table.selectRows).map(i => i.id);
param.caseId = this.caseId; param.caseResourceId = this.getCaseResourceId();
param.isPlanEdit = !!this.planCaseId;
param.refId = this.planCaseId ? this.caseId : null;
testCaseIssueRelate(param, () => { testCaseIssueRelate(param, () => {
this.visible = false; this.visible = false;
this.$emit('refresh', this.$refs.table.selectRows); this.$emit('refresh', this.$refs.table.selectRows);

View File

@ -31,7 +31,9 @@
:plan-id="planId" :plan-id="planId"
:is-copy="isCopy" :is-copy="isCopy"
:read-only="readOnly && !(isTestPlan)" :read-only="readOnly && !(isTestPlan)"
:case-id="caseId" ref="issue"/> :plan-case-id="planId ? this.form.id : null"
:case-id="caseId"
ref="issue"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('commons.relationship.name')" name="relationship"> <el-tab-pane :label="$t('commons.relationship.name')" name="relationship">

View File

@ -85,8 +85,18 @@
</span> </span>
</ms-table> </ms-table>
<test-plan-issue-edit :plan-id="planId" :case-id="caseId" @refresh="getIssues" ref="issueEdit"/> <test-plan-issue-edit
<IssueRelateList :case-id="caseId" @refresh="getIssues" ref="issueRelate"/> :plan-case-id="planCaseId"
:plan-id="planId"
:case-id="caseId"
@refresh="getIssues"
ref="issueEdit"/>
<IssueRelateList
:plan-case-id="planCaseId"
:case-id="caseId"
@refresh="getIssues"
ref="issueRelate"/>
</div> </div>
</template> </template>
@ -124,7 +134,13 @@ export default {
issueRelateVisible: false issueRelateVisible: false
} }
}, },
props: ['caseId', 'readOnly','planId', 'isCopy'], props: {
planId: String,
caseId: String,
planCaseId: String,
readOnly: Boolean,
isCopy: Boolean,
},
computed: { computed: {
issueStatusMap() { issueStatusMap() {
return ISSUE_STATUS_MAP; return ISSUE_STATUS_MAP;
@ -172,12 +188,15 @@ export default {
}, },
getIssues() { getIssues() {
if (!this.isCopy) { if (!this.isCopy) {
let result = getIssuesByCaseId(this.caseId, this.page); let result = getIssuesByCaseId(this.planId ? 'PLAN_FUNCTIONAL' : 'FUNCTIONAL', this.getCaseResourceId(), this.page);
if (result) { if (result) {
this.page.result = result; this.page.result = result;
} }
} }
}, },
getCaseResourceId() {
return this.planId ? this.planCaseId : this.caseId;
},
addIssue() { addIssue() {
if (!this.caseId || this.isCopy) { if (!this.caseId || this.isCopy) {
this.$warning(this.$t('api_test.automation.save_case_info')); this.$warning(this.$t('api_test.automation.save_case_info'));
@ -203,7 +222,7 @@ export default {
} }
}, },
deleteIssue(row) { deleteIssue(row) {
this.page.result = deleteIssueRelate({id: row.id, caseId: this.caseId}, () => { this.page.result = deleteIssueRelate({id: row.id, caseResourceId: this.getCaseResourceId(), isPlanEdit: this.planId ? true : false}, () => {
this.getIssues(); this.getIssues();
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
}); });

View File

@ -7,7 +7,7 @@
append-to-body append-to-body
ref="msEditDialog"> ref="msEditDialog">
<template v-slot:default="scope"> <template v-slot:default="scope">
<issue-edit-detail :is-minder="isMinder" :plan-id="planId" :case-id="caseId" :is-plan="true" @refresh="refresh" @close="handleClose" ref="issueEditDetail"/> <issue-edit-detail :plan-case-id="planCaseId" :is-minder="isMinder" :plan-id="planId" :case-id="caseId" :is-case-edit="true" @refresh="refresh" @close="handleClose" ref="issueEditDetail"/>
</template> </template>
</ms-edit-dialog> </ms-edit-dialog>
</template> </template>
@ -31,7 +31,12 @@ export default {
return getCurrentProjectID(); return getCurrentProjectID();
} }
}, },
props: ['caseId', 'planId', 'isMinder'], props: {
planId: String,
caseId: String,
planCaseId: String,
isMinder: Boolean,
},
methods: { methods: {
open(data) { open(data) {
this.visible = true; this.visible = true;

View File

@ -17,8 +17,19 @@
@save="save" @save="save"
ref="minder" ref="minder"
/> />
<IssueRelateList :case-id="getCurCaseId()" @refresh="refreshRelateIssue" ref="issueRelate"/>
<test-plan-issue-edit :is-minder="true" :plan-id="null" :case-id="getCurCaseId()" @refresh="refreshIssue" ref="issueEdit"/> <IssueRelateList
:case-id="getCurCaseId()"
@refresh="refreshRelateIssue"
ref="issueRelate"/>
<test-plan-issue-edit
:is-minder="true"
:plan-id="null"
:case-id="getCurCaseId()"
@refresh="refreshIssue"
ref="issueEdit"/>
</div> </div>
</template> </template>

View File

@ -14,8 +14,21 @@
@save="save" @save="save"
ref="minder" ref="minder"
/> />
<IssueRelateList :case-id="getCurCaseId()" @refresh="refreshRelateIssue" ref="issueRelate"/>
<test-plan-issue-edit :is-minder="true" :plan-id="planId" :case-id="getCurCaseId()" @refresh="refreshIssue" ref="issueEdit"/> <IssueRelateList
:plan-case-id="getCurId()"
:case-id="getCurCaseId()"
@refresh="refreshRelateIssue"
ref="issueRelate"/>
<test-plan-issue-edit
:is-minder="true"
:plan-id="planId"
:plan-case-id="getCurId()"
:case-id="getCurCaseId()"
@refresh="refreshIssue"
ref="issueEdit"/>
</div> </div>
</template> </template>
@ -180,6 +193,9 @@ name: "TestPlanMinder",
getCurCaseId() { getCurCaseId() {
return getSelectedNodeData().caseId; return getSelectedNodeData().caseId;
}, },
getCurId() {
return getSelectedNodeData().id;
},
refreshIssue(issue) { refreshIssue(issue) {
handleIssueAdd(issue); handleIssueAdd(issue);
}, },

View File

@ -533,9 +533,9 @@ export function handleMinderIssueDelete(commandName, isPlan) {
nodes.forEach(node => { nodes.forEach(node => {
let data = node.data; let data = node.data;
if (data.type === 'issue') { if (data.type === 'issue') {
let caseId = isPlan ? node.parent.data.caseId : node.parent.data.id let caseResourceId = node.parent.data.id;
let p = new Promise((resolve) => { let p = new Promise((resolve) => {
deleteIssueRelate({id: data.id, caseId: caseId}, () => { deleteIssueRelate({id: data.id, caseResourceId, isPlanEdit: isPlan}, () => {
resolve(); resolve();
}); });
}); });

View File

@ -1,5 +1,5 @@
<template> <template>
<el-main v-loading="result.loading" class="container" :style="isPlan ? '' : 'height: calc(100vh - 62px)'"> <el-main v-loading="result.loading" class="container" :style="isCaseEdit ? '' : 'height: calc(100vh - 62px)'">
<el-scrollbar> <el-scrollbar>
<el-form :model="form" :rules="rules" label-position="right" label-width="80px" ref="form"> <el-form :model="form" :rules="rules" label-position="right" label-width="80px" ref="form">
@ -61,8 +61,8 @@
</el-col> </el-col>
</el-row> </el-row>
<el-form-item v-if="!isPlan"> <el-form-item v-if="!isCaseEdit">
<test-case-issue-list :test-case-contain-ids="testCaseContainIds" :issues-id="form.id" <test-case-issue-list :issues-id="form.id"
ref="testCaseIssueList"/> ref="testCaseIssueList"/>
</el-form-item> </el-form-item>
@ -89,8 +89,10 @@
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<issue-comment :issues-id="form.id" <issue-comment :issues-id="form.id"
@getComments="getComments" ref="issueComment"/> @getComments="getComments"
ref="issueComment"/>
</el-form> </el-form>
</el-scrollbar> </el-scrollbar>
@ -159,7 +161,6 @@ export default {
{required: true, message: this.$t('commons.please_fill_content'), trigger: 'blur'}, {required: true, message: this.$t('commons.please_fill_content'), trigger: 'blur'},
] ]
}, },
testCaseContainIds: new Set(),
url: '', url: '',
form: { form: {
title: '', title: '',
@ -215,7 +216,7 @@ export default {
}; };
}, },
props: { props: {
isPlan: { isCaseEdit: {
type: Boolean, type: Boolean,
default() { default() {
return false; return false;
@ -223,6 +224,7 @@ export default {
}, },
caseId: String, caseId: String,
planId: String, planId: String,
planCaseId: String,
isMinder: Boolean, isMinder: Boolean,
}, },
computed: { computed: {
@ -301,7 +303,6 @@ export default {
} }
}, },
initEdit(data) { initEdit(data) {
this.testCaseContainIds = new Set();
if (data) { if (data) {
Object.assign(this.form, data); Object.assign(this.form, data);
if (!(data.options instanceof Array)) { if (!(data.options instanceof Array)) {
@ -361,10 +362,24 @@ export default {
param.projectId = this.projectId; param.projectId = this.projectId;
param.workspaceId = getCurrentWorkspaceId(); param.workspaceId = getCurrentWorkspaceId();
buildCustomFields(this.form, param, this.issueTemplate); buildCustomFields(this.form, param, this.issueTemplate);
if (this.isPlan) { if (this.planId) {
param.testCaseIds = [this.caseId]; //
if (!this.form.id) {
param.addResourceIds = [this.planCaseId];
param.refId = this.caseId;
param.isPlanEdit = true;
}
} else { } else {
param.testCaseIds = Array.from(this.testCaseContainIds); if (this.isCaseEdit) {
//
if (!this.form.id) {
param.addResourceIds = [this.caseId];
}
} else {
//
param.addResourceIds = [...this.$refs.testCaseIssueList.addIds];
param.deleteResourceIds = [...this.$refs.testCaseIssueList.deleteIds];
}
} }
if (this.planId) { if (this.planId) {
param.resourceId = this.planId; param.resourceId = this.planId;

View File

@ -52,7 +52,6 @@
<test-case-relate-list <test-case-relate-list
@refresh="initTableData" @refresh="initTableData"
@save="handleRelate" @save="handleRelate"
:test-case-contain-ids="testCaseContainIds"
ref="testCaseRelevance"/> ref="testCaseRelevance"/>
</div> </div>
@ -71,6 +70,8 @@ export default {
return { return {
result: {}, result: {},
tableData: [], tableData: [],
deleteIds: new Set(),
addIds: new Set(),
operators: [ operators: [
{ {
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger", tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
@ -81,12 +82,11 @@ export default {
}, },
props: { props: {
issuesId: String, issuesId: String,
testCaseContainIds: Set,
}, },
methods: { methods: {
handleDelete(item, index) { handleDelete(item, index) {
this.testCaseContainIds.delete(item.id);
this.tableData.splice(index, 1); this.tableData.splice(index, 1);
this.deleteIds.add(item.id);
}, },
initTableData() { initTableData() {
this.tableData = []; this.tableData = [];
@ -96,9 +96,6 @@ export default {
if (this.issuesId) { if (this.issuesId) {
this.result = this.$post('test/case/issues/list', condition, response => { this.result = this.$post('test/case/issues/list', condition, response => {
this.tableData = response.data; this.tableData = response.data;
this.tableData.forEach(item => {
this.testCaseContainIds.add(item.id);
});
this.$refs.table.reloadTable(); this.$refs.table.reloadTable();
}); });
} }
@ -108,10 +105,9 @@ export default {
}, },
handleRelate(selectRows) { handleRelate(selectRows) {
let selectData = Array.from(selectRows); let selectData = Array.from(selectRows);
selectData.forEach(item => { selectRows.forEach(i => {
if (item.id) { this.deleteIds.delete(i.id);
this.testCaseContainIds.add(item.id); this.addIds.add(i.id);
}
}); });
this.tableData.push(...selectData); this.tableData.push(...selectData);
}, },

View File

@ -107,9 +107,6 @@ export default {
selectNodeIds: [], selectNodeIds: [],
}; };
}, },
props: [
'testCaseContainIds'
],
watch: { watch: {
selectNodeIds() { selectNodeIds() {
this.initTableData(); this.initTableData();
@ -135,7 +132,6 @@ export default {
if (this.projectId) { if (this.projectId) {
this.getProjectNode(); this.getProjectNode();
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
this.condition.testCaseContainIds = Array.from(this.testCaseContainIds)
this.result = this.$post('/test/case/relate/issue/' + +this.currentPage + '/' + this.pageSize, this.condition, response => { this.result = this.$post('/test/case/relate/issue/' + +this.currentPage + '/' + this.pageSize, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;

View File

@ -24,9 +24,9 @@ export function getIssues(page) {
}); });
} }
export function getIssuesByCaseId(caseId, page) { export function getIssuesByCaseId(refType, caseId, page) {
if (caseId) { if (caseId) {
return get('issues/get/case/' + caseId, (response) => { return get('issues/get/case/' + refType + '/' + caseId, (response) => {
page.data = response.data; page.data = response.data;
buildIssues(page); buildIssues(page);
}); });