From de552370916002b2a0ec086eca8f39685831352b Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 13 Jan 2022 09:30:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8A=A5=E5=91=8A=E7=BA=A7=E8=81=94=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiScenarioReportService.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 65916f14d1..e8cc71bf3e 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -80,6 +80,8 @@ public class ApiScenarioReportService { @Resource private ApiScenarioReportStructureService apiScenarioReportStructureService; @Resource + private ApiScenarioReportStructureMapper apiScenarioReportStructureMapper; + @Resource private MsResultService resultService; public void saveResult(List 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); + } }