diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/SharingCommentController.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/SharingCommentController.java index 1640e17..73ce9d3 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/SharingCommentController.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/SharingCommentController.java @@ -19,9 +19,16 @@ public String postComment(@PathVariable("accountBookId") Long accountBookId, @R } // [가계부 공유] 댓글 수정 - @PutMapping("/{comment_id}") - public String putComment(@PathVariable("comment_id") Long comment_id, @RequestBody ReqSharingCommentDto reqSharingCommentDto) { - sharingCommentService.modifyComment(comment_id, reqSharingCommentDto); + @PutMapping("/{commentId}") + public String putComment(@PathVariable("commentId") Long commentId, @RequestBody ReqSharingCommentDto reqSharingCommentDto) { + sharingCommentService.modifyComment(commentId, reqSharingCommentDto); + return ""; + } + + // [가게부 공유] 댓글 삭제 + @DeleteMapping("/{commentId}") + public String deleteComment(@PathVariable("commentId") Long commentId) { + sharingCommentService.deleteComment(commentId); return ""; } } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/SharingCommentService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/SharingCommentService.java index cb444b2..cd1eb64 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/SharingCommentService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/SharingCommentService.java @@ -56,9 +56,10 @@ public String newComment(Long accountBookId, ReqSharingCommentDto reqSharingComm return "댓글 등록 성공"; } - public String modifyComment(Long comment_id, ReqSharingCommentDto reqSharingCommentDto) { + // [가계부 공유] 댓글 수정 + public String modifyComment(Long commentId, ReqSharingCommentDto reqSharingCommentDto) { // 댓글 찾기 - Optional sharingCommentOptional = sharingCommentRepository.findById(comment_id); + Optional sharingCommentOptional = sharingCommentRepository.findById(commentId); SharingComment sharingComment = sharingCommentOptional.get(); sharingComment.modifyComment(reqSharingCommentDto); @@ -67,4 +68,15 @@ public String modifyComment(Long comment_id, ReqSharingCommentDto reqSharingComm return "댓글 수정 성공"; } + + // [가게부 공유] 댓글 삭제 + public String deleteComment(Long commentId) { + // 댓글 찾기 + Optional sharingCommentOptional = sharingCommentRepository.findById(commentId); + SharingComment sharingComment = sharingCommentOptional.get(); + + sharingCommentRepository.delete(sharingComment); + + return "댓글 삭제 성공"; + } }