From d5468273582f762b43f8a901f5f19b3cacbfdaeb Mon Sep 17 00:00:00 2001 From: sungone <20200999@sungshin.ac.kr> Date: Sun, 23 Jul 2023 22:41:45 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Feat=20#18=20:=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SharingCommentController.java | 13 ++++++++++--- .../sharing/service/SharingCommentService.java | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) 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 "댓글 삭제 성공"; + } }