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 b246e02fda..c24f7ac116 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 @@ -119,7 +119,7 @@ public class BugController { @Operation(summary = "缺陷管理-列表-查看缺陷(详情&&编辑&&复制)") @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) public BugDetailDTO get(@PathVariable String id) { - return bugService.get(id); + return bugService.get(id, SessionUtils.getUserId()); } @GetMapping("/delete/{id}") diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugDetailDTO.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugDetailDTO.java index d5f3e7b81b..7f3603fbbe 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugDetailDTO.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugDetailDTO.java @@ -43,6 +43,9 @@ public class BugDetailDTO { @Schema(description = "是否平台默认模板") private Boolean platformDefault; + @Schema(description = "是否关注") + private Boolean followFlag; + @Schema(description = "附件集合") List attachments; } 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 49918f9d35..3c98fbf4a9 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 @@ -242,7 +242,7 @@ public class BugService { * @param id 缺陷ID * @return 缺陷详情 */ - public BugDetailDTO get(String id) { + public BugDetailDTO get(String id, String currentUser) { Bug bug = checkBugExist(id); TemplateDTO template = getTemplate(bug.getTemplateId(), bug.getProjectId(), null, null); List allCustomFields = extBugCustomFieldMapper.getBugAllCustomFields(List.of(id), bug.getProjectId()); @@ -288,6 +288,10 @@ public class BugService { detail.setCustomFields(allCustomFields); // 缺陷附件信息 detail.setAttachments(bugAttachmentService.getAllBugFiles(id)); + // 当前登录人是否关注该缺陷 + BugFollowerExample example = new BugFollowerExample(); + example.createCriteria().andBugIdEqualTo(id).andUserIdEqualTo(currentUser); + detail.setFollowFlag(bugFollowerMapper.countByExample(example) > 0); return detail; }