From 6db2c81ee61ad4c9af05dcf88a9de332e87dd128 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 14 Mar 2022 10:51:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E6=97=B6=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PerformanceTestController.java | 1 + .../service/PerformanceTestService.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index c95576c836..21bcfff96c 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -168,6 +168,7 @@ public class PerformanceTestController { @PostMapping("/delete/batch") @CacheNode + @MsAuditLog(module = OperLogModule.PERFORMANCE_TEST, type = OperLogConstants.DELETE, beforeEvent = "#msClass.deleteBatchLog(#request)", msClass = PerformanceTestService.class) public void deleteBatch(@RequestBody DeletePerformanceRequest request) { performanceTestService.deleteBatch(request); } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index baac69ac4d..fea3b0875f 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -770,6 +770,21 @@ public class PerformanceTestService { return null; } + public String deleteBatchLog(DeletePerformanceRequest request) { + ServiceUtils.getSelectAllIds(request, request.getCondition(), + (query) -> getLoadTestIds(request.getProjectId())); + List loadTestIds = request.getIds(); + LoadTestExample example = new LoadTestExample(); + example.createCriteria().andIdIn(loadTestIds); + List tests = loadTestMapper.selectByExample(example); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(tests)) { + List names = tests.stream().map(LoadTest::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(loadTestIds), tests.get(0).getProjectId(), String.join(",", names), tests.get(0).getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + /** * 一键更新由接口用例或者场景用例转换的性能测试 * @@ -1063,4 +1078,5 @@ public class PerformanceTestService { return loadTests.stream().map(LoadTest::getId).collect(Collectors.toList()); } + }