Skip to content

Commit

Permalink
Merge pull request #169 from CSID-DGU/backend/feature/community
Browse files Browse the repository at this point in the history
BE: [feat] 대댓글 엔드포인트 추가 #36
  • Loading branch information
Seoyoung2222 authored Dec 7, 2024
2 parents c3aa865 + 6115dae commit 0bd9213
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ public class CommentController {
public ResponseEntity<Long> createComment(@PathVariable String boardName, @PathVariable Long postId, @RequestBody CommentCreateRequestDto requestDto) {
requestDto.setPostId(postId);
Long commentId = commentCommandService.createComment(requestDto);
return ResponseEntity.ok(commentId);
return ResponseEntity.ok(postId);
}

@PostMapping("/{commentId}/reply")
public ResponseEntity<Long> createReply(@PathVariable String boardName,@PathVariable Long postId,@PathVariable Long commentId, @RequestBody CommentCreateRequestDto requestDto) {
requestDto.setPostId(postId);
requestDto.setParentCommentId(commentId);
Long replyId = commentCommandService.createComment(requestDto);
return ResponseEntity.ok(postId);
}

@PostMapping("/{commentId}/like")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public class CommentCreateRequestDto {
public void setPostId(Long postId) {
this.postId = postId;
}
public void setParentCommentId(Long parentCommentId) {
this.parentCommentId = parentCommentId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ public class CommentResponseDto {
private LocalDateTime createdAt;
private List<CommentResponseDto> replies;
private int likeCount;
private String writerProfileUrl;

public static CommentResponseDto from(Comment comment) {
return CommentResponseDto.builder()
.commentId(comment.getId())
.writerNickname(comment.getUser().getNickname())
.writerProfileUrl(comment.getUser().getProfileImageUrl())
.content(comment.getContent())
.createdAt(comment.getCreatedAt())
.replies(comment.getReplies().stream()
Expand Down

0 comments on commit 0bd9213

Please sign in to comment.