66import com .daramg .server .comment .repository .CommentLikeRepository ;
77import com .daramg .server .comment .repository .CommentRepository ;
88import com .daramg .server .common .application .EntityUtils ;
9+ import com .daramg .server .comment .exception .CommentErrorStatus ;
910import com .daramg .server .common .exception .BusinessException ;
1011import com .daramg .server .post .domain .Post ;
1112import com .daramg .server .notification .domain .NotificationType ;
@@ -31,7 +32,7 @@ public class CommentService {
3132 public void createComment (Long postId , CommentCreateDto request , User user ){
3233 Post post = entityUtils .getEntity (postId , Post .class );
3334 if (post .isBlocked ()){
34- throw new BusinessException ("블락된 포스트에는 댓글을 남길 수 없습니다." );
35+ throw new BusinessException (CommentErrorStatus . BLOCKED_POST );
3536 }
3637
3738 Comment comment = Comment .of (
@@ -53,11 +54,11 @@ public void createComment(Long postId, CommentCreateDto request, User user){
5354 public void createReply (Long commentId , CommentReplyCreateDto request , User user ){
5455 Comment parentComment = entityUtils .getEntity (commentId , Comment .class );
5556 if (parentComment .isDeleted () || parentComment .isBlocked ()){
56- throw new BusinessException ("삭제되었거나 블락된 댓글에는 대댓글을 남길 수 없습니다." );
57+ throw new BusinessException (CommentErrorStatus . BLOCKED_OR_DELETED_COMMENT_REPLY );
5758 }
5859 Post post = parentComment .getPost ();
5960 if (post .isBlocked ()){
60- throw new BusinessException ("블락된 포스트에는 댓글을 남길 수 없습니다." );
61+ throw new BusinessException (CommentErrorStatus . BLOCKED_POST );
6162 }
6263
6364 Comment reply = Comment .of (
@@ -79,7 +80,7 @@ public void createReply(Long commentId, CommentReplyCreateDto request, User user
7980 public CommentLikeResponseDto toggleCommentLike (Long commentId , User user ){
8081 Comment comment = entityUtils .getEntity (commentId , Comment .class );
8182 if (comment .isDeleted () || comment .isBlocked ()){
82- throw new BusinessException ("삭제되었거나 블락된 댓글에는 좋아요를 누를 수 없습니다." );
83+ throw new BusinessException (CommentErrorStatus . BLOCKED_OR_DELETED_COMMENT_LIKE );
8384 }
8485
8586 boolean alreadyLiked = commentLikeRepository
@@ -105,10 +106,10 @@ public void deleteComment(Long commentId, User user){
105106 Comment comment = entityUtils .getEntity (commentId , Comment .class );
106107
107108 if (comment .isDeleted ()){
108- throw new BusinessException ("이미 삭제 처리된 댓글입니다." );
109+ throw new BusinessException (CommentErrorStatus . ALREADY_DELETED );
109110 }
110111 if (comment .getUser () == null || !comment .getUser ().getId ().equals (user .getId ())){
111- throw new BusinessException ("댓글을 작성한 유저만 댓글을 삭제할 수 있습니다." );
112+ throw new BusinessException (CommentErrorStatus . NOT_COMMENT_AUTHOR );
112113 }
113114
114115 comment .softDelete ();
0 commit comments