From 479ee614935ef95a53d197f20487ae02c167e095 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 25 Oct 2024 18:07:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048128 --user=王旭 【任务中心】即时任务列表-场景批量执行生成独立报告任务-查看报告-按创建时间排序报SQL异常 https://www.tapd.cn/55049933/s/1598422 --- .../project/controller/ProjectTaskHubController.java | 7 +++++-- .../project/controller/ProjectTaskHubControllerTests.java | 2 +- .../system/controller/OrganizationTaskHubController.java | 7 +++++-- .../system/controller/SystemTaskHubController.java | 7 +++++-- .../system/controller/BaseTaskHubControllerTests.java | 5 +++++ 5 files changed, 21 insertions(+), 7 deletions(-) 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); }