diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java index 900c8bd88b..c17eb5331a 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java @@ -194,8 +194,11 @@ public class ProjectTaskHubController { @Operation(summary = "项目-任务中心-用例执行任务-批量任务列表") @RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ) public Pager> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { - Page page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), - StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); + String sort = 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 page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), sort); return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); } } diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java index ec655a0d98..7285cc0b87 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java @@ -289,7 +289,7 @@ public class ProjectTaskHubControllerTests extends BaseTest { request.setCurrent(1); request.setPageSize(10); 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()); this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java index 0260bceed6..ad7cf0ada8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java @@ -207,8 +207,11 @@ public class OrganizationTaskHubController { @Operation(summary = "组织-任务中心-用例执行任务-批量任务列表") @RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ) public Pager> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { - Page page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), - StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); + String sort = 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 page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), sort); return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java index 63cd56a8aa..1d89faebe3 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java @@ -144,8 +144,11 @@ public class SystemTaskHubController { @Operation(summary = "组织-任务中心-用例执行任务-批量任务列表") @RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ) public Pager> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { - Page page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), - StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); + String sort = 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 page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), sort); return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java index 38f3832c27..15829944bc 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java @@ -413,6 +413,11 @@ public class BaseTaskHubControllerTests extends BaseTest { request.setPageSize(10); this.requestPostWithOk(SYSTEM_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); }