From 17d5ccf12487a9787c12a5da45dbe679f04ab761 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Fri, 8 Nov 2024 16:21:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E5=BE=85=E5=8A=9E=E8=AF=84=E5=AE=A1&&=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --task=1016866 --user=宋昌昌 我的工作台-我创建&关注&待办-后端 https://www.tapd.cn/55049933/s/1607311 --- .../bug/dto/request/BugPageRequest.java | 6 ++ .../metersphere/bug/mapper/ExtBugMapper.xml | 8 +++ .../functional/mapper/ExtCaseReviewMapper.xml | 7 +++ .../request/CaseReviewPageRequest.java | 4 ++ .../controller/MyViewController.java | 9 +++ .../dashboard/controller/ToDoController.java | 63 +++++++++++++++++++ .../controller/ToDoControllerTests.java | 51 +++++++++++++++ 7 files changed, 148 insertions(+) create mode 100644 backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/ToDoController.java create mode 100644 backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/ToDoControllerTests.java diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugPageRequest.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugPageRequest.java index 0d28effccc..a2f282ce04 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugPageRequest.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugPageRequest.java @@ -19,4 +19,10 @@ public class BugPageRequest extends BasePageRequest { @Schema(description = "是否回收站") private boolean useTrash; + + @Schema(description = "是否我的待办, 默认查询全部") + private boolean myTodo = false; + + @Schema(description = "我的待办用户ID, 组合使用: myTodo=true, myTodoUserId=xxx") + private String myTodoUserId; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml index 76068c04fb..80486092be 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml @@ -157,6 +157,14 @@ or b.tags like concat('%', #{request.keyword},'%') ) + + + 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} + diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml index de1d21c46f..757901d694 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml @@ -123,6 +123,13 @@ select case_review_user.review_id from case_review_user where case_review_user.user_id = #{request.reviewByMe} ) + + + and case_review.status in ('PREPARED', 'UNDERWAY') + and case_review.id in ( + select review_id from case_review_user where user_id = #{request.myTodoUserId} + ) + diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewPageRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewPageRequest.java index 7a1a287604..2d55a06246 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewPageRequest.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/CaseReviewPageRequest.java @@ -28,6 +28,10 @@ public class CaseReviewPageRequest extends BasePageRequest implements Serializab @Schema(description = "我创建的") private String createByMe; + @Schema(description = "是否我的待办, 默认查询全部") + private boolean myTodo = false; + @Schema(description = "我的待办用户ID, 组合使用: myTodo=true, myTodoUserId=xxx") + private String myTodoUserId; } diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/MyViewController.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/MyViewController.java index a4e0490368..100aaafa29 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/MyViewController.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/MyViewController.java @@ -7,6 +7,7 @@ import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCasePageRequest; import io.metersphere.api.dto.scenario.ApiScenarioDTO; 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.scenario.ApiScenarioService; 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.TestPlanStatisticsService; import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.system.dto.ProtocolDTO; 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.Parameter; import io.swagger.v3.oas.annotations.media.Schema; @@ -65,6 +68,8 @@ public class MyViewController { @Resource private ApiScenarioService apiScenarioService; @Resource + private ApiTestService apiTestService; + @Resource private BugService bugService; @PostMapping("/plan/page") @@ -103,6 +108,10 @@ public class MyViewController { @Operation(summary = "我的-接口用例-列表分页查询") @CheckOwner(resourceId = "#viewRequest.getProjectId()", resourceType = "project") public Pager> page(@Validated @RequestBody DashboardViewApiCaseTableRequest viewRequest) { + // 默认查询当前用户组织下的所有协议 + List protocols = apiTestService.getProtocols(SessionUtils.getCurrentOrganizationId()); + List protocolList = protocols.stream().map(ProtocolDTO::getProtocol).toList(); + viewRequest.setProtocols(protocolList); Page page = PageHelper.startPage(viewRequest.getCurrent(), viewRequest.getPageSize(), 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)); diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/ToDoController.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/ToDoController.java new file mode 100644 index 0000000000..2e8c5b3ff4 --- /dev/null +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/controller/ToDoController.java @@ -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> reviewPage(@Validated @RequestBody CaseReviewPageRequest request) { + Page 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> bugPage(@Validated @RequestBody BugPageRequest request) { + Page 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)); + } +} diff --git a/backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/ToDoControllerTests.java b/backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/ToDoControllerTests.java new file mode 100644 index 0000000000..8bbc291d9e --- /dev/null +++ b/backend/services/dashboard/src/test/java/io/metersphere/dashboard/controller/ToDoControllerTests.java @@ -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); + } +}