perf(接口测试): 优化接口测试回收站批量删除方法

This commit is contained in:
guoyuqi 2022-10-15 21:43:46 +08:00 committed by fit2-zhao
parent 26573638f2
commit 6b6cf1a86a
1 changed files with 19 additions and 16 deletions

View File

@ -1961,23 +1961,26 @@ public class ApiDefinitionService {
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return; return;
} }
this.deleteApiByIds(ids);
}
ids.forEach(id -> { private void deleteApiByIds(List<String> ids) {
// 把所有版本的api移到回收站 ApiDefinitionExample example = new ApiDefinitionExample();
ApiDefinitionWithBLOBs api = apiDefinitionMapper.selectByPrimaryKey(id); example.createCriteria().andIdIn(ids);
if (api == null) { List<ApiDefinition> apiDefinitionList = apiDefinitionMapper.selectByExample(example);
return; if (CollectionUtils.isEmpty(apiDefinitionList)){
} return;
ApiDefinitionExample example = new ApiDefinitionExample(); }
example.createCriteria().andRefIdEqualTo(api.getRefId()); List<String> refIds = apiDefinitionList.stream().map(ApiDefinition::getRefId).collect(Collectors.toList());
List<ApiDefinition> apiDefinitions = apiDefinitionMapper.selectByExample(example); example = new ApiDefinitionExample();
List<String> apiIds = apiDefinitions.stream().map(ApiDefinition::getId).collect(Collectors.toList()); example.createCriteria().andRefIdIn(refIds);
//删除ApiApiCase中resourceID被删除了的执行记录 List<ApiDefinition> apiDefinitions = apiDefinitionMapper.selectByExample(example);
apiExecutionInfoService.deleteByApiIdList(apiIds); List<String> apiIds = apiDefinitions.stream().map(ApiDefinition::getId).collect(Collectors.toList());
apiCaseExecutionInfoService.deleteByApiDefeinitionIdList(apiIds); //删除ApiApiCase中resourceID被删除了的执行记录
apiTestCaseService.deleteBatchByDefinitionId(apiIds); apiExecutionInfoService.deleteByApiIdList(apiIds);
apiDefinitionMapper.deleteByExample(example); apiCaseExecutionInfoService.deleteByApiDefeinitionIdList(apiIds);
}); apiTestCaseService.deleteBatchByDefinitionId(apiIds);
apiDefinitionMapper.deleteByExample(example);
} }
public ApiDefinitionExample getBatchExample(ApiBatchRequest request) { public ApiDefinitionExample getBatchExample(ApiBatchRequest request) {