From 560a2466d2e132fe0f2cea835fe3d6c0d0a18593 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 1 Sep 2021 17:23:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=89=B9=E9=87=8F=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/APIScenarioReportController.java | 6 ++++-- .../api/controller/ApiAutomationController.java | 4 ++++ .../api/controller/ApiDefinitionController.java | 4 ++++ .../api/controller/ApiTestCaseController.java | 6 +++++- .../api/service/ApiScenarioReportService.java | 9 +++++++++ .../controller/PerformanceReportController.java | 2 ++ .../performance/service/PerformanceReportService.java | 9 +++++++++ .../metersphere/track/controller/TestCaseController.java | 4 ++++ 8 files changed, 41 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APIScenarioReportController.java b/backend/src/main/java/io/metersphere/api/controller/APIScenarioReportController.java index 17e5bae0c7..39f1794a9b 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APIScenarioReportController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APIScenarioReportController.java @@ -57,8 +57,10 @@ public class APIScenarioReportController { @PostMapping("/batch/delete") @MsAuditLog(module = "api_automation_report", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#reportRequest.ids)", msClass = ApiScenarioReportService.class) - public void deleteAPIReportBatch(@RequestBody APIReportBatchRequest reportRequest) { - apiReportService.deleteAPIReportBatch(reportRequest); + @SendNotice(taskType = NoticeConstants.TaskType.API_REPORT_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getByIds(#request.ids)", targetClass = ApiScenarioReportService.class, + mailTemplate = "api/ReportDelete", subject = "接口报告通知") + public void deleteAPIReportBatch(@RequestBody APIReportBatchRequest request) { + apiReportService.deleteAPIReportBatch(request); } @GetMapping("/get/real/{reportId}") diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index f2765655e9..60cc624b56 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -111,6 +111,8 @@ public class ApiAutomationController { @PostMapping("/deleteBatch") @MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiAutomationService.class) + @SendNotice(taskType = NoticeConstants.TaskType.API_AUTOMATION_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getScenarioCaseByIds(#ids)", targetClass = ApiAutomationService.class, + mailTemplate = "api/AutomationUpdate", subject = "接口自动化通知") public void deleteBatch(@RequestBody List ids) { apiAutomationService.deleteBatch(ids); } @@ -217,6 +219,8 @@ public class ApiAutomationController { @PostMapping("/batch/edit") @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT) @MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class) + @SendNotice(taskType = NoticeConstants.TaskType.API_AUTOMATION_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getScenarioCaseByIds(#request.ids)", targetClass = ApiAutomationService.class, + mailTemplate = "api/AutomationUpdate", subject = "接口自动化通知") public void bathEdit(@RequestBody ApiScenarioBatchRequest request) { apiAutomationService.bathEdit(request); } diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index 128bc61840..07bf5800a5 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -147,6 +147,8 @@ public class ApiDefinitionController { @PostMapping("/removeToGcByParams") @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API) @MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_GC, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class) + @SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getBLOBs(#request.ids)", targetClass = ApiDefinitionService.class, + mailTemplate = "api/DefinitionUpdate", subject = "接口定义通知") public void removeToGcByParams(@RequestBody ApiBatchRequest request) { apiDefinitionService.removeToGcByParams(request); } @@ -264,6 +266,8 @@ public class ApiDefinitionController { @PostMapping("/batch/editByParams") @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API) @MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", content = "#msClass.getLogDetails(#request)", msClass = ApiDefinitionService.class) + @SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getBLOBs(#request.ids)", targetClass = ApiDefinitionService.class, + mailTemplate = "api/DefinitionUpdate", subject = "接口定义通知") public void editByParams(@RequestBody ApiBatchRequest request) { apiDefinitionService.editApiByParam(request); } diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java index 65582e6fab..5fc824fe7f 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -103,7 +103,7 @@ public class ApiTestCaseController { @GetMapping("/deleteToGc/{id}") @MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiTestCaseService.class) - @SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_DELETE,target = "#targetClass.get(#id)", targetClass = ApiTestCaseService.class, + @SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_DELETE, target = "#targetClass.get(#id)", targetClass = ApiTestCaseService.class, mailTemplate = "api/CaseDelete", subject = "接口用例通知") public void deleteToGc(@PathVariable String id) { apiTestCaseService.deleteToGc(id); @@ -127,6 +127,8 @@ public class ApiTestCaseController { @PostMapping("/batch/editByParam") @MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiTestCaseService.class) + @SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_UPDATE, target = "#targetClass.getApiCaseByIds(#request.ids)", targetClass = ApiTestCaseService.class, + mailTemplate = "api/CaseUpdate", subject = "接口用例通知") public void editApiBathByParam(@RequestBody ApiTestBatchRequest request) { apiTestCaseService.editApiBathByParam(request); } @@ -152,6 +154,8 @@ public class ApiTestCaseController { @PostMapping("/deleteToGcByParam") @MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiTestCaseService.class) + @SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_DELETE, target = "#targetClass.getApiCaseByIds(#request.ids)", targetClass = ApiTestCaseService.class, + mailTemplate = "api/CaseDelete", subject = "接口用例通知") public void deleteToGcByParam(@RequestBody ApiTestBatchRequest request) { apiTestCaseService.deleteToGcByParam(request); } 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 d9697d5774..5e60cdd7b0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -826,6 +826,15 @@ public class ApiScenarioReportService { return null; } + public List getByIds(List ids) { + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)) { + ApiScenarioReportExample example = new ApiScenarioReportExample(); + example.createCriteria().andIdIn(ids); + return apiScenarioReportMapper.selectByExample(example); + } + return null; + } + public List countByApiScenarioId() { return extApiScenarioReportMapper.countByApiScenarioId(); } diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java index 7ba60581ee..f740a13ec0 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java @@ -137,6 +137,8 @@ public class PerformanceReportController { @PostMapping("/batch/delete") @RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_REPORT_READ_DELETE) @MsAuditLog(module = "performance_test_report", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#reportRequest.ids)", msClass = PerformanceReportService.class) + @SendNotice(taskType = NoticeConstants.TaskType.PERFORMANCE_REPORT_TASK, event = NoticeConstants.Event.DELETE, + target = "#targetClass.getReportList(#reportRequest.ids)", targetClass = PerformanceReportService.class, mailTemplate = "performance/ReportDelete", subject = "性能测试报告通知") public void deleteReportBatch(@RequestBody DeleteReportRequest reportRequest) { performanceReportService.deleteReportBatch(reportRequest); } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index 6c1093f796..42831631bf 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -409,6 +409,15 @@ public class PerformanceReportService { return null; } + public List getReportList(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return new ArrayList<>(); + } + LoadTestReportExample example = new LoadTestReportExample(); + example.createCriteria().andIdIn(ids); + return loadTestReportMapper.selectByExample(example); + } + public List getReportChart(String reportKey, String reportId) { checkReportStatus(reportId); try { diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index 7e2be0b48d..837689ca85 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -255,6 +255,8 @@ public class TestCaseController { @PostMapping("/batch/edit") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT) @MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class) + @SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, target = "#targetClass.findByBatchRequest(#request)", targetClass = TestCaseService.class, + event = NoticeConstants.Event.UPDATE, mailTemplate = "track/TestCaseUpdate", subject = "测试用例通知") public void editTestCaseBath(@RequestBody TestCaseBatchRequest request) { testCaseService.editTestCaseBath(request); } @@ -269,6 +271,8 @@ public class TestCaseController { @PostMapping("/batch/deleteToGc") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE) @MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class) + @SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, target = "#targetClass.findByBatchRequest(#request)", targetClass = TestCaseService.class, + event = NoticeConstants.Event.DELETE, mailTemplate = "track/TestCaseDelete", subject = "测试用例通知") public void deleteToGcBatch(@RequestBody TestCaseBatchRequest request) { testCaseService.deleteToGcBatch(request); }