We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6d5c6eb commit 9dc920fCopy full SHA for 9dc920f
src/main/java/targeter/aim/domain/post/service/CommentService.java
@@ -62,6 +62,10 @@ public CommentDto.CommentCreateResponse createComment(
62
Comment parent = commentRepository.findById(parentCommentId)
63
.orElseThrow(() -> new RestException(ErrorCode.GLOBAL_NOT_FOUND, "부모 댓글을 찾을 수 없습니다."));
64
65
+ if (parent.getPost() == null || !parent.getPost().getId().equals(postId)) {
66
+ throw new RestException(ErrorCode.GLOBAL_BAD_REQUEST, "부모 댓글이 해당 게시글에 속하지 않습니다.");
67
+ }
68
+
69
if(parent.getParent() != null || parent.getDepth() == null || parent.getDepth() != 1 ) {
70
throw new RestException(ErrorCode.GLOBAL_BAD_REQUEST, "대댓글 아래에 대댓글을 작성할 수 없습니다.");
71
}
0 commit comments