fix(任务中心): 修复任务报告列表排序报错问题

--bug=1048128 --user=王旭 【任务中心】即时任务列表-场景批量执行生成独立报告任务-查看报告-按创建时间排序报SQL异常 https://www.tapd.cn/55049933/s/1598422
This commit is contained in:
WangXu10 2024-10-25 18:07:26 +08:00 committed by Craftsman
parent c3b5e598bd
commit 479ee61493
5 changed files with 21 additions and 7 deletions

View File

@ -194,8 +194,11 @@ public class ProjectTaskHubController {
@Operation(summary = "项目-任务中心-用例执行任务-批量任务列表") @Operation(summary = "项目-任务中心-用例执行任务-批量任务列表")
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ) @RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ)
public Pager<List<BatchExecTaskReportDTO>> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { public Pager<List<BatchExecTaskReportDTO>> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) {
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), String sort = StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc";
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); if (StringUtils.contains(request.getSortString(), "create_time")) {
sort = sort.replace("create_time", "r.start_time");
}
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), sort);
return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request));
} }
} }

View File

@ -289,7 +289,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
request.setCurrent(1); request.setCurrent(1);
request.setPageSize(10); request.setPageSize(10);
this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request); this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request);
request.setSort(Map.of("startTime", "asc")); request.setSort(Map.of("createTime", "asc"));
request.setBatchType(ExecTaskType.API_SCENARIO_BATCH.name()); request.setBatchType(ExecTaskType.API_SCENARIO_BATCH.name());
this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request); this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request);
} }

View File

@ -207,8 +207,11 @@ public class OrganizationTaskHubController {
@Operation(summary = "组织-任务中心-用例执行任务-批量任务列表") @Operation(summary = "组织-任务中心-用例执行任务-批量任务列表")
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ) @RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ)
public Pager<List<BatchExecTaskReportDTO>> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { public Pager<List<BatchExecTaskReportDTO>> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) {
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), String sort = StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc";
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); if (StringUtils.contains(request.getSortString(), "create_time")) {
sort = sort.replace("create_time", "r.start_time");
}
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), sort);
return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request));
} }

View File

@ -144,8 +144,11 @@ public class SystemTaskHubController {
@Operation(summary = "组织-任务中心-用例执行任务-批量任务列表") @Operation(summary = "组织-任务中心-用例执行任务-批量任务列表")
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ) @RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
public Pager<List<BatchExecTaskReportDTO>> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { public Pager<List<BatchExecTaskReportDTO>> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) {
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), String sort = StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc";
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); if (StringUtils.contains(request.getSortString(), "create_time")) {
sort = sort.replace("create_time", "r.start_time");
}
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), sort);
return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request));
} }

View File

@ -413,6 +413,11 @@ public class BaseTaskHubControllerTests extends BaseTest {
request.setPageSize(10); request.setPageSize(10);
this.requestPostWithOk(SYSTEM_TASK_BATCH_PAGE, request); this.requestPostWithOk(SYSTEM_TASK_BATCH_PAGE, request);
this.requestPostWithOk(ORG_TASK_BATCH_PAGE, request); this.requestPostWithOk(ORG_TASK_BATCH_PAGE, request);
request.setSort(new HashMap<>() {{
put("createTime", "desc");
}});
this.requestPostWithOk(SYSTEM_TASK_BATCH_PAGE, request);
this.requestPostWithOk(ORG_TASK_BATCH_PAGE, request);
} }