feat(工作台): 补充待办测试计划列表接口功能
--task=1016866 --user=宋昌昌 我的工作台-我创建&关注&待办-后端 https://www.tapd.cn/55049933/s/1607311
This commit is contained in:
parent
5906472833
commit
5e8362e0c8
|
@ -8,6 +8,9 @@ import io.metersphere.bug.service.BugService;
|
|||
import io.metersphere.functional.dto.CaseReviewDTO;
|
||||
import io.metersphere.functional.request.CaseReviewPageRequest;
|
||||
import io.metersphere.functional.service.CaseReviewService;
|
||||
import io.metersphere.plan.dto.request.TestPlanTableRequest;
|
||||
import io.metersphere.plan.dto.response.TestPlanResponse;
|
||||
import io.metersphere.plan.service.TestPlanManagementService;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
import io.metersphere.system.utils.PageUtils;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
|
@ -37,6 +40,17 @@ public class ToDoController {
|
|||
private CaseReviewService caseReviewService;
|
||||
@Resource
|
||||
private BugService bugService;
|
||||
@Resource
|
||||
private TestPlanManagementService testPlanManagementService;
|
||||
|
||||
@PostMapping("/plan/page")
|
||||
@Operation(summary = "我的待办-测试计划-列表分页查询")
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public Pager<List<TestPlanResponse>> planPage(@Validated @RequestBody TestPlanTableRequest request) {
|
||||
request.setMyTodo(true);
|
||||
request.setMyTodoUserId(SessionUtils.getUserId());
|
||||
return testPlanManagementService.page(request);
|
||||
}
|
||||
|
||||
@PostMapping("/review/page")
|
||||
@Operation(summary = "我的待办-用例评审-列表分页查询")
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.dashboard.controller;
|
|||
|
||||
import io.metersphere.bug.dto.request.BugPageRequest;
|
||||
import io.metersphere.functional.request.CaseReviewPageRequest;
|
||||
import io.metersphere.plan.dto.request.TestPlanTableRequest;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
|
@ -17,6 +18,7 @@ import java.util.Map;
|
|||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class ToDoControllerTests extends BaseTest {
|
||||
|
||||
private static final String PLAN_PAGE = "/plan/page";
|
||||
private static final String REVIEW_PAGE = "/review/page";
|
||||
private static final String BUG_PAGE = "/bug/page";
|
||||
|
||||
|
@ -25,6 +27,19 @@ public class ToDoControllerTests extends BaseTest {
|
|||
return "/dashboard/todo";
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(0)
|
||||
void plan() throws Exception{
|
||||
TestPlanTableRequest request = new TestPlanTableRequest();
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(10);
|
||||
request.setType("ALL");
|
||||
this.requestPostWithOk(PLAN_PAGE, request);
|
||||
request.setSort(Map.of("id", "desc"));
|
||||
this.requestPostWithOk(PLAN_PAGE, request);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void review() throws Exception{
|
||||
|
|
|
@ -30,6 +30,15 @@ public class TestPlanTableRequest extends BasePageRequest {
|
|||
private List<String> innerIds;
|
||||
private List<String> combineInnerIds;
|
||||
|
||||
@Schema(description = "是否我的待办, 默认查询全部")
|
||||
private boolean myTodo = false;
|
||||
|
||||
@Schema(description = "我的待办用户ID, 组合使用: myTodo=true, myTodoUserId=xxx")
|
||||
private String myTodoUserId;
|
||||
|
||||
@Schema(description = "已办的测试计划ID集合 (用作待办排除)")
|
||||
private List<String> doneExcludeIds;
|
||||
|
||||
public String getSortString() {
|
||||
if (StringUtils.isEmpty(super.getSortString())) {
|
||||
return "t.update_time desc";
|
||||
|
|
|
@ -91,7 +91,20 @@
|
|||
</select>
|
||||
|
||||
<sql id="queryByTableRequest">
|
||||
<include refid="baseConditionQuery"/>
|
||||
<if test="request.myTodo">
|
||||
<!-- 待办: 查询创建人为我的所有的计划 -->
|
||||
and t.type = 'TEST_PLAN'
|
||||
and t.create_user = #{request.myTodoUserId}
|
||||
<if test="request.doneExcludeIds != null and request.doneExcludeIds.size() > 0">
|
||||
and t.id not in
|
||||
<foreach collection="request.doneExcludeIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</if>
|
||||
<if test="!request.myTodo">
|
||||
<include refid="baseConditionQuery"/>
|
||||
</if>
|
||||
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
|
|
|
@ -9,6 +9,7 @@ import io.metersphere.plan.dto.TestPlanGroupCountDTO;
|
|||
import io.metersphere.plan.dto.TestPlanResourceExecResultDTO;
|
||||
import io.metersphere.plan.dto.request.TestPlanTableRequest;
|
||||
import io.metersphere.plan.dto.response.TestPlanResponse;
|
||||
import io.metersphere.plan.dto.response.TestPlanStatisticsResponse;
|
||||
import io.metersphere.plan.mapper.ExtTestPlanFunctionalCaseMapper;
|
||||
import io.metersphere.plan.mapper.ExtTestPlanMapper;
|
||||
import io.metersphere.plan.mapper.ExtTestPlanModuleMapper;
|
||||
|
@ -73,6 +74,9 @@ public class TestPlanManagementService {
|
|||
* 测试计划列表查询
|
||||
*/
|
||||
public Pager<List<TestPlanResponse>> page(TestPlanTableRequest request) {
|
||||
if (request.isMyTodo()) {
|
||||
request.setDoneExcludeIds(this.getDoneIds(request.getProjectId()));
|
||||
}
|
||||
this.initDefaultFilter(request);
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
MapUtils.isEmpty(request.getSort()) ? "t.pos desc, t.id desc" : request.getSortString("id", "t"));
|
||||
|
@ -311,4 +315,22 @@ public class TestPlanManagementService {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已完成且阈值达标的计划ID集合 (作为排除条件)
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 已办计划ID集合
|
||||
*/
|
||||
private List<String> getDoneIds(String projectId) {
|
||||
List<String> completePlanOrGroupIds = selectTestPlanIdByProjectIdAndStatus(projectId, List.of((TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED)));
|
||||
if (CollectionUtils.isEmpty(completePlanOrGroupIds)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<TestPlanStatisticsResponse> completePlanOrGroupWithStatistics = testPlanStatisticsService.calculateRate(completePlanOrGroupIds);
|
||||
return completePlanOrGroupWithStatistics.stream()
|
||||
.filter(plan -> plan.getPassRate() >= plan.getPassThreshold())
|
||||
.map(TestPlanStatisticsResponse::getId).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue