refactor(接口测试): 优化接口报告获取逻辑

This commit is contained in:
wxg0103 2024-03-25 19:23:56 +08:00 committed by Craftsman
parent d8e7b920bc
commit bee35b522b
1 changed files with 15 additions and 9 deletions

View File

@ -209,15 +209,21 @@ public class ApiReportService {
if (CollectionUtils.isEmpty(apiTestCaseRecords)) {
throw new MSException(Translator.get("api_case_report_not_exist"));
}
ApiReportStepDTO apiReportStepDTO = new ApiReportStepDTO();
BeanUtils.copyBean(apiReportStepDTO, apiReportDTO);
apiReportStepDTO.setStepId(apiTestCaseRecords.getFirst().getApiTestCaseId());
apiReportStepDTO.setReportId(id);
apiReportStepDTO.setSort(1L);
apiReportStepDTO.setStepType(ApiExecuteResourceType.API_CASE.name());
List<ApiReportStepDTO> apiReportSteps = new ArrayList<>();
apiReportSteps.add(apiReportStepDTO);
apiReportDTO.setChildren(apiReportSteps);
ApiReportDetailExample apiReportDetailExample = new ApiReportDetailExample();
apiReportDetailExample.createCriteria().andReportIdEqualTo(id).andStepIdEqualTo(apiTestCaseRecords.getFirst().getApiTestCaseId());
List<ApiReportDetail> apiReportDetails = apiReportDetailMapper.selectByExampleWithBLOBs(apiReportDetailExample);
if (CollectionUtils.isNotEmpty(apiReportDetails)) {
ApiReportStepDTO apiReportStepDTO = new ApiReportStepDTO();
BeanUtils.copyBean(apiReportStepDTO, apiReportDetails.getFirst());
apiReportStepDTO.setStepId(apiTestCaseRecords.getFirst().getApiTestCaseId());
apiReportStepDTO.setReportId(id);
apiReportStepDTO.setSort(1L);
apiReportStepDTO.setName(apiReport.getName());
apiReportStepDTO.setStepType(ApiExecuteResourceType.API_CASE.name());
List<ApiReportStepDTO> apiReportSteps = new ArrayList<>();
apiReportSteps.add(apiReportStepDTO);
apiReportDTO.setChildren(apiReportSteps);
}
return apiReportDTO;
}