fix(测试计划): 取消关联用例未清理关联缺陷数据

This commit is contained in:
song-cc-rock 2024-09-03 15:48:17 +08:00 committed by Craftsman
parent cabc48cbbc
commit a98b432471
7 changed files with 16 additions and 12 deletions

View File

@ -64,7 +64,7 @@
select brc.id as id, b.num as num, b.title as title, b.status as status, brc.test_plan_case_id as planCaseRefId
from bug_relation_case brc
join bug b on brc.bug_id = b.id
where brc.test_plan_case_id in
where b.deleted = false and brc.test_plan_case_id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>

View File

@ -9,14 +9,15 @@
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiCase">
select tpac.id as testPlanApiCaseId, atc.id as apiCaseId, atc.num as apiCaseNum, atc.name as apiCaseName, atc.priority as apiCasePriority,
tpac.test_plan_collection_id testPlanCollectionId, tpac.environment_id as environmentId, count(brc.id) as apiCaseBugCount,
tpac.test_plan_collection_id testPlanCollectionId, tpac.environment_id as environmentId, count(b.id) as apiCaseBugCount,
if(ad.module_id = 'root','未规划用例', ad.module_id) as apiCaseModule, tpac.execute_user as apiCaseExecuteUser,
ifnull(tpac.last_exec_result, 'PENDING') as apiCaseExecuteResult, tpac.last_exec_report_id apiCaseExecuteReportId, tpac.pos as pos
from test_plan_api_case tpac join api_test_case atc on atc.id = tpac.api_case_id
left join api_definition ad on atc.api_definition_id = ad.id
left join api_definition_module adm on ad.module_id = adm.id
left join bug_relation_case brc on brc.test_plan_case_id = tpac.id
where tpac.test_plan_id = #{id} and atc.deleted = false
left join bug b on b.id = brc.bug_id
where tpac.test_plan_id = #{id} and atc.deleted = false and b.deleted = false
group by tpac.id
</select>

View File

@ -9,13 +9,14 @@
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiScenario">
select tpas.id as testPlanApiScenarioId, aso.id as apiScenarioId, aso.num as apiScenarioNum, aso.name as apiScenarioName, aso.priority as apiScenarioPriority,
tpas.test_plan_collection_id testPlanCollectionId, tpas.grouped as grouped, tpas.environment_id environmentId, count(brc.id) as apiScenarioBugCount,
tpas.test_plan_collection_id testPlanCollectionId, tpas.grouped as grouped, tpas.environment_id environmentId, count(b.id) as apiScenarioBugCount,
if(aso.module_id = 'root','未规划用例', aso.module_id) as apiScenarioModule, tpas.execute_user as apiScenarioExecuteUser,
ifnull(tpas.last_exec_result, 'PENDING') as apiScenarioExecuteResult, tpas.last_exec_report_id apiScenarioExecuteReportId, tpas.pos as pos
from test_plan_api_scenario tpas join api_scenario aso on aso.id = tpas.api_scenario_id
left join api_scenario_module asm on aso.module_id = asm.id
left join bug_relation_case brc on brc.test_plan_case_id = tpas.id
where tpas.test_plan_id = #{id} and aso.deleted = false
left join bug b on b.id = brc.bug_id
where tpas.test_plan_id = #{id} and aso.deleted = false and b.deleted = false
group by tpas.id
</select>

View File

@ -6,7 +6,7 @@
select distinct brc.bug_id as bugId, b.num as bugNum, b.title as bugTitle, b.status bugStatus,
b.handle_user bugHandleUser, count(brc.id) bugCaseCount
from bug_relation_case brc join bug b on brc.bug_id = b.id
where brc.test_plan_id = #{id}
where brc.test_plan_id = #{id} and b.deleted = false
group by brc.bug_id
</select>

View File

@ -5,11 +5,12 @@
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportFunctionCase">
select tpfc.id as testPlanFunctionCaseId, fc.id as functionCaseId, fc.num as functionCaseNum, fc.name as functionCaseName, tpfc.test_plan_collection_id testPlanCollectionId,
if(fc.module_id = 'root','未规划用例', fc.module_id) as functionCaseModule, tpfc.execute_user as functionCaseExecuteUser,
count(brc.id) as functionCaseBugCount, ifnull(tpfc.last_exec_result, 'PENDING') as functionCaseExecuteResult, tpfc.pos as pos
count(b.id) as functionCaseBugCount, ifnull(tpfc.last_exec_result, 'PENDING') as functionCaseExecuteResult, tpfc.pos as pos
from test_plan_functional_case tpfc join functional_case fc on tpfc.functional_case_id = fc.id
left join functional_case_module fcm on fcm.id = fc.module_id
left join bug_relation_case brc on brc.test_plan_case_id = tpfc.id
where tpfc.test_plan_id = #{id} and fc.deleted = false
left join bug b on b.id = brc.bug_id
where tpfc.test_plan_id = #{id} and fc.deleted = false and b.deleted = false
group by tpfc.id
</select>

View File

@ -219,10 +219,6 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
TestPlanFunctionalCaseExample testPlanFunctionalCaseExample = new TestPlanFunctionalCaseExample();
testPlanFunctionalCaseExample.createCriteria().andIdIn(associationParam.getResourceIdList());
testPlanFunctionalCaseMapper.deleteByExample(testPlanFunctionalCaseExample);
// 取消关联用例需同步删除计划-用例缺陷关系表
BugRelationCaseExample example = new BugRelationCaseExample();
example.createCriteria().andTestPlanCaseIdIn(associationParam.getResourceIdList());
bugRelationCaseMapper.deleteByExample(example);
extTestPlanCaseExecuteHistoryMapper.updateDeleted(associationParam.getResourceIdList(), true);
}

View File

@ -2,6 +2,7 @@ package io.metersphere.plan.service;
import io.metersphere.bug.domain.Bug;
import io.metersphere.bug.domain.BugRelationCase;
import io.metersphere.bug.domain.BugRelationCaseExample;
import io.metersphere.bug.mapper.BugMapper;
import io.metersphere.bug.mapper.BugRelationCaseMapper;
import io.metersphere.bug.service.BugStatusService;
@ -87,6 +88,10 @@ public abstract class TestPlanResourceService extends TestPlanSortService {
if (CollectionUtils.isNotEmpty(associationIdList)) {
TestPlanResourceAssociationParam associationParam = new TestPlanResourceAssociationParam(associationIdList, testPlan.getProjectId(), testPlan.getId(), testPlan.getNum(), logInsertModule.getOperator());
disassociate.accept(associationParam);
// 取消关联用例需同步删除计划-用例缺陷关系表
BugRelationCaseExample example = new BugRelationCaseExample();
example.createCriteria().andTestPlanCaseIdIn(associationIdList);
bugRelationCaseMapper.deleteByExample(example);
response.setAssociationCount(associationIdList.size());
}
return response;