feat(工作台): 补充待办评审&&缺陷列表接口功能

--task=1016866 --user=宋昌昌 我的工作台-我创建&关注&待办-后端 https://www.tapd.cn/55049933/s/1607311
This commit is contained in:
song-cc-rock 2024-11-08 16:21:00 +08:00 committed by Craftsman
parent 6078bcb4f5
commit 17d5ccf124
7 changed files with 148 additions and 0 deletions

View File

@ -19,4 +19,10 @@ public class BugPageRequest extends BasePageRequest {
@Schema(description = "是否回收站") @Schema(description = "是否回收站")
private boolean useTrash; private boolean useTrash;
@Schema(description = "是否我的待办, 默认查询全部")
private boolean myTodo = false;
@Schema(description = "我的待办用户ID, 组合使用: myTodo=true, myTodoUserId=xxx")
private String myTodoUserId;
} }

View File

@ -157,6 +157,14 @@
or b.tags like concat('%', #{request.keyword},'%') or b.tags like concat('%', #{request.keyword},'%')
) )
</if> </if>
<!-- 我的待办: Local平台&&非结束状态&&处理人为我; -->
<if test="request.myTodo">
and b.platform = 'Local' and b.status in (
select id from status_item si left join status_definition sd on si.id = sd.status_id
where scope_type = 'PROJECT' and scope_id = #{request.projectId}
and (sd.definition_id != 'END' || sd.definition_id is null)
) and b.handle_user = #{request.myTodoUserId}
</if>
<include refid="filter"/> <include refid="filter"/>
<include refid="combine"> <include refid="combine">
<property name="combineSearch" value="request.combineSearch"/> <property name="combineSearch" value="request.combineSearch"/>

View File

@ -123,6 +123,13 @@
select case_review_user.review_id from case_review_user where case_review_user.user_id = #{request.reviewByMe} select case_review_user.review_id from case_review_user where case_review_user.user_id = #{request.reviewByMe}
) )
</if> </if>
<!-- 我的待办: "进行中"和"未开始",评审人为我的所有评审; -->
<if test="request.myTodo">
and case_review.status in ('PREPARED', 'UNDERWAY')
and case_review.id in (
select review_id from case_review_user where user_id = #{request.myTodoUserId}
)
</if>
<include refid="filters"> <include refid="filters">
<property name="filter" value="request.filter"/> <property name="filter" value="request.filter"/>
</include> </include>

View File

@ -28,6 +28,10 @@ public class CaseReviewPageRequest extends BasePageRequest implements Serializab
@Schema(description = "我创建的") @Schema(description = "我创建的")
private String createByMe; private String createByMe;
@Schema(description = "是否我的待办, 默认查询全部")
private boolean myTodo = false;
@Schema(description = "我的待办用户ID, 组合使用: myTodo=true, myTodoUserId=xxx")
private String myTodoUserId;
} }

View File

@ -7,6 +7,7 @@ import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCasePageRequest; import io.metersphere.api.dto.definition.ApiTestCasePageRequest;
import io.metersphere.api.dto.scenario.ApiScenarioDTO; import io.metersphere.api.dto.scenario.ApiScenarioDTO;
import io.metersphere.api.dto.scenario.ApiScenarioPageRequest; import io.metersphere.api.dto.scenario.ApiScenarioPageRequest;
import io.metersphere.api.service.ApiTestService;
import io.metersphere.api.service.definition.ApiTestCaseService; import io.metersphere.api.service.definition.ApiTestCaseService;
import io.metersphere.api.service.scenario.ApiScenarioService; import io.metersphere.api.service.scenario.ApiScenarioService;
import io.metersphere.bug.dto.request.BugPageRequest; import io.metersphere.bug.dto.request.BugPageRequest;
@ -27,9 +28,11 @@ import io.metersphere.plan.dto.response.TestPlanStatisticsResponse;
import io.metersphere.plan.service.TestPlanManagementService; import io.metersphere.plan.service.TestPlanManagementService;
import io.metersphere.plan.service.TestPlanStatisticsService; import io.metersphere.plan.service.TestPlanStatisticsService;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.system.dto.ProtocolDTO;
import io.metersphere.system.security.CheckOwner; import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -65,6 +68,8 @@ public class MyViewController {
@Resource @Resource
private ApiScenarioService apiScenarioService; private ApiScenarioService apiScenarioService;
@Resource @Resource
private ApiTestService apiTestService;
@Resource
private BugService bugService; private BugService bugService;
@PostMapping("/plan/page") @PostMapping("/plan/page")
@ -103,6 +108,10 @@ public class MyViewController {
@Operation(summary = "我的-接口用例-列表分页查询") @Operation(summary = "我的-接口用例-列表分页查询")
@CheckOwner(resourceId = "#viewRequest.getProjectId()", resourceType = "project") @CheckOwner(resourceId = "#viewRequest.getProjectId()", resourceType = "project")
public Pager<List<ApiTestCaseDTO>> page(@Validated @RequestBody DashboardViewApiCaseTableRequest viewRequest) { public Pager<List<ApiTestCaseDTO>> page(@Validated @RequestBody DashboardViewApiCaseTableRequest viewRequest) {
// 默认查询当前用户组织下的所有协议
List<ProtocolDTO> protocols = apiTestService.getProtocols(SessionUtils.getCurrentOrganizationId());
List<String> protocolList = protocols.stream().map(ProtocolDTO::getProtocol).toList();
viewRequest.setProtocols(protocolList);
Page<Object> page = PageHelper.startPage(viewRequest.getCurrent(), viewRequest.getPageSize(), Page<Object> page = PageHelper.startPage(viewRequest.getCurrent(), viewRequest.getPageSize(),
StringUtils.isNotBlank(viewRequest.getSortString("id")) ? viewRequest.getSortString("id") : "pos desc, id desc"); StringUtils.isNotBlank(viewRequest.getSortString("id")) ? viewRequest.getSortString("id") : "pos desc, id desc");
return PageUtils.setPageInfo(page, apiTestCaseService.page(buildTargetRequest(new ApiTestCasePageRequest(), viewRequest), false, true, null)); return PageUtils.setPageInfo(page, apiTestCaseService.page(buildTargetRequest(new ApiTestCasePageRequest(), viewRequest), false, true, null));

View File

@ -0,0 +1,63 @@
package io.metersphere.dashboard.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.bug.dto.request.BugPageRequest;
import io.metersphere.bug.dto.response.BugDTO;
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.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author song-cc-rock
*/
@Tag(name = "工作台-我的待办")
@RestController
@RequestMapping("/dashboard/todo")
public class ToDoController {
@Resource
private CaseReviewService caseReviewService;
@Resource
private BugService bugService;
@PostMapping("/review/page")
@Operation(summary = "我的待办-用例评审-列表分页查询")
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public Pager<List<CaseReviewDTO>> reviewPage(@Validated @RequestBody CaseReviewPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
request.setMyTodo(true);
request.setMyTodoUserId(SessionUtils.getUserId());
return PageUtils.setPageInfo(page, caseReviewService.getCaseReviewPage(request));
}
@PostMapping("/bug/page")
@Operation(summary = "我的待办-缺陷-列表分页查询")
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public Pager<List<BugDTO>> bugPage(@Validated @RequestBody BugPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
request.setUseTrash(false);
request.setMyTodo(true);
request.setMyTodoUserId(SessionUtils.getUserId());
return PageUtils.setPageInfo(page, bugService.list(request));
}
}

View File

@ -0,0 +1,51 @@
package io.metersphere.dashboard.controller;
import io.metersphere.bug.dto.request.BugPageRequest;
import io.metersphere.functional.request.CaseReviewPageRequest;
import io.metersphere.system.base.BaseTest;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Map;
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ToDoControllerTests extends BaseTest {
private static final String REVIEW_PAGE = "/review/page";
private static final String BUG_PAGE = "/bug/page";
@Override
public String getBasePath() {
return "/dashboard/todo";
}
@Test
@Order(1)
void review() throws Exception{
CaseReviewPageRequest request = new CaseReviewPageRequest();
request.setProjectId(DEFAULT_PROJECT_ID);
request.setCurrent(1);
request.setPageSize(10);
this.requestPostWithOk(REVIEW_PAGE, request);
request.setSort(Map.of("id", "desc"));
this.requestPostWithOk(REVIEW_PAGE, request);
}
@Test
@Order(2)
void bug() throws Exception{
BugPageRequest request = new BugPageRequest();
request.setProjectId(DEFAULT_PROJECT_ID);
request.setCurrent(1);
request.setPageSize(10);
this.requestPostWithOk(BUG_PAGE, request);
request.setSort(Map.of("id", "desc"));
this.requestPostWithOk(BUG_PAGE, request);
}
}