refactor: 批量操作通知

This commit is contained in:
Captain.B 2021-09-01 17:23:09 +08:00 committed by 刘瑞斌
parent 4e7d5d2b9e
commit 560a2466d2
8 changed files with 41 additions and 3 deletions

View File

@ -57,8 +57,10 @@ public class APIScenarioReportController {
@PostMapping("/batch/delete") @PostMapping("/batch/delete")
@MsAuditLog(module = "api_automation_report", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#reportRequest.ids)", msClass = ApiScenarioReportService.class) @MsAuditLog(module = "api_automation_report", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#reportRequest.ids)", msClass = ApiScenarioReportService.class)
public void deleteAPIReportBatch(@RequestBody APIReportBatchRequest reportRequest) { @SendNotice(taskType = NoticeConstants.TaskType.API_REPORT_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getByIds(#request.ids)", targetClass = ApiScenarioReportService.class,
apiReportService.deleteAPIReportBatch(reportRequest); mailTemplate = "api/ReportDelete", subject = "接口报告通知")
public void deleteAPIReportBatch(@RequestBody APIReportBatchRequest request) {
apiReportService.deleteAPIReportBatch(request);
} }
@GetMapping("/get/real/{reportId}") @GetMapping("/get/real/{reportId}")

View File

@ -111,6 +111,8 @@ public class ApiAutomationController {
@PostMapping("/deleteBatch") @PostMapping("/deleteBatch")
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiAutomationService.class) @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<String> ids) { public void deleteBatch(@RequestBody List<String> ids) {
apiAutomationService.deleteBatch(ids); apiAutomationService.deleteBatch(ids);
} }
@ -217,6 +219,8 @@ public class ApiAutomationController {
@PostMapping("/batch/edit") @PostMapping("/batch/edit")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_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) @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) { public void bathEdit(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.bathEdit(request); apiAutomationService.bathEdit(request);
} }

View File

@ -147,6 +147,8 @@ public class ApiDefinitionController {
@PostMapping("/removeToGcByParams") @PostMapping("/removeToGcByParams")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_GC, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class) @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) { public void removeToGcByParams(@RequestBody ApiBatchRequest request) {
apiDefinitionService.removeToGcByParams(request); apiDefinitionService.removeToGcByParams(request);
} }
@ -264,6 +266,8 @@ public class ApiDefinitionController {
@PostMapping("/batch/editByParams") @PostMapping("/batch/editByParams")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API) @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) @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) { public void editByParams(@RequestBody ApiBatchRequest request) {
apiDefinitionService.editApiByParam(request); apiDefinitionService.editApiByParam(request);
} }

View File

@ -103,7 +103,7 @@ public class ApiTestCaseController {
@GetMapping("/deleteToGc/{id}") @GetMapping("/deleteToGc/{id}")
@MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiTestCaseService.class) @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 = "接口用例通知") mailTemplate = "api/CaseDelete", subject = "接口用例通知")
public void deleteToGc(@PathVariable String id) { public void deleteToGc(@PathVariable String id) {
apiTestCaseService.deleteToGc(id); apiTestCaseService.deleteToGc(id);
@ -127,6 +127,8 @@ public class ApiTestCaseController {
@PostMapping("/batch/editByParam") @PostMapping("/batch/editByParam")
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiTestCaseService.class) @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) { public void editApiBathByParam(@RequestBody ApiTestBatchRequest request) {
apiTestCaseService.editApiBathByParam(request); apiTestCaseService.editApiBathByParam(request);
} }
@ -152,6 +154,8 @@ public class ApiTestCaseController {
@PostMapping("/deleteToGcByParam") @PostMapping("/deleteToGcByParam")
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiTestCaseService.class) @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) { public void deleteToGcByParam(@RequestBody ApiTestBatchRequest request) {
apiTestCaseService.deleteToGcByParam(request); apiTestCaseService.deleteToGcByParam(request);
} }

View File

@ -826,6 +826,15 @@ public class ApiScenarioReportService {
return null; return null;
} }
public List<ApiScenarioReport> getByIds(List<String> 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<ApiReportCountDTO> countByApiScenarioId() { public List<ApiReportCountDTO> countByApiScenarioId() {
return extApiScenarioReportMapper.countByApiScenarioId(); return extApiScenarioReportMapper.countByApiScenarioId();
} }

View File

@ -137,6 +137,8 @@ public class PerformanceReportController {
@PostMapping("/batch/delete") @PostMapping("/batch/delete")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_REPORT_READ_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) @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) { public void deleteReportBatch(@RequestBody DeleteReportRequest reportRequest) {
performanceReportService.deleteReportBatch(reportRequest); performanceReportService.deleteReportBatch(reportRequest);
} }

View File

@ -409,6 +409,15 @@ public class PerformanceReportService {
return null; return null;
} }
public List<LoadTestReport> getReportList(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
LoadTestReportExample example = new LoadTestReportExample();
example.createCriteria().andIdIn(ids);
return loadTestReportMapper.selectByExample(example);
}
public List<ChartsData> getReportChart(String reportKey, String reportId) { public List<ChartsData> getReportChart(String reportKey, String reportId) {
checkReportStatus(reportId); checkReportStatus(reportId);
try { try {

View File

@ -255,6 +255,8 @@ public class TestCaseController {
@PostMapping("/batch/edit") @PostMapping("/batch/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_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) @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) { public void editTestCaseBath(@RequestBody TestCaseBatchRequest request) {
testCaseService.editTestCaseBath(request); testCaseService.editTestCaseBath(request);
} }
@ -269,6 +271,8 @@ public class TestCaseController {
@PostMapping("/batch/deleteToGc") @PostMapping("/batch/deleteToGc")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class) @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) { public void deleteToGcBatch(@RequestBody TestCaseBatchRequest request) {
testCaseService.deleteToGcBatch(request); testCaseService.deleteToGcBatch(request);
} }