-
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
Feature/#83 댓글 대댓글 crud api 구현 #97
The head ref may contain hidden characters: "Feature/#83-\uB313\uAE00_\uB300\uB313\uAE00_CRUD_API_\uAD6C\uD604"
Conversation
…023-emmsale into Feature/#83-댓글_대댓글_CRUD_API_구현
- 테스트에서 createdAt, updatedAt을 등록하지 못하기 때문에 null 제약조건 - createdAt, updatedAt 을 nullable 하는 것으로 수정 #83
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.
전체적으로 통일성이 있어서 확인하긴 편했습니다.
몇몇 커멘트 남겼으니 확인해주세요.
final Event savedEvent | ||
) { | ||
final Comment savedComment = commentRepository.save( | ||
new Comment(savedEvent, null, member, commentAddRequest.getContent()) |
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.
요건 취향이긴 한데, 한번 정적팩터리 메서드를 정의해서
RootComment를 만들 때랑 ChildComment 만들 때랑 다른 메서드를 사용하게 하는 것은 어떨까요?
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.
현장 리뷰 완료요~~
commentCommandService.delete(commentId, member); | ||
} | ||
|
||
@PatchMapping("/comments/{comment-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.
comment 내용을 완전히 덮어씌우는 거라면
Put 은 어떤가요?
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.
현장 리뷰 완료요~~
@DisplayName("delete() : 댓글을 삭제할 때, 로그인 한 본인의 댓글이 아니면 CAN_NOT_DELETE_COMMENT 가 발생합니다.") | ||
void test_delete_canNotDeleteComment() throws Exception { | ||
//given | ||
final Member 댓글_작성자 = memberRepository.findById(1L).get(); |
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.
현장 리뷰 완료요~~
new Comment(event2, null, member, "부모댓글1") | ||
); | ||
|
||
final long eventId = 2L; |
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.
나중에 event 관련된 테스트가 생기면 auto_increment 때문에 터질 것 같아요.
event의 getId로 eventId를 세팅하면 어떨까요?
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.
수고하셨습니다!
크게 수정할 점은 보이지 않습니다.
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class CommentCommandService { |
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.
혹시 Command가 나타내는게 Query 이외의 모든 동작인가요? 지금은 Query와 Command밖에 없어서 쉽게 예측이 되지만 더 늘어난다면 Command에 어떤 동작이 있는지 예측하기 어려울 것 같아요.
혹시 CommentWriteService, CommentDeleteService 이런 식으로 나누는건 어떠신가요?
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("/comments/{comment-id}") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void delete(@PathVariable("comment-id") final Long commentId, final Member member) { |
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.
이건 개인적으로 궁금해서 여쭤보는건데 혹시 comment-id로 받으시는 이유가 있으신가요?
commentId로 받으면 PathVariable에 name을 생략할 수 있는데 굳이 comment-id로 받아서 name을 명시한 이유가 있는지 궁금합니다.
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.
현장 리뷰 완료요~~
|
||
private final String content; | ||
|
||
private CommentModifyRequest() { |
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.
혹시 이게 왜 필요한지 알 수 있을까요?
없으면 테스트가 터지는데 다른 Request DTO들은 없어도 되는데 이 친구만 특별하게 있어야 하는 이유가 궁금합니다!
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.
현장 리뷰 완료요~~
@Getter | ||
public class CommentResponse { | ||
|
||
private static final String DELETE_COMMENT_CONTENT = "삭제된 댓글입니다."; |
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.
이 상수가 사용되고 있는 곳을 찾을 수 없는데 혹시 어디서 사용하는 건가요?
isDeleted
를 통해 true
일 경우 이 값으로 대체하는 로직이 빠진걸까요?
"해당 댓글은 존재하지 않습니다." | ||
), | ||
|
||
CAN_NOT_DELETE_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.
이건 개인적인 의견인데 갑자기 생각이 나서 코멘트 달아둡니다.
혹시 NOT_FOUND처럼 FORBIDDEN으로 http 상태 메시지로 통일하는건 어떠신가요?
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.
현장 리뷰 완료요~~
), | ||
|
||
CAN_NOT_MODIFY_DELETED_COMMENT( | ||
HttpStatus.FORBIDDEN, |
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.
이건 인가의 문제가 아니라 클라이언트의 잘못된 요청이므로 BAD_REQUEST가 더 좋을 것 같은데 우르는 어떻게 생각하시나요?
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.
현장 리뷰 완료요~~
@@ -36,6 +38,8 @@ void findAllByMemberId() throws Exception { | |||
.map(MemberActivity::getId) | |||
.collect(toUnmodifiableList()); | |||
|
|||
System.out.println("memberCareerIds.size() = " + memberCareerIds.size()); |
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.
현장 리뷰 완료요~~
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.
수고하셨습니다!
코멘트 몇 개 남겼으니 확인해주시면 감사하겠습니다~
CAN_NOT_MODIFY_COMMENT( | ||
HttpStatus.FORBIDDEN, | ||
"댓글 작성자 외에는 수정할 수 없습니다." | ||
), |
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.
개인적으로 CAN_NOT_DELETE_COMMENT
, CAN_NOT_MODIFY_COMMENT
보다는 INVALID_AUTHORITY
가 원인을 파악하기에 좀 더 직관적일 것 같다는 생각이 듭니다!
final Comment comment = commentRepository.findById(commentId) | ||
.orElseThrow(() -> new CommentException(NOT_FOUND_COMMENT)); | ||
|
||
validateSameWriter(loginMember, comment, CAN_NOT_DELETE_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.
혹시 CAN_NOT_DELETE_COMMENT
예외 타입을 validateSameWriter()
메서드에서 직접 사용하지 않고 매개변수로 넘겨주신 이유가 있나요??
조금 불필요한 작업으로 느껴져서요
@Getter | ||
public class CommentResponse { | ||
|
||
private static final String DELETE_COMMENT_CONTENT = "삭제된 댓글입니다."; |
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.
이제 사용되고 있지 않은 상수인 것 같으니 지워줘도 될 것 같습니다!
- 2L -> event2.getId()
- 2L -> event2.getId()
- parentId가 nullable 하기 때문에 이에 따라서 optional을 사용하여 리팩터링 - 정적 팩터리 메서드 사용으로 생성자 private 로 변경 후 테스트 수정 #83
현장 리뷰 완료 |
#️⃣연관된 이슈
📝작업 내용
댓글 관련 CRUD API 를 구현해습니다.
예상 소요 시간 및 실제 소요 시간
예상 시간 : 수요일 오후 6시
실제 소요 시간 : 수요일 오전 12시
💬리뷰 요구사항
코드 잘 읽히시는지, 제대로 작성된 것 같은지 확인 부탁드립니다.