fix(测试跟踪): 测试计划功能用例列表ID排序报错
--bug=1013907 --user=陈建星 【测试计划】测试计划关联功能用例,点击id字段排序报错 https://www.tapd.cn/55049933/s/1177793
This commit is contained in:
parent
71b44661ff
commit
084385cb5a
|
@ -258,11 +258,8 @@
|
|||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
<choose>
|
||||
<when test="order.name == 'custom_num'">
|
||||
customNum ${order.type}
|
||||
</when>
|
||||
<when test="order.name == 'name'">
|
||||
test_case.name ${order.type}
|
||||
<when test="order.name == 'custom_num' || order.name == 'num' || order.name == 'name'">
|
||||
test_case.${order.name} ${order.type}
|
||||
</when>
|
||||
<otherwise>
|
||||
test_plan_test_case.${order.name} ${order.type}
|
||||
|
|
|
@ -54,6 +54,24 @@ public class ServiceUtils {
|
|||
return getDefaultOrderByField(prefix, orders, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前项目设置是否启用自定义ID
|
||||
* 设置按照哪个字段排序
|
||||
* @param isCustomNum
|
||||
* @param orders
|
||||
* @return
|
||||
*/
|
||||
public static List<OrderRequest> replaceCustomNumOrder(Boolean isCustomNum, List<OrderRequest> orders) {
|
||||
orders.forEach(item -> {
|
||||
if (isCustomNum && StringUtils.equals(item.getName(), "num")) {
|
||||
item.setName("custom_num");
|
||||
} else if (StringUtils.equals(item.getName(), "custom_num")) {
|
||||
item.setName("num");
|
||||
}
|
||||
});
|
||||
return orders;
|
||||
}
|
||||
|
||||
private static List<OrderRequest> getDefaultOrderByField(String prefix, List<OrderRequest> orders, String field) {
|
||||
if (orders == null || orders.size() < 1) {
|
||||
OrderRequest orderRequest = new OrderRequest();
|
||||
|
|
|
@ -29,6 +29,7 @@ public class TestPlanTestCaseController {
|
|||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
public Pager<List<TestPlanCaseDTO>> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanCaseRequest request) {
|
||||
testPlanTestCaseService.wrapQueryTestPlanCaseRequest(request);
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, testPlanTestCaseService.list(request));
|
||||
}
|
||||
|
@ -94,6 +95,7 @@ public class TestPlanTestCaseController {
|
|||
|
||||
@PostMapping("/list/all")
|
||||
public List<TestPlanCaseDTO> getTestPlanCases(@RequestBody QueryTestPlanCaseRequest request) {
|
||||
testPlanTestCaseService.wrapQueryTestPlanCaseRequest(request);
|
||||
return testPlanTestCaseService.list(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,5 +35,9 @@ public class QueryTestPlanCaseRequest extends BaseQueryRequest {
|
|||
|
||||
private String id;
|
||||
|
||||
private Boolean isCustomNum = false;
|
||||
|
||||
private String projectName;
|
||||
|
||||
private Map<String, Object> combine;
|
||||
}
|
||||
|
|
|
@ -696,6 +696,8 @@ public class TestPlanService {
|
|||
public List<TestPlanCaseDTO> listTestCaseByPlanId(String planId) {
|
||||
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
|
||||
request.setPlanId(planId);
|
||||
request.setProjectId(testPlanMapper.selectByPrimaryKey(planId).getProjectId());
|
||||
testPlanTestCaseService.wrapQueryTestPlanCaseRequest(request);
|
||||
return testPlanTestCaseService.list(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,35 +86,43 @@ public class TestPlanTestCaseService {
|
|||
}
|
||||
|
||||
public List<TestPlanCaseDTO> list(QueryTestPlanCaseRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
|
||||
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return list;
|
||||
}
|
||||
Project project = projectService.getProjectById(list.get(0).getProjectId());
|
||||
List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder(request.getOrders());
|
||||
orders = ServiceUtils.replaceCustomNumOrder(request.getIsCustomNum(), orders);
|
||||
request.setOrders(orders);
|
||||
|
||||
ProjectApplication projectApplication = projectApplicationService.getProjectApplication(project.getId(), "CASE_CUSTOM_NUM");
|
||||
list.forEach(item -> {
|
||||
// 设置项目名称
|
||||
item.setProjectName(project.getName());
|
||||
if (StringUtils.equals(projectApplication.getTypeValue(), "false")) {
|
||||
// 如果配置是不启用自定义字段,则设置为 num
|
||||
item.setCustomNum(item.getNum().toString());
|
||||
}
|
||||
});
|
||||
// 设置版本信息
|
||||
ServiceUtils.buildVersionInfo(list);
|
||||
QueryMemberRequest queryMemberRequest = new QueryMemberRequest();
|
||||
queryMemberRequest.setProjectId(request.getProjectId());
|
||||
Map<String, String> 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()));
|
||||
});
|
||||
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
list.forEach(item -> {
|
||||
// 设置项目名称
|
||||
item.setProjectName(request.getProjectName());
|
||||
if (!request.getIsCustomNum()) {
|
||||
// 如果配置是不启用自定义字段,则设置为 num
|
||||
item.setCustomNum(item.getNum().toString());
|
||||
}
|
||||
});
|
||||
|
||||
// 设置版本信息
|
||||
ServiceUtils.buildVersionInfo(list);
|
||||
QueryMemberRequest queryMemberRequest = new QueryMemberRequest();
|
||||
queryMemberRequest.setProjectId(request.getProjectId());
|
||||
Map<String, String> 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 wrapQueryTestPlanCaseRequest(QueryTestPlanCaseRequest request) {
|
||||
Project project = projectService.getProjectById(request.getProjectId());
|
||||
ProjectApplication projectApplication = projectApplicationService.getProjectApplication(project.getId(), ProjectApplicationType.CASE_CUSTOM_NUM.name());
|
||||
request.setIsCustomNum(StringUtils.equals(projectApplication.getTypeValue(), "false") ? false : true);
|
||||
request.setProjectName(project.getName());
|
||||
return request;
|
||||
}
|
||||
|
||||
public List<TestPlanCaseDTO> listByPlanId(QueryTestPlanCaseRequest request) {
|
||||
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.listByPlanId(request);
|
||||
return list;
|
||||
|
|
Loading…
Reference in New Issue