refactor(测试计划): 优化报告详情分页数据查询逻辑

This commit is contained in:
song-cc-rock 2024-08-27 15:49:58 +08:00 committed by Craftsman
parent 5bc575bfbe
commit 3077d2903c
2 changed files with 18 additions and 0 deletions

View File

@ -146,6 +146,9 @@ public class TestPlanReportController {
public Pager<List<BugDTO>> pageBug(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprb.bug_num, tprb.id desc");
if (!request.getStartPager()) {
page.close();
}
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailBugs(request));
}
@ -156,6 +159,9 @@ public class TestPlanReportController {
public Pager<List<ReportDetailCasePageDTO>> pageFunctionalCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprfc.pos desc");
if (!request.getStartPager()) {
page.close();
}
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.FUNCTIONAL));
}
@ -173,6 +179,9 @@ public class TestPlanReportController {
public Pager<List<ReportDetailCasePageDTO>> pageApiCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tprac.pos desc");
if (!request.getStartPager()) {
page.close();
}
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.API_CASE));
}
@ -183,6 +192,9 @@ public class TestPlanReportController {
public Pager<List<ReportDetailCasePageDTO>> pageScenarioCase(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tpras.pos desc");
if (!request.getStartPager()) {
page.close();
}
return PageUtils.setPageInfo(page, testPlanReportService.listReportDetailCases(request, AssociateCaseType.API_SCENARIO));
}
@ -193,6 +205,9 @@ public class TestPlanReportController {
public Pager<List<TestPlanReportDetailResponse>> planReportPage(@Validated @RequestBody TestPlanReportDetailPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "tpr.create_time desc");
if (!request.getStartPager()) {
page.close();
}
return PageUtils.setPageInfo(page, testPlanReportService.planReportList(request));
}

View File

@ -13,4 +13,7 @@ public class TestPlanReportDetailPageRequest extends BasePageRequest {
@Schema(description = "报告ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan.report_id.not_blank}")
private String reportId;
@Schema(description = "是否分页", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Boolean startPager = true;
}