Skip to content

Commit 9dc920f

Browse files
authored
feat: QnA/후기 댓글 작성 및 조회 기능 구현 (#69)
1 parent 6d5c6eb commit 9dc920f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/targeter/aim/domain/post/service/CommentService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public CommentDto.CommentCreateResponse createComment(
6262
Comment parent = commentRepository.findById(parentCommentId)
6363
.orElseThrow(() -> new RestException(ErrorCode.GLOBAL_NOT_FOUND, "부모 댓글을 찾을 수 없습니다."));
6464

65+
if (parent.getPost() == null || !parent.getPost().getId().equals(postId)) {
66+
throw new RestException(ErrorCode.GLOBAL_BAD_REQUEST, "부모 댓글이 해당 게시글에 속하지 않습니다.");
67+
}
68+
6569
if(parent.getParent() != null || parent.getDepth() == null || parent.getDepth() != 1 ) {
6670
throw new RestException(ErrorCode.GLOBAL_BAD_REQUEST, "대댓글 아래에 대댓글을 작성할 수 없습니다.");
6771
}

0 commit comments

Comments
 (0)