From 5779930f56eeb11f232cf300fafa0c34da454729 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 10 Aug 2022 14:27:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=85=A8=E9=80=89=E5=88=A0=E9=99=A4=E6=97=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=89=80=E6=9C=89=E7=9A=84=E5=9C=BA=E6=99=AF=E5=92=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8A=A5=E5=91=8A=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015725 --user=宋天阳 【接口测试】接口测试报告-全选接口报告-批量删除,会把场景报告也都删掉,全选场景报告也是 https://www.tapd.cn/55049933/s/1221535 --- .../api/dto/QueryAPIReportRequest.java | 5 ++++ .../api/service/ApiScenarioReportService.java | 28 +++++++++++++------ .../mapper/ext/ExtApiScenarioReportMapper.xml | 13 +++++---- .../constants/ReportTypeConstants.java | 8 ++++++ .../api/automation/report/ApiReportList.vue | 1 + 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java b/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java index 0b4bce3dcf..700a38a96c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java @@ -23,5 +23,10 @@ public class QueryAPIReportRequest { private Map> filters; private Map combine; + /** + * 查询哪种用例的报告 SCENARIO/API + */ + private String caseType; + private String limit; } 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 7dd78c0f67..3591e4e4f2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -182,7 +182,12 @@ public class ApiScenarioReportService { public List idList(QueryAPIReportRequest request) { request = this.initRequest(request); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); - return extApiScenarioReportMapper.idList(request); + //检查必填参数caseType + if (StringUtils.equalsAny(request.getCaseType(), ReportTypeConstants.API.name(), ReportTypeConstants.SCENARIO.name())) { + return extApiScenarioReportMapper.idList(request); + } else { + return new ArrayList<>(0); + } } private void checkNameExist(APIScenarioReportResult request) { @@ -271,7 +276,7 @@ public class ApiScenarioReportService { } public ApiScenarioReport updatePlanCase(ResultDTO dto) { - String status = getStatus(dto); + String status = getStatus(dto); ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode()); TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(dto.getTestId()); if (testPlanApiScenario != null) { @@ -648,13 +653,19 @@ public class ApiScenarioReportService { } public void deleteAPIReportBatch(APIReportBatchRequest reportRequest) { - List ids = getIdsByDeleteBatchRequest(reportRequest); - ids = batchDeleteReportResource(reportRequest, ids, true); + if (reportRequest.getIsUi()) { + //ui报告对应的用例类型也是scenario + reportRequest.setCaseType(ReportTypeConstants.SCENARIO.name()); + } + if (StringUtils.isNotBlank(reportRequest.getCaseType())) { + List ids = getIdsByDeleteBatchRequest(reportRequest); + ids = batchDeleteReportResource(reportRequest, ids, true); - //处理最后剩余的数据 - if (!ids.isEmpty()) { - deleteScenarioReportByIds(ids); - deleteApiDefinitionResultByIds(ids); + //处理报告关联数据 + if (!ids.isEmpty()) { + deleteScenarioReportByIds(ids); + deleteApiDefinitionResultByIds(ids); + } } } @@ -873,7 +884,6 @@ public class ApiScenarioReportService { long errorReportResultSize = dto.getRequestResults().stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ExecuteResult.ERROR_REPORT_RESULT.toString())).count(); - String status = dto.getRequestResults().isEmpty() ? ExecuteResult.UN_EXECUTE.toString() : ScenarioStatus.Success.name(); if (errorSize > 0) { status = ScenarioStatus.Error.name(); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index 1a6789880b..9550a65561 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -241,6 +241,7 @@