From 5f0168f64088a1a243e2378ae23c2cdab1dc5f32 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Fri, 12 Aug 2022 18:37:09 +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=E5=8A=9F=E8=83=BD=E7=94=A8?= =?UTF-8?q?=E4=BE=8BID=E6=8E=92=E5=BA=8F=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/1222841 --- .../service/ProjectApplicationService.java | 10 ++++++++++ .../track/service/TestPlanTestCaseService.java | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java b/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java index 65eaa25183..d0bd4b48f4 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectApplicationService.java @@ -373,4 +373,14 @@ public class ProjectApplicationService { return projectApplications.stream() .collect(Collectors.toMap(ProjectApplication::getProjectId, ProjectApplication::getType)); } + + public Boolean checkCustomNumByProjectId(String projectId) { + ProjectApplicationExample example = new ProjectApplicationExample(); + example.createCriteria() + .andProjectIdEqualTo(projectId) + .andTypeEqualTo(ProjectApplicationType.CASE_CUSTOM_NUM.name()) + .andTypeValueEqualTo("true"); + List projectApplications = projectApplicationMapper.selectByExample(example); + return projectApplications.size() > 0; + } } 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 39dc324a49..9618f51f58 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -80,6 +80,9 @@ public class TestPlanTestCaseService { @Resource private FunctionCaseExecutionInfoService functionCaseExecutionInfoService; + private static final String CUSTOM_NUM = "custom_num"; + private static final String NUM = "num"; + public List listAll() { TestPlanTestCaseExample example = new TestPlanTestCaseExample(); example.createCriteria(); @@ -92,6 +95,21 @@ public class TestPlanTestCaseService { public List list(QueryTestPlanCaseRequest request) { List orders = ServiceUtils.getDefaultSortOrder(request.getOrders()); + // CUSTOM_NUM ORDER + boolean customOrderFlag = orders.stream().anyMatch(order -> StringUtils.equals(order.getName(), CUSTOM_NUM)); + if (customOrderFlag) { + // 判断当前项目时候开启自定义字段的配置 + boolean customNumEnable = projectApplicationService.checkCustomNumByProjectId(request.getProjectId()); + orders.forEach(order -> { + if (StringUtils.equals(order.getName(), CUSTOM_NUM)) { + if (customNumEnable) { + order.setName(CUSTOM_NUM); + } else { + order.setName(NUM); + } + } + }); + } request.setOrders(orders); List list = extTestPlanTestCaseMapper.list(request);