refactor(性能测试): 批量删除时记录日志

This commit is contained in:
shiziyuan9527 2022-03-14 10:51:53 +08:00 committed by shiziyuan9527
parent 136f968a8f
commit 6db2c81ee6
2 changed files with 17 additions and 0 deletions

View File

@ -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);
}

View File

@ -770,6 +770,21 @@ public class PerformanceTestService {
return null;
}
public String deleteBatchLog(DeletePerformanceRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> getLoadTestIds(request.getProjectId()));
List<String> loadTestIds = request.getIds();
LoadTestExample example = new LoadTestExample();
example.createCriteria().andIdIn(loadTestIds);
List<LoadTest> tests = loadTestMapper.selectByExample(example);
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(tests)) {
List<String> 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());
}
}