Conversation
Summary of ChangesHello @hyobin-yang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 사용자 상호작용 기능의 핵심 도메인 모델을 도입합니다. 댓글, 게시물 및 댓글에 대한 좋아요, 신고, 스크랩 기능을 위한 엔티티를 정의하여 풍부한 사용자 참여 기능을 위한 기반을 마련합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이번 PR은 유저 상호작용 관련 도메인 엔티티들을 정의하는 변경사항을 담고 있습니다. 전반적으로 JPA 엔티티 설계가 잘 되어있지만, 몇 가지 개선점을 제안합니다. Report 엔티티의 경우, 생성자에서 type에 따른 post와 comment 필드의 유효성 검사를 추가하여 데이터 무결성을 강화해야 합니다. 또한, ReportReason 열거형에 description 필드에 대한 getter를 추가하여 활용도를 높이는 것이 좋겠습니다. 마지막으로 Comment 엔티티에 자식 댓글 목록을 관리하는 OneToMany 연관관계를 추가하면 계층 구조를 다루기 더 용이해질 것입니다. 자세한 내용은 각 파일의 주석을 참고해주세요.
| public Report(@NonNull ReportType type, Post post, Comment comment, | ||
| @NonNull User reporter, @NonNull ReportReason reportReason, | ||
| String reportContent) { | ||
| this.type = type; | ||
| this.post = post; | ||
| this.comment = comment; | ||
| this.reporter = reporter; | ||
| this.reportReason = reportReason; | ||
| this.reportContent = reportContent; | ||
| } |
There was a problem hiding this comment.
현재 생성자에서는 type 필드와 post, comment 필드 간의 유효성 검사를 수행하지 않습니다. 이로 인해 type이 POST인데 post가 null이거나, post와 comment가 모두 설정되는 등 유효하지 않은 상태의 Report 객체가 생성될 수 있습니다. 객체의 일관성을 보장하기 위해 생성자에서 검증 로직을 추가하는 것이 좋습니다.
public Report(@NonNull ReportType type, Post post, Comment comment,
@NonNull User reporter, @NonNull ReportReason reportReason,
String reportContent) {
if (type == ReportType.POST) {
if (post == null || comment != null) {
throw new IllegalArgumentException("POST 타입의 신고는 post 필드가 null이 아니어야 하고 comment 필드는 null이어야 합니다.");
}
} else if (type == ReportType.COMMENT) {
if (comment == null || post != null) {
throw new IllegalArgumentException("COMMENT 타입의 신고는 comment 필드가 null이 아니어야 하고 post 필드는 null이어야 합니다.");
}
}
this.type = type;
this.post = post;
this.comment = comment;
this.reporter = reporter;
this.reportReason = reportReason;
this.reportContent = reportContent;
}|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "parent_comment_id") | ||
| private Comment parentComment; |
There was a problem hiding this comment.
Comment 엔티티가 계층 구조(대댓글)를 지원하기 위해 parentComment 필드를 가지고 있습니다. 부모 댓글에서 자식 댓글 목록으로 쉽게 접근할 수 있도록 childComments에 대한 OneToMany 연관관계를 추가하는 것을 고려해 보세요. 이렇게 하면 자식 댓글을 조회하기 위해 별도의 쿼리를 작성할 필요가 없어집니다.
다음과 같이 parentComment 필드 아래에 추가할 수 있습니다:
@OneToMany(mappedBy = "parentComment", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> childComments = new ArrayList<>();이 변경을 위해서는 java.util.List, java.util.ArrayList, jakarta.persistence.OneToMany, jakarta.persistence.CascadeType를 import해야 합니다.
| private final String description; | ||
|
|
||
| ReportReason(String description) { | ||
| this.description = description; | ||
| } |
There was a problem hiding this comment.
ReportReason 열거형의 description 필드는 private으로 선언되어 있고 외부에서 접근할 방법이 없습니다. 이 필드는 신고 사유를 UI에 표시하는 등 외부에서 사용될 가능성이 높으므로, public getter를 추가하는 것이 좋습니다.
private final String description;
ReportReason(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
No description provided.