Skip to content

Commit

Permalink
✨ Feat #18 : 댓글 삭제 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Suanna01 committed Jul 23, 2023
1 parent bb263f1 commit d546827
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<SharingComment> sharingCommentOptional = sharingCommentRepository.findById(comment_id);
Optional<SharingComment> sharingCommentOptional = sharingCommentRepository.findById(commentId);
SharingComment sharingComment = sharingCommentOptional.get();

sharingComment.modifyComment(reqSharingCommentDto);
Expand All @@ -67,4 +68,15 @@ public String modifyComment(Long comment_id, ReqSharingCommentDto reqSharingComm

return "댓글 수정 성공";
}

// [가게부 공유] 댓글 삭제
public String deleteComment(Long commentId) {
// 댓글 찾기
Optional<SharingComment> sharingCommentOptional = sharingCommentRepository.findById(commentId);
SharingComment sharingComment = sharingCommentOptional.get();

sharingCommentRepository.delete(sharingComment);

return "댓글 삭제 성공";
}
}

0 comments on commit d546827

Please sign in to comment.