refactor(测试计划): 测试计划报告用例列表耗时字段增加排序
This commit is contained in:
parent
31f8172473
commit
0e2894eea6
|
@ -187,8 +187,10 @@ public class TestPlanReportController {
|
|||
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
|
||||
public Pager<List<ReportDetailCasePageDTO>> pageFunctionalCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
|
||||
request.setDetailReportIds(testPlanReportService.getActualReportIds(request.getReportId()));
|
||||
String sort = request.getSortString();
|
||||
sort = StringUtils.replace(sort, "request_time", "request_duration");
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprfc.pos desc");
|
||||
StringUtils.isNotBlank(sort) ? sort : "tprfc.pos desc");
|
||||
if (!request.getStartPager()) {
|
||||
// 不分页仅排序 {测试集升序, 用例位次倒序}
|
||||
page.setPageSize(0);
|
||||
|
@ -196,7 +198,7 @@ public class TestPlanReportController {
|
|||
page.setOrderBy("tpc.pos, tpc.name, tprfc.pos desc");
|
||||
page.setOrderByOnly(true);
|
||||
}
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.FUNCTIONAL));
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, null, AssociateCaseType.FUNCTIONAL));
|
||||
}
|
||||
|
||||
@GetMapping("/detail/functional/case/step/{reportId}")
|
||||
|
@ -212,8 +214,10 @@ public class TestPlanReportController {
|
|||
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
|
||||
public Pager<List<ReportDetailCasePageDTO>> pageApiCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
|
||||
request.setDetailReportIds(testPlanReportService.getActualReportIds(request.getReportId()));
|
||||
String sort = request.getSortString();
|
||||
sort = StringUtils.replace(sort, "request_time", "request_duration");
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprac.pos desc");
|
||||
StringUtils.isNotBlank(sort) ? sort : "tprac.pos desc");
|
||||
if (!request.getStartPager()) {
|
||||
// 不分页仅排序 {测试集升序, 用例位次倒序}
|
||||
page.setPageSize(0);
|
||||
|
@ -221,7 +225,7 @@ public class TestPlanReportController {
|
|||
page.setOrderBy("tpc.pos, tpc.name, tprac.pos desc");
|
||||
page.setOrderByOnly(true);
|
||||
}
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.API_CASE));
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, null, AssociateCaseType.API_CASE));
|
||||
}
|
||||
|
||||
@PostMapping("/detail/scenario/case/page")
|
||||
|
@ -230,8 +234,10 @@ public class TestPlanReportController {
|
|||
@CheckOwner(resourceId = "#request.getReportId()", resourceType = "test_plan_report")
|
||||
public Pager<List<ReportDetailCasePageDTO>> pageScenarioCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
|
||||
request.setDetailReportIds(testPlanReportService.getActualReportIds(request.getReportId()));
|
||||
String sort = request.getSortString();
|
||||
sort = StringUtils.replace(sort, "request_time", "request_duration");
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tpras.pos desc");
|
||||
StringUtils.isNotBlank(sort) ? sort : "tpras.pos desc");
|
||||
if (!request.getStartPager()) {
|
||||
// 不分页仅排序 {测试集升序, 用例位次倒序}
|
||||
page.setPageSize(0);
|
||||
|
@ -239,7 +245,7 @@ public class TestPlanReportController {
|
|||
page.setOrderBy("tpc.pos, tpc.name, tpras.pos desc");
|
||||
page.setOrderByOnly(true);
|
||||
}
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.API_SCENARIO));
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, null, AssociateCaseType.API_SCENARIO));
|
||||
}
|
||||
|
||||
@PostMapping("/detail/plan/report/page")
|
||||
|
|
|
@ -108,9 +108,11 @@ public class TestPlanReportShareController {
|
|||
request.setDetailReportIds(testPlanReportService.getActualReportIds(request.getReportId()));
|
||||
ShareInfo shareInfo = testPlanReportShareService.checkResource(request.getShareId());
|
||||
testPlanReportShareService.validateExpired(shareInfo);
|
||||
String sort = request.getSortString();
|
||||
sort = StringUtils.replace(sort, "request_time", "request_duration");
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprfc.pos desc");
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.FUNCTIONAL));
|
||||
StringUtils.isNotBlank(sort) ? sort : "tprfc.pos desc");
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, null, AssociateCaseType.FUNCTIONAL));
|
||||
}
|
||||
|
||||
@PostMapping("/detail/api/case/page")
|
||||
|
@ -119,9 +121,11 @@ public class TestPlanReportShareController {
|
|||
request.setDetailReportIds(testPlanReportService.getActualReportIds(request.getReportId()));
|
||||
ShareInfo shareInfo = testPlanReportShareService.checkResource(request.getShareId());
|
||||
testPlanReportShareService.validateExpired(shareInfo);
|
||||
String sort = request.getSortString();
|
||||
sort = StringUtils.replace(sort, "request_time", "request_duration");
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprac.pos desc");
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.API_CASE));
|
||||
StringUtils.isNotBlank(sort) ? sort : "tprac.pos desc");
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, null, AssociateCaseType.API_CASE));
|
||||
}
|
||||
|
||||
@PostMapping("/detail/scenario/case/page")
|
||||
|
@ -130,9 +134,11 @@ public class TestPlanReportShareController {
|
|||
request.setDetailReportIds(testPlanReportService.getActualReportIds(request.getReportId()));
|
||||
ShareInfo shareInfo = testPlanReportShareService.checkResource(request.getShareId());
|
||||
testPlanReportShareService.validateExpired(shareInfo);
|
||||
String sort = request.getSortString();
|
||||
sort = StringUtils.replace(sort, "request_time", "request_duration");
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tpras.pos desc");
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.API_SCENARIO));
|
||||
StringUtils.isNotBlank(sort) ? sort : "tpras.pos desc");
|
||||
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, null, AssociateCaseType.API_SCENARIO));
|
||||
}
|
||||
|
||||
@PostMapping("/detail/plan/report/page")
|
||||
|
|
|
@ -927,15 +927,13 @@ public class TestPlanReportService {
|
|||
* @param request 请求参数
|
||||
* @return 用例分页数据
|
||||
*/
|
||||
public List<ReportDetailCasePageDTO> listReportDetailCases(TestPlanReportDetailPageRequest request, String caseType) {
|
||||
public List<ReportDetailCasePageDTO> listReportDetailCases(TestPlanReportDetailPageRequest request, String sort, String caseType) {
|
||||
List<ReportDetailCasePageDTO> detailCases;
|
||||
switch (caseType) {
|
||||
case AssociateCaseType.FUNCTIONAL ->
|
||||
detailCases = extTestPlanReportFunctionalCaseMapper.list(request, request.getSortString());
|
||||
case AssociateCaseType.API_CASE ->
|
||||
detailCases = extTestPlanReportApiCaseMapper.list(request, request.getSortString());
|
||||
case AssociateCaseType.API_SCENARIO ->
|
||||
detailCases = extTestPlanReportApiScenarioMapper.list(request, request.getSortString());
|
||||
detailCases = extTestPlanReportFunctionalCaseMapper.list(request, sort);
|
||||
case AssociateCaseType.API_CASE -> detailCases = extTestPlanReportApiCaseMapper.list(request, sort);
|
||||
case AssociateCaseType.API_SCENARIO -> detailCases = extTestPlanReportApiScenarioMapper.list(request, sort);
|
||||
default -> detailCases = new ArrayList<>();
|
||||
}
|
||||
List<String> distinctUserIds = detailCases.stream().map(ReportDetailCasePageDTO::getExecuteUser).distinct().collect(Collectors.toList());
|
||||
|
@ -1344,17 +1342,18 @@ public class TestPlanReportService {
|
|||
if (CollectionUtils.isNotEmpty(collections)) {
|
||||
TestPlanReportDetailPageRequest reportDetail = new TestPlanReportDetailPageRequest();
|
||||
BeanUtils.copyBean(reportDetail, request);
|
||||
String sort = StringUtils.replace(request.getSortString(), "request_time", "request_duration");
|
||||
collections.forEach(item -> {
|
||||
reportDetail.setCollectionId(item.getId());
|
||||
reportDetail.setDetailReportIds(getActualReportIds(request.getReportId()));
|
||||
List<ReportDetailCasePageDTO> caseList = new ArrayList<>();
|
||||
switch (caseType) {
|
||||
case CollectionQueryType.FUNCTIONAL ->
|
||||
caseList = listReportDetailCases(reportDetail, AssociateCaseType.FUNCTIONAL);
|
||||
caseList = listReportDetailCases(reportDetail, sort, AssociateCaseType.FUNCTIONAL);
|
||||
case CollectionQueryType.API ->
|
||||
caseList = listReportDetailCases(reportDetail, AssociateCaseType.API_CASE);
|
||||
caseList = listReportDetailCases(reportDetail, sort, AssociateCaseType.API_CASE);
|
||||
case CollectionQueryType.SCENARIO ->
|
||||
caseList = listReportDetailCases(reportDetail, AssociateCaseType.API_SCENARIO);
|
||||
caseList = listReportDetailCases(reportDetail, sort, AssociateCaseType.API_SCENARIO);
|
||||
default -> caseList = new ArrayList<>();
|
||||
}
|
||||
item.setReportDetailCaseList(caseList);
|
||||
|
|
Loading…
Reference in New Issue