fix(测试跟踪): 测试计划关联功能用例顺序

This commit is contained in:
song-cc-rock 2023-04-04 10:46:01 +08:00 committed by jianxing
parent c293daccee
commit 662023e702
2 changed files with 22 additions and 2 deletions

View File

@ -1263,14 +1263,14 @@
left join test_plan_test_case as T2 on test_case.id=T2.case_id and T2.plan_id =#{request.planId}
<include refid="notInQueryWhereCondition"/>
and T2.case_id is null
order by test_case.`order` desc, test_case.sort desc
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
<select id="getMaintainerMapForPlanRepeat" resultType="io.metersphere.base.domain.TestCase">
select test_case.id as id, test_case.maintainer as maintainer
from test_case as test_case
<include refid="notInQueryWhereCondition"/>
order by test_case.`order` desc, test_case.sort desc
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
<select id="getForNodeEdit" resultType="io.metersphere.dto.TestCaseDTO">

View File

@ -49,6 +49,7 @@ import io.metersphere.plan.service.remote.ui.PlanTestPlanUiScenarioCaseService;
import io.metersphere.plan.service.remote.ui.PlanUiAutomationService;
import io.metersphere.plan.utils.TestPlanReportUtil;
import io.metersphere.plan.utils.TestPlanRequestUtil;
import io.metersphere.request.OrderRequest;
import io.metersphere.request.ScheduleRequest;
import io.metersphere.service.*;
import io.metersphere.utils.DiscoveryUtil;
@ -557,6 +558,15 @@ public class TestPlanService {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
boolean isSelectAll = request.getRequest() != null && request.getRequest().isSelectAll();
if (isSelectAll) {
List<OrderRequest> orders = request.getRequest().getOrders();
if (CollectionUtils.isNotEmpty(orders)) {
orders.forEach(order -> {
order.setPrefix("test_case");
});
} else {
List<OrderRequest> defaultOrders = getDefaultOrders();
request.getRequest().setOrders(defaultOrders);
}
List<TestCase> maintainerMap;
if (BooleanUtils.isTrue(testPlan.getRepeatCase())) {
maintainerMap = extTestCaseMapper.getMaintainerMapForPlanRepeat(request.getRequest());
@ -685,6 +695,16 @@ public class TestPlanService {
}
}
private List<OrderRequest> getDefaultOrders() {
List<OrderRequest> orderRequests = new ArrayList<>();
OrderRequest orderRequest = new OrderRequest();
orderRequest.setPrefix("test_case");
orderRequest.setName("order");
orderRequest.setType("desc");
orderRequests.add(orderRequest);
return orderRequests;
}
public List<TestPlan> recentTestPlans(String projectId) {
return extTestPlanMapper.listRecent(SessionUtils.getUserId(), projectId);
}