Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix : 댓글 삭제 시 게시물의 댓글 수 차감 로직 수정 #151

Merged
merged 2 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,17 @@ public ApiResponse<CommentResponse.CommentProc> writeComment(
@Operation(summary = "댓글 수정 요청", description = "댓글 수정 요청을 PATCH로 보냅니다.")
@Parameter(name = "commentId", description = "댓글 Id, Path Variable입니다.", required = true, example = "1", in = ParameterIn.PATH)
@PatchMapping("/{commentId}")
public ApiResponse<CommentResponse.CommentProc> updateComment(@RequestBody String content,
public ApiResponse<CommentResponse.CommentProc> updateComment(@RequestBody CommentRequest.PATCH request,
@PathVariable(name = "commentId") Long commentId) {

return ApiResponse.onSuccess(commentCommandService.update(content, commentId));
return ApiResponse.onSuccess(commentCommandService.update(request.getContent(), commentId));
}

@Operation(summary = "댓글 삭제 요청", description = "댓글 삭제 요청을 DELETE로 보냅니다.")
@Parameter(name = "commentId", description = "댓글 Id, Path Variable입니다.", required = true, example = "1", in = ParameterIn.PATH)
@DeleteMapping("/{commentId}")
public ApiResponse<CommentResponse.CommentProc> deleteComment(
@PathVariable(name = "commentId") Long commentId) {

return ApiResponse.onSuccess(commentCommandService.delete(commentId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ public static class Post {
private Long parentId;
}

@Schema(description = "게시글 댓글 수정 요청 DTO")
@Getter
public static class PATCH {

@Schema(description = "댓글 내용")
private String content;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public CommentResponse.CommentProc update(String content, Long commentId) {

public CommentResponse.CommentProc delete(Long commentId) {
Comment comment = commentQueryService.findById(commentId);
comment.getBoard().changeComment(false);
Board board = comment.getBoard();
board.changeComment(false);
commentRepository.deleteById(commentId);
return CommentResponse.toCommentProc(commentId);
}
Expand Down