From 2133ab291bbf2a4e5d45cbb7d267635333877346 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 22 Aug 2022 15:28:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=94=A8=E4=BE=8B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=92=E5=BA=8F=E6=80=BB=E6=95=B0=E6=9C=89=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015743 --user=宋昌昌 [测试跟踪]github#16785测试计划-功能用例排序不正确 https://www.tapd.cn/55049933/s/1229336 --- .../TestPlanTestCaseController.java | 4 +- .../service/TestPlanTestCaseService.java | 40 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java index b9a0c51689..5517f75aaf 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java @@ -30,8 +30,10 @@ public class TestPlanTestCaseController { @PostMapping("/list/{goPage}/{pageSize}") public Pager> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanCaseRequest request) { + QueryTestPlanCaseRequest paramRequest = testPlanTestCaseService.setCustomNumOrderParam(request); Page page = PageHelper.startPage(goPage, pageSize, true); - return PageUtils.setPageInfo(page, testPlanTestCaseService.list(request)); + List list = testPlanTestCaseService.list(paramRequest); + return PageUtils.setPageInfo(page, list); } /*jenkins测试计划下全部用例*/ diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java index 9618f51f58..768ac801eb 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -94,6 +94,26 @@ public class TestPlanTestCaseService { } public List list(QueryTestPlanCaseRequest request) { + List list = extTestPlanTestCaseMapper.list(request); + if (CollectionUtils.isNotEmpty(list)) { + // 设置版本信息 + ServiceUtils.buildVersionInfo(list); + ServiceUtils.buildProjectInfo(list); + ServiceUtils.buildCustomNumInfo(list); + + QueryMemberRequest queryMemberRequest = new QueryMemberRequest(); + queryMemberRequest.setProjectId(request.getProjectId()); + Map userMap = userService.getProjectMemberList(queryMemberRequest) + .stream().collect(Collectors.toMap(User::getId, User::getName)); + list.forEach(item -> { + item.setExecutorName(userMap.get(item.getExecutor())); + item.setMaintainerName(userMap.get(item.getMaintainer())); + }); + } + return list; + } + + public QueryTestPlanCaseRequest setCustomNumOrderParam(QueryTestPlanCaseRequest request) { List orders = ServiceUtils.getDefaultSortOrder(request.getOrders()); // CUSTOM_NUM ORDER boolean customOrderFlag = orders.stream().anyMatch(order -> StringUtils.equals(order.getName(), CUSTOM_NUM)); @@ -111,25 +131,7 @@ public class TestPlanTestCaseService { }); } request.setOrders(orders); - - List list = extTestPlanTestCaseMapper.list(request); - if (CollectionUtils.isNotEmpty(list)) { - - // 设置版本信息 - ServiceUtils.buildVersionInfo(list); - ServiceUtils.buildProjectInfo(list); - ServiceUtils.buildCustomNumInfo(list); - - QueryMemberRequest queryMemberRequest = new QueryMemberRequest(); - queryMemberRequest.setProjectId(request.getProjectId()); - Map userMap = userService.getProjectMemberList(queryMemberRequest) - .stream().collect(Collectors.toMap(User::getId, User::getName)); - list.forEach(item -> { - item.setExecutorName(userMap.get(item.getExecutor())); - item.setMaintainerName(userMap.get(item.getMaintainer())); - }); - } - return list; + return request; } public QueryTestPlanCaseRequest wrapQueryTestPlanCaseRequest(QueryTestPlanCaseRequest request) {