diff --git a/backend/framework/sdk/src/main/resources/i18n/case.properties b/backend/framework/sdk/src/main/resources/i18n/case.properties index 12154ed533..fa8e318fb9 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case.properties @@ -133,6 +133,7 @@ case_comment.parent_id_is_null=当前回复的评论id为空 case_comment.parent_case_is_null=当前回复的评论不存在 case_comment.reply_user_is_null=回复的用户为空 case_comment.id_is_null=当前评论id为空 +case_comment.user_self=只能删除自己的评论 #module case_module.not.exist=用例模块不存在 #case @@ -148,3 +149,6 @@ case_review.multiple=多人评审 case_review.not.exist=用例评审不存在 case_review_content.not.exist = 评审意见不能为空 case_review_history.system=系统触发 +#minder +case.minder.all.case=全部用例 + diff --git a/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties index 488d655eb1..f0840f3f4d 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties @@ -147,6 +147,7 @@ case_comment.parent_id_is_null=The comment id of the current reply is empty case_comment.parent_case_is_null=The comment currently being replied to does not exist case_comment.reply_user_is_null=The user who replied is empty case_comment.id_is_null=The current comment id is empty +case_comment.user_self=You can only delete your own comments un_follow_functional_case=unfollow functional case follow_functional_case=followed functional case #module @@ -167,4 +168,6 @@ case_review_content.not.exist = Review comments cannot be empty case_review_history.system=System trigger case_review.viewFlag.not_blank=View flag cannot be empty functional_case_relationship_edge.type.not_blank=Relationship type cannot be empty -cycle_relationship=There is a circular dependency after association, please check the dependency relationship \ No newline at end of file +cycle_relationship=There is a circular dependency after association, please check the dependency relationship +#minder +case.minder.all.case=All Case \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties index e4f9d79151..63c5d8c970 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties @@ -146,6 +146,7 @@ case_comment.parent_id_is_null=当前回复的评论id为空 case_comment.parent_case_is_null=当前回复的评论不存在 case_comment.reply_user_is_null=回复的用户为空 case_comment.id_is_null=当前评论id为空 +case_comment.user_self=只能删除自己的评论 un_follow_functional_case=取消关注用例 follow_functional_case=关注用例 #module @@ -167,3 +168,5 @@ case_review_history.system=系统触发 case_review.viewFlag.not_blank=查看标识不能为空 functional_case_relationship_edge.type.not_blank=类型不能为空 cycle_relationship=关联后存在循环依赖,请检查依赖关系 +#minder +case.minder.all.case=全部用例 diff --git a/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties index 8d0fac94d2..6a921b7d9a 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties @@ -147,6 +147,7 @@ case_comment.parent_id_is_null=目前回覆的評論id為空 case_comment.parent_case_is_null=目前回應的評論不存在 case_comment.reply_user_is_null=回覆的用戶為空 case_comment.id_is_null=目前評論id為空 +case_comment.user_self=只能刪除自己的評論 un_follow_functional_case=取消關注用例 follow_functional_case=關注用例 #module @@ -167,4 +168,6 @@ case_review_content.not.exist = 評審意見不能為空 case_review_history.system=系統觸發 case_review.viewFlag.not_blank=查看標誌不能為空 functional_case_relationship_edge.type.not_blank=類型不能為空 -cycle_relationship=關聯后存在循環依賴,請檢查依賴關係 \ No newline at end of file +cycle_relationship=關聯后存在循環依賴,請檢查依賴關係 +#minder +case.minder.all.case=全部用例 diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseCommentController.java b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseCommentController.java index a082b9116f..c582459630 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseCommentController.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseCommentController.java @@ -46,7 +46,7 @@ public class FunctionalCaseCommentController { @Operation(summary = "用例管理-功能用例-用例评论-删除评论") @RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_COMMENT) public void deleteComment(@PathVariable String commentId) { - functionalCaseCommentService.deleteComment(commentId); + functionalCaseCommentService.deleteComment(commentId, SessionUtils.getUserId()); } @GetMapping("/get/list/{caseId}") diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java index b7d4a2ef2e..fc2e41c380 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCommentService.java @@ -213,11 +213,15 @@ public class FunctionalCaseCommentService { return relatedUserList; } - public void deleteComment(String commentId) { + public void deleteComment(String commentId, String userId) { FunctionalCaseComment functionalCaseComment = functionalCaseCommentMapper.selectByPrimaryKey(commentId); if (functionalCaseComment == null) { return; } + //只有评论人自己可以删除当前评论 + if (!StringUtils.equalsIgnoreCase(functionalCaseComment.getCreateUser(), userId)) { + throw new MSException(Translator.get("case_comment.user_self")); + } //删除选中的评论下的所有回复 FunctionalCaseCommentExample functionalCaseCommentExample = new FunctionalCaseCommentExample(); functionalCaseCommentExample.createCriteria().andParentIdEqualTo(commentId); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java index 775962dd13..d5d1549340 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java @@ -468,6 +468,15 @@ public class FunctionalCaseCommentControllerTests { } + @Test + @Order(22) + public void deleteCommentUser() throws Exception { + delFunctionalCaseCommentError(); + FunctionalCaseComment functionalCaseComment = functionalCaseCommentMapper.selectByPrimaryKey("user_not_exist"); + Assertions.assertNotNull(functionalCaseComment); + + } + private FunctionalCaseComment getFunctionalCaseComment(FunctionalCaseCommentRequest functionalCaseCommentRequest, String url) throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post(url).header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken) @@ -490,6 +499,15 @@ public class FunctionalCaseCommentControllerTests { .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); } + private void delFunctionalCaseCommentError() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get(DELETE_URL+ "user_not_exist").header(SessionConstants.HEADER_TOKEN, sessionId) + .header(SessionConstants.CSRF_TOKEN, csrfToken) + .header(SessionConstants.CURRENT_PROJECT, projectId) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is5xxServerError()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)); + } + private FunctionalCaseComment getFunctionalCaseComment() { FunctionalCaseCommentExample functionalCaseCommentExample = new FunctionalCaseCommentExample(); functionalCaseCommentExample.createCriteria().andCaseIdEqualTo("xiaomeinvGTest"); diff --git a/backend/services/case-management/src/test/resources/dml/init_case_comment.sql b/backend/services/case-management/src/test/resources/dml/init_case_comment.sql index 9791eff5a3..b4a97c90ea 100644 --- a/backend/services/case-management/src/test/resources/dml/init_case_comment.sql +++ b/backend/services/case-management/src/test/resources/dml/init_case_comment.sql @@ -142,5 +142,8 @@ VALUES (UUID(), 'default-project-member-user-guo', 'project_admin', 'project-cas INSERT INTO user_role_permission(id, role_id, permission_id) VALUES ('user_role_guo_permission1', 'project_admin', 'FUNCTIONAL_CASE:READ+COMMENT'); +INSERT INTO functional_case_comment(id, case_id, create_user, parent_id, resource_id, notifier, content, reply_user, create_time, update_time) +VALUES ('user_not_exist', 'comment_case', 'gyq', 'NONE', null, 'gyq;', '', null,UNIX_TIMESTAMP() * 1000,UNIX_TIMESTAMP() * 1000); +