Skip to content

Commit

Permalink
♻️ refactor: 삭제된 댓글 수정 시도하는 경우 에러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jinho7 committed Aug 17, 2024
1 parent 20a4bfa commit 6ffee95
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public CommentResponseDTO.CommentDTO createComment(Long boardId, CommentRequestD
public CommentResponseDTO.CommentDTO updateComment(Long boardId, Long commentId, CommentRequestDTO.UpdateDTO updateDTO, Member member) {
Comment comment = commentRepository.findById(commentId)
.orElseThrow(() -> new CommentException(CommentErrorCode.COMMENT_NOT_FOUND));
validateCommentOwnership(comment, member);

// 삭제된 댓글 수정 시도 체크
if (comment.isDeleted()) {
throw new CommentException(CommentErrorCode.COMMENT_ALREADY_DELETED);
}

validateCommentOwnership(comment, member);

// 댓글이 해당 게시글에 속하지 않는 경우
if (!comment.getBoard().getId().equals(boardId)) {
throw new CommentException(CommentErrorCode.COMMENT_BOARD_MISMATCH);
Expand Down

0 comments on commit 6ffee95

Please sign in to comment.