diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java index 17374ee031..bee66e5e01 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugController.java @@ -95,6 +95,7 @@ public class BugController { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc"); request.setUseTrash(false); + request.setTodoParam(bugService.buildBugToDoParam(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId())); return PageUtils.setPageInfo(page, bugService.list(request)); } 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 08b6d22c2b..a4f1290773 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 @@ -20,6 +20,18 @@ public class BugPageRequest extends BasePageRequest { @Schema(description = "是否回收站, 后台默认设置") private boolean useTrash; - @Schema(description = "待办参数, 后台默认设置") + @Schema(description = "待办参数: 后台默认设置") private BugTodoRequest todoParam; + + @Schema(description = "工作台参数: 是否属于测试计划") + private Boolean relatedToPlan = false; + + @Schema(description = "工作台参数: 是否我创建的") + private Boolean createByMe = false; + + @Schema(description = "工作台参数: 是否待我处理的") + private Boolean assignedToMe = false; + + @Schema(description = "工作台参数: 是否遗留的") + private Boolean unresolved = false; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTodoRequest.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTodoRequest.java index 9be571a4c7..07c7a80af0 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTodoRequest.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugTodoRequest.java @@ -8,7 +8,7 @@ import java.util.List; /** * @author song-cc-rock - * 缺陷待办参数 + * 缺陷待办参数 (工作台) */ @Data @Builder 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 c1362f3acc..84ab6adbec 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 @@ -162,36 +162,48 @@ or b.tags like concat('%', #{request.keyword},'%') ) - + and ( - - ( - b.platform = 'Local' - - and b.status not in - - #{lastStatus} - - - and b.handle_user = #{request.todoParam.msUserId} - ) - + + ( + b.platform = 'Local' + + and b.status not in + + #{lastStatus} + + + + and b.handle_user = #{request.todoParam.msUserId} + + ) + or - ( - b.platform = #{request.todoParam.currentPlatform} - - and b.status not in - - #{lastStatus} - + ( + b.platform = #{request.todoParam.currentPlatform} + + and b.status not in + + #{lastStatus} + + + + and b.handle_user = #{request.todoParam.platformUser} + + ) - - and b.handle_user = #{request.todoParam.platformUser} - - ) - + ) + + + + and b.create_user = #{request.todoParam.msUserId} + + + and b.id in ( + select distinct b.id from bug b inner join bug_relation_case brc on b.id = brc.bug_id + where brc.test_plan_id is not null and b.project_id = #{request.projectId} ) diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java index a108deb3a9..304e23173a 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java @@ -2106,7 +2106,49 @@ public class BugService { } } + /** + * 获取平台临时富文本图片URL + * @param key 富文本图片key + * @return 富文本图片URL + */ private String getPlatformTmpRichUrlOfKey(String key) { return "alt=\"" + key + "\""; } + + /** + * 设置缺陷待办参数 + * @param request 请求参数 + * @param currentUserId 当前用户ID + * @param currentOrgId 当前组织ID + * @return 待办参数 + */ + public BugTodoRequest buildBugToDoParam(BugPageRequest request, String currentUserId, String currentOrgId) { + List msLastStepStatusIds = bugCommonService.getLocalLastStepStatus(request.getProjectId()); + BugTodoRequest todoParam = BugTodoRequest.builder().build(); + if (request.getAssignedToMe() || request.getCreateByMe()) { + todoParam.setMsUserId(currentUserId); + } + if (request.getUnresolved()) { + todoParam.setMsLastStepStatus(msLastStepStatusIds); + } + try { + // 设置待办的平台参数 + String platformName = projectApplicationService.getPlatformName(request.getProjectId()); + if (StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { + return todoParam; + } + if (request.getUnresolved()) { + todoParam.setCurrentPlatform(platformName); + todoParam.setPlatformLastStatus(bugCommonService.getPlatformLastStepStatus(request.getProjectId())); + } + if (request.getAssignedToMe()) { + todoParam.setPlatformUser(bugCommonService.getPlatformHandlerUser(request.getProjectId(), currentUserId, currentOrgId)); + } + } catch (Exception e) { + // 设置平台参数异常时, 无法正常过滤平台非结束的缺陷 + LogUtils.error(e.getMessage()); + return todoParam; + } + return todoParam; + } } \ No newline at end of file diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java index 00364cff58..9a2a3eed42 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java @@ -189,6 +189,7 @@ public class BugControllerTests extends BaseTest { bugPageRequest.setPageSize(10); bugPageRequest.setKeyword("default-x"); bugPageRequest.setProjectId("default-project-for-bug"); + bugPageRequest.setCreateByMe(true); MvcResult mvcResult = this.requestPostWithOkAndReturn(BUG_PAGE, bugPageRequest); // 获取返回值 String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); @@ -608,6 +609,8 @@ public class BugControllerTests extends BaseTest { BugPageRequest bugPageRequest = new BugPageRequest(); bugPageRequest.setCurrent(1); bugPageRequest.setPageSize(10); + bugPageRequest.setUnresolved(true); + bugPageRequest.setAssignedToMe(true); bugPageRequest.setProjectId("default-project-for-bug"); this.requestPostWithOk(BUG_PAGE, bugPageRequest); diff --git a/backend/services/bug-management/src/test/resources/file/metersphere-jira-test.jar b/backend/services/bug-management/src/test/resources/file/metersphere-jira-test.jar index a07da3a9ac..32a2845d4d 100644 Binary files a/backend/services/bug-management/src/test/resources/file/metersphere-jira-test.jar and b/backend/services/bug-management/src/test/resources/file/metersphere-jira-test.jar differ 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 index cef18c6abd..74306f73fe 100644 --- 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 @@ -3,9 +3,7 @@ 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.request.BugTodoRequest; import io.metersphere.bug.dto.response.BugDTO; -import io.metersphere.bug.enums.BugPlatform; import io.metersphere.bug.service.BugCommonService; import io.metersphere.bug.service.BugService; import io.metersphere.functional.dto.CaseReviewDTO; @@ -17,7 +15,6 @@ import io.metersphere.plan.dto.response.TestPlanStatisticsResponse; import io.metersphere.plan.service.TestPlanManagementService; import io.metersphere.plan.service.TestPlanStatisticsService; import io.metersphere.project.service.ProjectApplicationService; -import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.security.CheckOwner; import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; @@ -96,36 +93,11 @@ public class ToDoController { @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public Pager> bugPage(@Validated @RequestBody BugPageRequest request) { request.setUseTrash(false); - request.setTodoParam(buildBugToDoParam(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId())); + request.setAssignedToMe(true); + request.setUnresolved(true); + request.setTodoParam(bugService.buildBugToDoParam(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId())); Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "b.pos desc"); return PageUtils.setPageInfo(page, bugService.list(request)); } - - /** - * 设置缺陷待办参数 - * @param request 请求参数 - * @param currentUserId 当前用户ID - * @param currentOrgId 当前组织ID - * @return 待办参数 - */ - private BugTodoRequest buildBugToDoParam(BugPageRequest request, String currentUserId, String currentOrgId) { - List msLastStepStatusIds = bugCommonService.getLocalLastStepStatus(request.getProjectId()); - BugTodoRequest todoParam = BugTodoRequest.builder().msUserId(currentUserId).msLastStepStatus(msLastStepStatusIds).build(); - try { - // 设置待办的平台参数 - String platformName = projectApplicationService.getPlatformName(request.getProjectId()); - if (StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { - return todoParam; - } - todoParam.setCurrentPlatform(platformName); - todoParam.setPlatformLastStatus(bugCommonService.getPlatformLastStepStatus(request.getProjectId())); - todoParam.setPlatformUser(bugCommonService.getPlatformHandlerUser(request.getProjectId(), currentUserId, currentOrgId)); - } catch (Exception e) { - // 设置平台参数异常时, 无法正常过滤平台非结束的缺陷 - LogUtils.error(e.getMessage()); - return todoParam; - } - return todoParam; - } }