From 0f24d581b074bc76b604253420795f9193d72c2a Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Thu, 18 Jan 2024 15:47:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=BC=BA=E9=99=B7=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BC=BA=E9=99=B7=E7=AE=A1=E7=90=86=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=97=A5=E5=BF=97=E5=8E=86=E5=8F=B2=E5=8F=8A=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/i18n/project.properties | 1 + .../resources/i18n/project_en_US.properties | 1 + .../resources/i18n/project_zh_CN.properties | 1 + .../resources/i18n/project_zh_TW.properties | 1 + .../bug/controller/BugCommentController.java | 15 ++ .../bug/controller/BugController.java | 144 ++++++++++-------- .../controller/BugRelateCaseController.java | 4 + .../bug/controller/BugTrashController.java | 7 + .../bug/dto/response/BugRelateCaseDTO.java | 12 +- .../bug/enums/BugAttachmentSourceType.java | 4 +- .../bug/mapper/ExtBugRelateCaseMapper.java | 9 ++ .../bug/mapper/ExtBugRelateCaseMapper.xml | 13 +- .../bug/service/BugCommentService.java | 6 +- .../bug/service/BugLogService.java | 124 +++++++++++++++ .../bug/service/BugNoticeService.java | 73 +++++++++ .../service/BugRelateCaseCommonService.java | 1 + .../bug/service/BugRelateCaseLogService.java | 40 +++++ .../metersphere/bug/service/BugService.java | 127 +++++++++++++-- .../bug/service/BugSyncNoticeService.java | 40 +++++ .../bug/service/BugSyncService.java | 15 +- .../bug/service/XpackBugService.java | 3 +- .../bug/controller/BugControllerTests.java | 18 ++- .../BugRelateCaseControllerTests.java | 2 +- .../bug/mock/XpackBugMockServiceImpl.java | 2 +- .../src/test/resources/dml/init_bug_trash.sql | 2 + .../service/NoticeTemplateService.java | 12 +- .../service/ProjectApplicationService.java | 28 ++-- .../ProjectApplicationControllerTests.java | 6 +- .../metersphere/system/dto/BugNoticeDTO.java | 47 ++++++ .../system/dto/BugSyncNoticeDTO.java | 47 ++++++ .../notice/constants/NoticeConstants.java | 3 + .../notice/utils/MessageTemplateUtils.java | 8 +- 32 files changed, 691 insertions(+), 125 deletions(-) create mode 100644 backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java create mode 100644 backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugNoticeService.java create mode 100644 backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugRelateCaseLogService.java create mode 100644 backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugSyncNoticeService.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/BugNoticeDTO.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/BugSyncNoticeDTO.java diff --git a/backend/framework/sdk/src/main/resources/i18n/project.properties b/backend/framework/sdk/src/main/resources/i18n/project.properties index c2979b6891..a416da056f 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project.properties @@ -184,6 +184,7 @@ message.execute_fail=执行不通过 message.execute_at=执行被@ message.open=开启 message.close=关闭 +message.sync_completed=同步完成 message.create_user=创建人 message.follow_people=关注人 message.operator=操作人 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties index cb2d0e9d9a..98e3749ff2 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties @@ -220,6 +220,7 @@ message.execute_fail=Execution failed message.execute_at=Execution is @ message.open=turn on message.close=closure +message.sync_completed=Sync completed message.create_user=Create user message.follow_people=Follow people message.operator=Operator diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties index 0afbb06a68..72eb47f37d 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties @@ -220,6 +220,7 @@ message.execute_fail=执行不通过 message.execute_at=执行被@ message.open=开启 message.close=关闭 +message.sync_completed=同步完成 message.create_user=创建人 message.follow_people=关注人 message.operator=操作人 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties index e7f2e17384..7566d88424 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties @@ -220,6 +220,7 @@ message.execute_fail=執行不通過 message.execute_at=執行被@ message.open=開啟 message.close=關閉 +message.sync_completed=同步完成 message.create_user=創建人 message.follow_people=關注人 message.operator=操作人 diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugCommentController.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugCommentController.java index 744302ab9a..ccd3fa6de2 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugCommentController.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugCommentController.java @@ -4,9 +4,13 @@ import io.metersphere.bug.domain.BugComment; import io.metersphere.bug.dto.request.BugCommentEditRequest; import io.metersphere.bug.dto.response.BugCommentDTO; import io.metersphere.bug.service.BugCommentService; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.security.CheckOwner; 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.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -20,21 +24,32 @@ public class BugCommentController { private BugCommentService bugCommentService; @GetMapping("/get/{bugId}") + @Operation(summary = "缺陷管理-评论-获取评论") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#bugId", resourceType = "bug") public List get(@PathVariable String bugId) { return bugCommentService.getComments(bugId); } @PostMapping("/add") + @Operation(summary = "缺陷管理-评论-新增评论") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#request.getBugId()", resourceType = "bug") public BugComment add(@RequestBody BugCommentEditRequest request) { return bugCommentService.addComment(request, SessionUtils.getUserId()); } @PostMapping("/update") + @Operation(summary = "缺陷管理-评论-编辑评论") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#request.getBugId()", resourceType = "bug") public BugComment update(@RequestBody BugCommentEditRequest request) { return bugCommentService.updateComment(request, SessionUtils.getUserId()); } @GetMapping("/delete/{commentId}") + @Operation(summary = "缺陷管理-评论-删除评论") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) public void delete(@PathVariable String commentId) { bugCommentService.deleteComment(commentId); } 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 21670166bd..4fda08eae3 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 @@ -6,9 +6,7 @@ import io.metersphere.bug.constants.BugExportColumns; import io.metersphere.bug.dto.BugSyncResult; import io.metersphere.bug.dto.request.*; import io.metersphere.bug.dto.response.BugDTO; -import io.metersphere.bug.service.BugService; -import io.metersphere.bug.service.BugStatusService; -import io.metersphere.bug.service.BugSyncService; +import io.metersphere.bug.service.*; import io.metersphere.plugin.platform.dto.SelectOption; import io.metersphere.project.dto.ProjectTemplateOptionDTO; import io.metersphere.project.service.ProjectTemplateService; @@ -16,6 +14,11 @@ import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.TemplateScene; import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO; import io.metersphere.system.dto.sdk.TemplateDTO; +import io.metersphere.system.log.annotation.Log; +import io.metersphere.system.log.constants.OperationLogType; +import io.metersphere.system.notice.annotation.SendNotice; +import io.metersphere.system.notice.constants.NoticeConstants; +import io.metersphere.system.security.CheckOwner; import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; @@ -51,29 +54,33 @@ public class BugController { private ProjectTemplateService projectTemplateService; @GetMapping("/header/custom-field/{projectId}") - @Operation(summary = "缺陷管理-获取表头自定义字段") + @Operation(summary = "缺陷管理-列表-获取表头自定义字段") @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#projectId", resourceType = "project") public List getHeaderFields(@PathVariable String projectId) { return bugService.getHeaderCustomFields(projectId); } @GetMapping("/header/status-option/{projectId}") - @Operation(summary = "缺陷管理-获取表头状态选项") + @Operation(summary = "缺陷管理-列表-获取表头状态选项") @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#projectId", resourceType = "project") public List getHeaderStatusOption(@PathVariable String projectId) { return bugStatusService.getHeaderStatusOption(projectId); } @GetMapping("/header/handler-option/{projectId}") - @Operation(summary = "缺陷管理-获取表头处理人选项") + @Operation(summary = "缺陷管理-列表-获取表头处理人选项") @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#projectId", resourceType = "project") public List getHeaderHandleOption(@PathVariable String projectId) { return bugService.getHeaderHandlerOption(projectId); } @PostMapping("/page") - @Operation(summary = "缺陷管理-获取缺陷列表") + @Operation(summary = "缺陷管理-列表-分页缺陷列表") @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public Pager> page(@Validated @RequestBody BugPageRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); @@ -82,104 +89,121 @@ public class BugController { } @PostMapping("/add") - @Operation(summary = "缺陷管理-创建缺陷") + @Operation(summary = "缺陷管理-列表-创建缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_ADD) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + @Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request, #files)", msClass = BugLogService.class) + @SendNotice(taskType = NoticeConstants.TaskType.BUG_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getNoticeByRequest(#request)", targetClass = BugNoticeService.class) public void add(@Validated({Created.class}) @RequestPart(value = "request") BugEditRequest request, @RequestPart(value = "file", required = false) List files) { bugService.addOrUpdate(request, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), false); } @PostMapping("/update") - @Operation(summary = "缺陷管理-更新缺陷") + @Operation(summary = "缺陷管理-列表-编辑缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request, #files)", msClass = BugLogService.class) + @SendNotice(taskType = NoticeConstants.TaskType.BUG_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getNoticeByRequest(#request)", targetClass = BugNoticeService.class) public void update(@Validated({Updated.class}) @RequestPart(value = "request") BugEditRequest request, @RequestPart(value = "file", required = false) List files) { bugService.addOrUpdate(request, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), true); } @GetMapping("/delete/{id}") - @Operation(summary = "缺陷管理-删除缺陷") + @Operation(summary = "缺陷管理-列表-删除缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_DELETE) + @Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = BugLogService.class) + @SendNotice(taskType = NoticeConstants.TaskType.BUG_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getNoticeById(#id)", targetClass = BugNoticeService.class) public void delete(@PathVariable String id) { - bugService.delete(id); + bugService.delete(id, SessionUtils.getUserId()); } - @GetMapping("/template/option") - @Operation(summary = "缺陷管理-获取当前项目缺陷模板选项") - @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) - public List getTemplateOption(@RequestParam(value = "projectId") String projectId) { - return projectTemplateService.getOption(projectId, TemplateScene.BUG.name()); + @GetMapping("/sync/{projectId}") + @Operation(summary = "缺陷管理-列表-同步缺陷(开源)") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @CheckOwner(resourceId = "#projectId", resourceType = "project") + public void sync(@PathVariable String projectId) { + bugSyncService.syncBugs(projectId, SessionUtils.getUserId()); } - @PostMapping("/template/detail") - @Operation(summary = "缺陷管理-获取模板详情内容") + @PostMapping("/sync/all") + @Operation(summary = "缺陷管理-列表-同步缺陷(全量)") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + public void syncAll(@RequestBody BugSyncRequest request) { + bugSyncService.syncAllBugs(request, SessionUtils.getUserId()); + } + + @GetMapping("/sync/check/{projectId}") + @Operation(summary = "缺陷管理-列表-同步状态校验") @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) - public TemplateDTO getTemplateDetail(@RequestBody BugTemplateRequest request) { - return bugService.getTemplate(request.getId(), request.getProjectId(), request.getFromStatusId(), request.getPlatformBugKey()); + @CheckOwner(resourceId = "#projectId", resourceType = "project") + public BugSyncResult checkStatus(@PathVariable String projectId) { + return bugSyncService.checkSyncStatus(projectId); + } + + @GetMapping("/export/columns/{projectId}") + @Operation(summary = "缺陷管理-列表-获取导出字段配置") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT) + @CheckOwner(resourceId = "#projectId", resourceType = "project") + public BugExportColumns getExportColumns(@PathVariable String projectId) { + return bugService.getExportColumns(projectId); + } + + @PostMapping("/export") + @Operation(summary = "缺陷管理-列表-批量导出缺陷") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + public ResponseEntity export(@Validated @RequestBody BugExportRequest request) throws Exception { + return bugService.export(request); } @PostMapping("/batch-delete") - @Operation(summary = "缺陷管理-批量删除缺陷") + @Operation(summary = "缺陷管理-列表-批量删除缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_DELETE) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public void batchDelete(@Validated @RequestBody BugBatchRequest request) { request.setUseTrash(false); - bugService.batchDelete(request); + bugService.batchDelete(request, SessionUtils.getUserId()); } @PostMapping("/batch-update") - @Operation(summary = "缺陷管理-批量编辑缺陷") + @Operation(summary = "缺陷管理-列表-批量编辑缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public void batchUpdate(@Validated @RequestBody BugBatchUpdateRequest request) { request.setUseTrash(false); bugService.batchUpdate(request, SessionUtils.getUserId()); } + @GetMapping("/template/option/{projectId}") + @Operation(summary = "缺陷管理-详情-获取当前项目模板选项") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#projectId", resourceType = "project") + public List getTemplateOption(@PathVariable String projectId) { + return projectTemplateService.getOption(projectId, TemplateScene.BUG.name()); + } + + @PostMapping("/template/detail") + @Operation(summary = "缺陷管理-详情-获取模板详情内容") + @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + public TemplateDTO getTemplateDetail(@RequestBody BugTemplateRequest request) { + return bugService.getTemplate(request.getId(), request.getProjectId(), request.getFromStatusId(), request.getPlatformBugKey()); + } + @GetMapping("/follow/{id}") - @Operation(summary = "缺陷管理-关注缺陷") + @Operation(summary = "缺陷管理-详情-关注缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) public void follow(@PathVariable String id) { bugService.follow(id, SessionUtils.getUserId()); } @GetMapping("/unfollow/{id}") - @Operation(summary = "缺陷管理-取消关注缺陷") + @Operation(summary = "缺陷管理-详情-取消关注缺陷") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) public void unfollow(@PathVariable String id) { bugService.unfollow(id, SessionUtils.getUserId()); } - - @GetMapping("/sync/{projectId}") - @Operation(summary = "缺陷管理-同步缺陷(开源)") - @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) - public void sync(@PathVariable String projectId) { - bugSyncService.syncBugs(projectId); - } - - @PostMapping("/sync/all") - @Operation(summary = "缺陷管理-同步缺陷(全量)") - @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) - public void syncAll(@RequestBody BugSyncRequest request) { - bugSyncService.syncAllBugs(request); - } - - @GetMapping("/sync/check/{projectId}") - @Operation(summary = "缺陷管理-同步状态校验") - @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) - public BugSyncResult checkStatus(@PathVariable String projectId) { - return bugSyncService.checkSyncStatus(projectId); - } - - @GetMapping("/export/columns/{projectId}") - @Operation(summary = "缺陷管理-获取导出字段配置") - @RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT) - public BugExportColumns getExportColumns(@PathVariable String projectId) { - return bugService.getExportColumns(projectId); - } - - @PostMapping("/export") - @Operation(summary = "缺陷管理-批量导出缺陷") - @RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT) - public ResponseEntity export(@Validated @RequestBody BugExportRequest request) throws Exception { - return bugService.export(request); - } } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugRelateCaseController.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugRelateCaseController.java index cfc50a19b0..4c24777268 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugRelateCaseController.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugRelateCaseController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import io.metersphere.bug.dto.request.BugRelatedCasePageRequest; import io.metersphere.bug.dto.response.BugRelateCaseDTO; import io.metersphere.bug.service.BugRelateCaseCommonService; +import io.metersphere.bug.service.BugRelateCaseLogService; import io.metersphere.dto.TestCaseProviderDTO; import io.metersphere.provider.BaseAssociateCaseProvider; import io.metersphere.request.AssociateCaseModuleRequest; @@ -12,6 +13,8 @@ import io.metersphere.request.AssociateOtherCaseRequest; import io.metersphere.request.TestCasePageProviderRequest; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.metersphere.system.log.annotation.Log; +import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.security.CheckOwner; import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; @@ -80,6 +83,7 @@ public class BugRelateCaseController { @GetMapping("/un-relate/{id}") @Operation(description = "缺陷管理-关联用例-取消关联用例") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @Log(type = OperationLogType.DISASSOCIATE, expression = "#msClass.getRelateLog(#id)", msClass = BugRelateCaseLogService.class) public void unRelate(@PathVariable String id) { bugRelateCaseCommonService.unRelate(id); } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugTrashController.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugTrashController.java index 7552671721..8491ce28a4 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugTrashController.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/controller/BugTrashController.java @@ -5,8 +5,12 @@ import com.github.pagehelper.PageHelper; import io.metersphere.bug.dto.request.BugBatchRequest; import io.metersphere.bug.dto.request.BugPageRequest; import io.metersphere.bug.dto.response.BugDTO; +import io.metersphere.bug.service.BugLogService; import io.metersphere.bug.service.BugService; import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.log.annotation.Log; +import io.metersphere.system.log.constants.OperationLogType; +import io.metersphere.system.security.CheckOwner; import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.swagger.v3.oas.annotations.Operation; @@ -40,6 +44,7 @@ public class BugTrashController { @GetMapping("/recover/{id}") @Operation(summary = "回收站-恢复") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @Log(type = OperationLogType.RECOVER, expression = "#msClass.recoverLog(#id)", msClass = BugLogService.class) public void recover(@PathVariable String id) { bugService.recover(id); } @@ -54,6 +59,7 @@ public class BugTrashController { @PostMapping("/batch-recover") @Operation(summary = "回收站-批量恢复") @RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public void batchRecover(@Validated @RequestBody BugBatchRequest request) { request.setUseTrash(true); bugService.batchRecover(request); @@ -62,6 +68,7 @@ public class BugTrashController { @PostMapping("/batch-delete") @Operation(summary = "回收站-批量彻底删除") @RequiresPermissions(PermissionConstants.PROJECT_BUG_DELETE) + @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public void batchDelete(@Validated @RequestBody BugBatchRequest request) { request.setUseTrash(true); bugService.batchDeleteTrash(request); diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugRelateCaseDTO.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugRelateCaseDTO.java index a4412fba7d..8c1fb8aa55 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugRelateCaseDTO.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/response/BugRelateCaseDTO.java @@ -1,17 +1,19 @@ package io.metersphere.bug.dto.response; -import io.metersphere.functional.domain.FunctionalCase; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) -public class BugRelateCaseDTO extends FunctionalCase { +public class BugRelateCaseDTO{ @Schema(description = "关联ID") private String relateId; + @Schema(description = "关联用例名称") + private String relateCaseName; + @Schema(description = "关联类型") private String relateCaseType; @@ -29,4 +31,10 @@ public class BugRelateCaseDTO extends FunctionalCase { @Schema(description = "版本名称") private String versionName; + + @Schema(description = "项目ID") + private String projectId; + + @Schema(description = "版本ID") + private String versionId; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/enums/BugAttachmentSourceType.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/enums/BugAttachmentSourceType.java index dbdf8b32bf..3bb8d7a464 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/enums/BugAttachmentSourceType.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/enums/BugAttachmentSourceType.java @@ -7,7 +7,7 @@ public enum BugAttachmentSourceType { */ ATTACHMENT, /** - * MarkDown编辑器 + * MD图片 */ - MD; + MD_PIC; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java index 5938774ea7..f3c99e09a7 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java @@ -50,5 +50,14 @@ public interface ExtBugRelateCaseMapper { */ List list(@Param("request") BugRelatedCasePageRequest request); + /** + * 根据CaseId获取关联的Case + * @param id 用例ID + * @param sourceType 用例类型 + * @return 用例关联DTO + */ + BugRelateCaseDTO getRelateCase(@Param("id") String id, @Param("sourceType") String sourceType); + + List getAssociateBugs(@Param("request") AssociateBugPageRequest request, @Param("sort") String sort); } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml index cd1126fec4..94a2e41836 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml @@ -46,7 +46,7 @@ + +