@@ -68,15 +68,15 @@ public CommentResponseDto createComment(Long postId, CommentCreateRequestDto req
6868 @ Transactional (readOnly = true )
6969 public List <CommentResponseDto > getComments (Long postId , Long lastId ) {
7070 if (lastId == null ) {
71- return commentRepository .findTop10ByPostIdAndStatusNotOrderByIdDesc (postId , CommentStatus . DELETED )
72- .stream ()
73- .map (CommentResponseDto ::new )
74- .toList ();
71+ return commentRepository .findTop10ByPostIdOrderByIdDesc (postId )
72+ .stream ()
73+ .map (CommentResponseDto ::new )
74+ .toList ();
7575 } else {
76- return commentRepository .findTop10ByPostIdAndStatusNotAndIdLessThanOrderByIdDesc (postId , CommentStatus . DELETED , lastId )
77- .stream ()
78- .map (CommentResponseDto ::new )
79- .toList ();
76+ return commentRepository .findTop10ByPostIdAndIdLessThanOrderByIdDesc (postId , lastId )
77+ .stream ()
78+ .map (CommentResponseDto ::new )
79+ .toList ();
8080 }
8181 }
8282
@@ -85,11 +85,6 @@ public List<CommentResponseDto> getComments(Long postId, Long lastId) {
8585 public CommentResponseDto getComment (Long postId , Long commentId ) {
8686 Comment comment = findCommentWithValidation (postId , commentId );
8787
88- // 삭제된 댓글 조회 방지
89- if (comment .getStatus () == CommentStatus .DELETED ) {
90- throw new IllegalArgumentException ("삭제된 댓글입니다." );
91- }
92-
9388 return new CommentResponseDto (comment );
9489 }
9590
@@ -136,17 +131,12 @@ public void deleteComment(Long postId, Long commentId) {
136131 // 댓글과 게시글의 연관관계 검증
137132 private Comment findCommentWithValidation (Long postId , Long commentId ) {
138133 Comment comment = commentRepository .findById (commentId )
139- .orElseThrow (() -> new IllegalArgumentException ("댓글이 존재하지 않습니다. id=" + commentId ));
134+ .orElseThrow (() -> new IllegalArgumentException ("댓글이 존재하지 않습니다. id=" + commentId ));
140135
141136 if (!comment .getPost ().getId ().equals (postId )) {
142137 throw new IllegalStateException ("댓글이 해당 게시글에 속하지 않습니다." );
143138 }
144139
145- // 삭제된 댓글 접근 방지 (수정/삭제 시)
146- if (comment .getStatus () == CommentStatus .DELETED ) {
147- throw new IllegalStateException ("삭제된 댓글은 수정하거나 삭제할 수 없습니다." );
148- }
149-
150140 return comment ;
151141 }
152142}
0 commit comments