-
Notifications
You must be signed in to change notification settings - Fork 2
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
[feat] 게시글 댓글 등록, 삭제 #64
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
댓글삭제 컨트롤러 부분 우선적으로 확인 부탁드립니다! 고생하셨습니다~!
@DeleteMapping(value="/posts/{id}/comment") | ||
public ResponseEntity deleteComment(@PathVariable("id") Long id){ | ||
commentService.delete(id); | ||
return ResponseEntity.ok(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삭제되었을때 상태코드 같이 리턴해주시면 좋을 것 같습니다!
} | ||
|
||
//댓글 삭제 | ||
@DeleteMapping(value="/posts/{id}/comment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url 의미가 조금 맞지 않아 수정이 필요해 보입니다. 컨트롤러에 맵핑된 id (파라미터로 받은 id) 는 게시글 id 인데, 실제 서비스에서 삭제하는 id 는 댓글 id 입니다.
컨트롤러 url 을 /posts/{post-id}/comments/{comment-id}
등으로 수정하면 좋을 것 같습니다!
@Transactional | ||
public void delete(Long id) { | ||
Comment comment = commentRepository.findById(id).orElseThrow(() -> | ||
new IllegalArgumentException("존재하지 않는 댓글입니다. id=" + id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
에러가 로그상에만 떨어지고 있는데 리턴값으로도 에러메세지나 상태코드를 넘겨주면 프론트에서 처리하기 좋을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commentService.delete(id); | ||
return ResponseEntity.ok(id); | ||
@DeleteMapping(value="/posts/{post-id}/comment/{comment-id}") | ||
public ResultResponse deleteComment(@PathVariable("post-id")Long PostId,@PathVariable("comment-id") Long CommentId){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변수명 첫글자는 소문자로 작성하면 좋을 듯 합니다!
post /posts/{id}/comment
댓글 등록 - 성공
댓글 등록 - 에러 : 100글자 이상 등록한 경우
delete /posts/{id}/comment
댓글 삭제