Skip to content

Commit

Permalink
refact : reply 서비스, 컨트롤러 comment로 병합
Browse files Browse the repository at this point in the history
 - 테스트를 진행하면서 분리되어 있던 대댓글 기능을 CommentController, CommentService로 통합함.
#41
  • Loading branch information
pyuseon committed Apr 4, 2022
1 parent f6fae98 commit e29f760
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,16 @@ public void deleteComment(@PathVariable Long commentId,
userDetails.getUser().getId(),commentId);
commentService.deleteComment(commentId, userDetails);
}



// 대댓글 작성하기
@PostMapping("/comments/{commentId}")
public CommentResponseDto registerReply(@PathVariable Long commentId,
@RequestBody CommentRequestDto requestDto,
@AuthenticationPrincipal UserDetailsImpl userDetails){
log.info("대댓글 작성하기 userId : {} commentId : {}",
userDetails.getUser().getId(),commentId);
return commentService.registerReply(commentId, requestDto, userDetails);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,15 @@ public void deleteComment(Long commentId, UserDetailsImpl userDetails) {
commentRepository.deleteAll(comments);
commentRepository.delete(comment);
}

public CommentResponseDto registerReply(Long commentId, CommentRequestDto requestDto, UserDetailsImpl userDetails) {
Comment comment = PresentCheck.commentIsPresentCheck(commentId, commentRepository);
Comment reply = Comment.commentBuilder()
.portfolio(comment.getPortfolio())
.user(userDetails.getUser())
.content(requestDto.getContent())
.parentComment(comment)
.build();
return CommentResponseDto.builder().commentId(commentRepository.save(reply).getId()).build();
}
}

This file was deleted.

0 comments on commit e29f760

Please sign in to comment.