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

[8주차] cow mvc practice(BaekJaehyuk) #3

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

BaekJaehyuk
Copy link

추가 Q & A

🤔 잘 모르겠거나, 더 궁금한 내용이 있었나요?

집중적으로 리뷰 받고싶은 것이 있나요?

Copy link
Owner

@Hoya324 Hoya324 left a comment

Choose a reason for hiding this comment

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

이야 Postman 링크도 같이 올려주시면 좋을거 같아요! 아니면 swagger도 츄라이

import lombok.Getter;

@Getter
public class CreateCommentResponse {
Copy link
Owner

Choose a reason for hiding this comment

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

댓글을 생성하는 response? 라는 생각이 들어서 프론트에게 Comment 생성에 대한 정보를 넘겨줘야하는가? 라는 생각이 들게 됩니다! 만약 Comment 생성한 후 정보를 반환하고 싶은거라면 CommentResponse 또는CreatedCommnetReponse 와 같은 클래스 명을 사용할거 같아요! 반환의 이유가 있는지 확인해보고 결정해주세요!

Copy link
Author

Choose a reason for hiding this comment

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

고민해 보겠습니다

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "comment_id")
private Long id;
Copy link
Owner

Choose a reason for hiding this comment

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

id를 Long type으로 설정한 이유가 있나요?

Copy link
Owner

Choose a reason for hiding this comment

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

경험상 uuid를 사용하는게 좋을 때도 많아서 한번쯤 알아두면 좋을거 같습니다

uuid


@RequiredArgsConstructor
@Service
@Transactional
Copy link
Owner

Choose a reason for hiding this comment

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

Transactional을 interface에도 달고 구현체에도 달게 되면 어떻게 될까요?

Copy link
Collaborator

@KoSeonJe KoSeonJe left a comment

Choose a reason for hiding this comment

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

커밋도 더 디테일하게 나눠 주시면 좋을 것 같아요 고생하셨습니다

Long postId;
String content;

public Comment toEntity() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

사용 안하시고 계신데 toEntity를 만들어 놓은 이유가 있을까요

Copy link
Author

Choose a reason for hiding this comment

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

@Hoya324 호야씨가 만들어 놓으셨어요

Copy link
Collaborator

Choose a reason for hiding this comment

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

사용하셔야죠

Member member = findMemberById(createCommentRequest.getMemberId());
Post post = findPostById(createCommentRequest.getPostId());

Comment comment = Comment.of(createCommentRequest.getContent(), post, member);
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment 객체를 만들때 연관관계 주입을 해주지 않고, 따로 편의 메소드로 작성하는 것이 좋을 것 같습니다.(post,member)

Member member = findMemberById(createCommentRequest.getMemberId());
Post post = findPostById(createCommentRequest.getPostId());

Comment comment = Comment.of(createCommentRequest.getContent(), post, member);
Copy link
Collaborator

Choose a reason for hiding this comment

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

CraeteCommentRequest의 toEntity메소드를 사용하여 인스턴스 생성하는 것이 더 좋아보입니다.


Comment comment = Comment.of(createCommentRequest.getContent(), post, member);
commentRepository.save(comment);
post.addComment(comment);
Copy link
Collaborator

Choose a reason for hiding this comment

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

연관관계 편의 메소드를 만들어 한번에 관리해주세요


// 게시글 삭제
@DeleteMapping("/{postId}")
public ResponseEntity<Long> deletePost(@PathVariable Long postId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

다른 부분은 ResponseEntity를 적용하지 않으셨는데, 따로 이 부분만 적용하신 이유가 있을까요?

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