Skip to content

[14주차] 김지나 학습 PR 제출합니다.#4

Open
jina4066 wants to merge 1 commit intoCOW-edu:mainfrom
jina4066:main
Open

[14주차] 김지나 학습 PR 제출합니다.#4
jina4066 wants to merge 1 commit intoCOW-edu:mainfrom
jina4066:main

Conversation

@jina4066
Copy link
Copy Markdown

@jina4066 jina4066 commented Jan 2, 2024

image


commentService.create(commentCreateRequest);

return ResponseEntity.ok().build();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post 요청으로 자원이 생성되었으니, ok(200)보다는 created(201)가 더 적합할 것 같네요!

Comment on lines +16 to +22
public Comment toEntity(Member member, Post post) {
return Comment.builder()
.member(member)
.post(post)
.content(this.content)
.build();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +17 to +19
public static CommentResponse from(Comment comment) {
return new CommentResponse(comment.getId(), comment.getContent());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +52 to +54
return comments.stream()
.map(CommentResponse::from)
.collect(Collectors.toList());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

public List<CommentResponse> findAll() {
List<Comment> comments = commentRepository.findAll();
if (comments.isEmpty()) {
throw new NoSuchElementException("댓글이 존재하지 않습니다.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

댓글이 존재하지 않을 때, 예외를 던지는 것과 빈 배열은 반환하는 것 중 뭐가 더 적합할지 생각해보면 좋을 것 같습니다!

Copy link
Copy Markdown
Member

@stophwan stophwan Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

게시글 중 댓글이 없는 게시글이 많다는 것을 알면 좋을 것 같아요!

Comment on lines +32 to +33
Member member = memberRepository.findById(commentCreateRequest.getMember()).get();
Post post = postRepository.findById(commentCreateRequest.getMember()).get();
Copy link
Copy Markdown

@k-kbk k-kbk Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

member나 post가 null일 땐?

Comment on lines +12 to +14
private Long member;
private Long post;
private String content;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final로 변경 방지하기

Copy link
Copy Markdown
Member

@stophwan stophwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 고생하셨습니다!

Comment on lines +26 to +28
private final PostRepository postRepository;
private final MemberRepository memberRepository;
private final CommentRepository commentRepository;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 분 PR에서 이부분 작성해놨으니 참고하시면 좋을 것 같아요!

Comment on lines +50 to +53
public void update(PostUpdateRequest postUpdateRequest) {
this.title = postUpdateRequest.getTitle();
this.content = postUpdateRequest.getContent();
}
Copy link
Copy Markdown
Member

@stophwan stophwan Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분도 다른 분 PR코멘트를 확인해주세요. 변경 가능성이 낮은 도메인 객체가 변경 가능성이 높은 요청객체에 의존하는 것에 대해 고민해보시면 좋을 것 같아요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants