fix(测试跟踪): 测试计划功能用例ID排序问题

--bug=1015743 --user=宋昌昌 [测试跟踪]github#16785测试计划-功能用例排序不正确 https://www.tapd.cn/55049933/s/1222841
This commit is contained in:
song-cc-rock 2022-08-12 18:54:45 +08:00 committed by 刘瑞斌
parent 8b6b67e9d0
commit 81a226bb8c
2 changed files with 28 additions and 0 deletions

View File

@ -363,4 +363,14 @@ public class ProjectApplicationService {
}
}
}
public Boolean checkCustomNumByProjectId(String projectId) {
ProjectApplicationExample example = new ProjectApplicationExample();
example.createCriteria()
.andProjectIdEqualTo(projectId)
.andTypeEqualTo(ProjectApplicationType.CASE_CUSTOM_NUM.name())
.andTypeValueEqualTo("true");
List<ProjectApplication> projectApplications = projectApplicationMapper.selectByExample(example);
return projectApplications.size() > 0;
}
}

View File

@ -75,6 +75,9 @@ public class TestPlanTestCaseService {
@Resource
private ProjectApplicationService projectApplicationService;
private static final String CUSTOM_NUM = "custom_num";
private static final String NUM = "num";
public List<TestPlanTestCaseWithBLOBs> listAll() {
TestPlanTestCaseExample example = new TestPlanTestCaseExample();
example.createCriteria();
@ -88,6 +91,21 @@ public class TestPlanTestCaseService {
public List<TestPlanCaseDTO> list(QueryTestPlanCaseRequest request) {
List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder(request.getOrders());
orders = ServiceUtils.replaceCustomNumOrder(request.getIsCustomNum(), orders);
// 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<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);