Skip to content

[feature] 유저 interaction 도메인 정의#16

Merged
hyobin-yang merged 2 commits intomainfrom
#15-feature-user-interaction-domain
Sep 19, 2025
Merged

[feature] 유저 interaction 도메인 정의#16
hyobin-yang merged 2 commits intomainfrom
#15-feature-user-interaction-domain

Conversation

@hyobin-yang
Copy link
Copy Markdown
Contributor

No description provided.

@hyobin-yang hyobin-yang self-assigned this Sep 19, 2025
@hyobin-yang hyobin-yang linked an issue Sep 19, 2025 that may be closed by this pull request
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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

  • 댓글 엔티티 정의: 게시물과 사용자 간의 댓글 관계를 정의하는 Comment 엔티티를 추가했습니다. 이 엔티티는 부모 댓글을 참조하여 계층형 댓글을 지원하며, 좋아요 수와 차단 여부 필드를 포함합니다.
  • 댓글 좋아요 엔티티 정의: 사용자가 댓글에 '좋아요'를 표시할 수 있도록 CommentLike 엔티티를 추가했습니다. 중복 좋아요를 방지하기 위한 고유 제약 조건이 포함되어 있습니다.
  • 게시물 좋아요 엔티티 정의: 사용자가 게시물에 '좋아요'를 표시할 수 있도록 PostLike 엔티티를 추가했습니다. 이 또한 중복 좋아요를 방지하기 위한 고유 제약 조건이 있습니다.
  • 신고 엔티티 정의: 게시물 또는 댓글을 신고할 수 있는 Report 엔티티를 추가했습니다. 신고 유형(ReportType), 신고 사유(ReportReason - 스팸, 욕설, 저작권 침해 등), 신고 내용, 처리 여부 필드를 포함합니다.
  • 스크랩 엔티티 정의: 사용자가 게시물을 스크랩(북마크)할 수 있도록 Scrap 엔티티를 추가했습니다. 사용자-게시물 쌍에 대한 고유 제약 조건이 설정되어 있습니다.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이번 PR은 유저 상호작용 관련 도메인 엔티티들을 정의하는 변경사항을 담고 있습니다. 전반적으로 JPA 엔티티 설계가 잘 되어있지만, 몇 가지 개선점을 제안합니다. Report 엔티티의 경우, 생성자에서 type에 따른 postcomment 필드의 유효성 검사를 추가하여 데이터 무결성을 강화해야 합니다. 또한, ReportReason 열거형에 description 필드에 대한 getter를 추가하여 활용도를 높이는 것이 좋겠습니다. 마지막으로 Comment 엔티티에 자식 댓글 목록을 관리하는 OneToMany 연관관계를 추가하면 계층 구조를 다루기 더 용이해질 것입니다. 자세한 내용은 각 파일의 주석을 참고해주세요.

Comment on lines +46 to +55
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;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

현재 생성자에서는 type 필드와 post, comment 필드 간의 유효성 검사를 수행하지 않습니다. 이로 인해 typePOST인데 postnull이거나, postcomment가 모두 설정되는 등 유효하지 않은 상태의 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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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해야 합니다.

Comment on lines +70 to +74
private final String description;

ReportReason(String description) {
this.description = description;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

ReportReason 열거형의 description 필드는 private으로 선언되어 있고 외부에서 접근할 방법이 없습니다. 이 필드는 신고 사유를 UI에 표시하는 등 외부에서 사용될 가능성이 높으므로, public getter를 추가하는 것이 좋습니다.

        private final String description;

        ReportReason(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

@hyobin-yang hyobin-yang merged commit 70347d2 into main Sep 19, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 유저 interaction 도메인 정의

1 participant