fix(接口测试): 补充报告级联删除方法

This commit is contained in:
fit2-zhao 2022-01-13 09:30:42 +08:00 committed by fit2-zhao
parent 7b2daddc39
commit de55237091
1 changed files with 28 additions and 0 deletions

View File

@ -80,6 +80,8 @@ public class ApiScenarioReportService {
@Resource
private ApiScenarioReportStructureService apiScenarioReportStructureService;
@Resource
private ApiScenarioReportStructureMapper apiScenarioReportStructureMapper;
@Resource
private MsResultService resultService;
public void saveResult(List<RequestResult> requestResults, ResultDTO dto) {
@ -459,6 +461,14 @@ public class ApiScenarioReportService {
public void delete(DeleteAPIReportRequest request) {
apiScenarioReportDetailMapper.deleteByPrimaryKey(request.getId());
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
example.createCriteria().andReportIdEqualTo(request.getId());
apiScenarioReportResultMapper.deleteByExample(example);
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
structureExample.createCriteria().andReportIdEqualTo(request.getId());
apiScenarioReportStructureMapper.deleteByExample(structureExample);
// 补充逻辑如果是集成报告则把零时报告全部删除
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(request.getId());
if (report != null && StringUtils.isNotEmpty(report.getScenarioId())) {
@ -528,6 +538,15 @@ public class ApiScenarioReportService {
ApiScenarioReportExample apiTestReportExample = new ApiScenarioReportExample();
apiTestReportExample.createCriteria().andIdIn(handleIdList);
apiScenarioReportMapper.deleteByExample(apiTestReportExample);
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
reportResultExample.createCriteria().andReportIdIn(handleIdList);
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
structureExample.createCriteria().andReportIdIn(handleIdList);
apiScenarioReportStructureMapper.deleteByExample(structureExample);
//转存剩余的数据
ids = otherIdList;
}
@ -540,6 +559,15 @@ public class ApiScenarioReportService {
ApiScenarioReportExample apiTestReportExample = new ApiScenarioReportExample();
apiTestReportExample.createCriteria().andIdIn(ids);
apiScenarioReportMapper.deleteByExample(apiTestReportExample);
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
reportResultExample.createCriteria().andReportIdIn(ids);
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
structureExample.createCriteria().andReportIdIn(ids);
apiScenarioReportStructureMapper.deleteByExample(structureExample);
}
}