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)) { if (CollectionUtils.isEmpty(apiTestCaseRecords)) {
throw new MSException(Translator.get("api_case_report_not_exist")); throw new MSException(Translator.get("api_case_report_not_exist"));
} }
ApiReportStepDTO apiReportStepDTO = new ApiReportStepDTO(); ApiReportDetailExample apiReportDetailExample = new ApiReportDetailExample();
BeanUtils.copyBean(apiReportStepDTO, apiReportDTO); apiReportDetailExample.createCriteria().andReportIdEqualTo(id).andStepIdEqualTo(apiTestCaseRecords.getFirst().getApiTestCaseId());
apiReportStepDTO.setStepId(apiTestCaseRecords.getFirst().getApiTestCaseId()); List<ApiReportDetail> apiReportDetails = apiReportDetailMapper.selectByExampleWithBLOBs(apiReportDetailExample);
apiReportStepDTO.setReportId(id); if (CollectionUtils.isNotEmpty(apiReportDetails)) {
apiReportStepDTO.setSort(1L); ApiReportStepDTO apiReportStepDTO = new ApiReportStepDTO();
apiReportStepDTO.setStepType(ApiExecuteResourceType.API_CASE.name()); BeanUtils.copyBean(apiReportStepDTO, apiReportDetails.getFirst());
List<ApiReportStepDTO> apiReportSteps = new ArrayList<>(); apiReportStepDTO.setStepId(apiTestCaseRecords.getFirst().getApiTestCaseId());
apiReportSteps.add(apiReportStepDTO); apiReportStepDTO.setReportId(id);
apiReportDTO.setChildren(apiReportSteps); 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; return apiReportDTO;
} }