fix: 取消关联项目同取消关联的接口用例
This commit is contained in:
parent
1fede9b66b
commit
45d0a6515e
|
@ -15,4 +15,6 @@ public interface ExtTestPlanApiCaseMapper {
|
||||||
List<String> getExecResultByPlanId(String planId);
|
List<String> getExecResultByPlanId(String planId);
|
||||||
|
|
||||||
List<String> getIdsByPlanId(String planId);
|
List<String> getIdsByPlanId(String planId);
|
||||||
|
|
||||||
|
List<String> getNotRelevanceCaseIds(@Param("planId")String planId, @Param("relevanceProjectIds")List<String> relevanceProjectIds);
|
||||||
}
|
}
|
|
@ -98,9 +98,23 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getIdsByPlanId" resultType="java.lang.String">
|
<select id="getIdsByPlanId" resultType="java.lang.String">
|
||||||
select id from
|
select id
|
||||||
from test_plan_api_case
|
from test_plan_api_case
|
||||||
where id = #{planId}
|
where id = #{planId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
||||||
|
select t.id
|
||||||
|
from test_plan_api_case t
|
||||||
|
inner join api_test_case c
|
||||||
|
on c.id = t.api_case_id
|
||||||
|
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||||
|
and c.project_id not in
|
||||||
|
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||||
|
#{projectId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
where t.test_plan_id = #{planId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -21,4 +21,6 @@ public interface ExtTestPlanScenarioCaseMapper {
|
||||||
List<String> getExecResultByPlanId(String planId);
|
List<String> getExecResultByPlanId(String planId);
|
||||||
|
|
||||||
List<String> getIdsByPlanId(String planId);
|
List<String> getIdsByPlanId(String planId);
|
||||||
|
|
||||||
|
List<String> getNotRelevanceCaseIds(String planId, List<String> relevanceProjectIds);
|
||||||
}
|
}
|
|
@ -92,4 +92,18 @@
|
||||||
where test_plan_id = #{planId}
|
where test_plan_id = #{planId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
||||||
|
select t.id
|
||||||
|
from test_plan_api_scenario t
|
||||||
|
inner join api_scenario c
|
||||||
|
on c.id = t.api_scenario_id
|
||||||
|
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||||
|
and c.project_id not in
|
||||||
|
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||||
|
#{projectId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
where t.test_plan_id = #{planId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -77,6 +77,9 @@ public class TestPlanApiCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteApiCaseBath(TestPlanApiCaseBatchRequest request) {
|
public void deleteApiCaseBath(TestPlanApiCaseBatchRequest request) {
|
||||||
|
if (CollectionUtils.isEmpty(request.getIds())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
apiDefinitionExecResultService.deleteByResourceIds(request.getIds());
|
apiDefinitionExecResultService.deleteByResourceIds(request.getIds());
|
||||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
|
@ -97,4 +100,11 @@ public class TestPlanApiCaseService {
|
||||||
apiCase.setStatus(status);
|
apiCase.setStatus(status);
|
||||||
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);
|
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByRelevanceProjectIds(String planId, List<String> relevanceProjectIds) {
|
||||||
|
TestPlanApiCaseBatchRequest request = new TestPlanApiCaseBatchRequest();
|
||||||
|
request.setPlanId(planId);
|
||||||
|
request.setIds(extTestPlanApiCaseMapper.getNotRelevanceCaseIds(planId, relevanceProjectIds));
|
||||||
|
deleteApiCaseBath(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,9 @@ public class TestPlanScenarioCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteApiCaseBath(TestPlanApiCaseBatchRequest request) {
|
public void deleteApiCaseBath(TestPlanApiCaseBatchRequest request) {
|
||||||
|
if (CollectionUtils.isEmpty(request.getIds())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andIdIn(request.getIds());
|
.andIdIn(request.getIds());
|
||||||
|
@ -110,4 +113,11 @@ public class TestPlanScenarioCaseService {
|
||||||
request.setIds(ids);
|
request.setIds(ids);
|
||||||
deleteApiCaseBath(request);
|
deleteApiCaseBath(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteByRelevanceProjectIds(String planId, List<String> relevanceProjectIds) {
|
||||||
|
TestPlanApiCaseBatchRequest request = new TestPlanApiCaseBatchRequest();
|
||||||
|
request.setIds(extTestPlanScenarioCaseMapper.getNotRelevanceCaseIds(planId, relevanceProjectIds));
|
||||||
|
request.setPlanId(planId);
|
||||||
|
deleteApiCaseBath(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||||
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
|
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
|
||||||
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.ExtProjectMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||||
|
@ -27,7 +26,6 @@ import io.metersphere.notice.service.NoticeSendService;
|
||||||
import io.metersphere.service.SystemParameterService;
|
import io.metersphere.service.SystemParameterService;
|
||||||
import io.metersphere.track.Factory.ReportComponentFactory;
|
import io.metersphere.track.Factory.ReportComponentFactory;
|
||||||
import io.metersphere.track.domain.ReportComponent;
|
import io.metersphere.track.domain.ReportComponent;
|
||||||
|
|
||||||
import io.metersphere.track.dto.TestCaseReportMetricDTO;
|
import io.metersphere.track.dto.TestCaseReportMetricDTO;
|
||||||
import io.metersphere.track.dto.TestPlanCaseDTO;
|
import io.metersphere.track.dto.TestPlanCaseDTO;
|
||||||
import io.metersphere.track.dto.TestPlanDTO;
|
import io.metersphere.track.dto.TestPlanDTO;
|
||||||
|
@ -69,8 +67,6 @@ public class TestPlanService {
|
||||||
@Resource
|
@Resource
|
||||||
TestPlanTestCaseService testPlanTestCaseService;
|
TestPlanTestCaseService testPlanTestCaseService;
|
||||||
@Resource
|
@Resource
|
||||||
ExtProjectMapper extProjectMapper;
|
|
||||||
@Resource
|
|
||||||
TestCaseReportMapper testCaseReportMapper;
|
TestCaseReportMapper testCaseReportMapper;
|
||||||
@Resource
|
@Resource
|
||||||
TestPlanProjectMapper testPlanProjectMapper;
|
TestPlanProjectMapper testPlanProjectMapper;
|
||||||
|
@ -229,6 +225,14 @@ public class TestPlanService {
|
||||||
criteria.andCaseIdNotIn(caseIds);
|
criteria.andCaseIdNotIn(caseIds);
|
||||||
}
|
}
|
||||||
testPlanTestCaseMapper.deleteByExample(testPlanTestCaseExample);
|
testPlanTestCaseMapper.deleteByExample(testPlanTestCaseExample);
|
||||||
|
|
||||||
|
List<String> relevanceProjectIds = new ArrayList<>();
|
||||||
|
relevanceProjectIds.add(testPlan.getProjectId());
|
||||||
|
if (!CollectionUtils.isEmpty(testPlan.getProjectIds())) {
|
||||||
|
relevanceProjectIds.addAll(testPlan.getProjectIds());
|
||||||
|
}
|
||||||
|
testPlanApiCaseService.deleteByRelevanceProjectIds(testPlan.getId(), relevanceProjectIds);
|
||||||
|
testPlanScenarioCaseService.deleteByRelevanceProjectIds(testPlan.getId(), relevanceProjectIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue