Skip to content

Conversation

@nayonsoso
Copy link
Collaborator

@nayonsoso nayonsoso commented Jul 23, 2025

관련 이슈

작업 내용

앱 출시를 대비하기 위해, 우선 순위가 올라간 "신고" 기능을 구현합니다.

image

특이 사항

  • 채팅에도 신고 기능이 들어갈 것으로 압니다. "확장성"을 고려하여, 아래 형식으로 구현했습니다.
image

@coderabbitai
Copy link

coderabbitai bot commented Jul 23, 2025

Walkthrough

  1. 신고(Report) 기능 도입
    • 새로운 신고(Report) 도메인 및 관련 enum(ReportType, TargetType) 클래스가 추가되었습니다.
    • 신고를 위한 JPA 엔티티(Report)와 DB 테이블 생성 SQL(V24__create_report_table.sql)이 도입되어, 신고 기록이 영속화됩니다.
    • 신고 요청을 위한 DTO(ReportRequest)가 생성되었고, 신고 컨트롤러(ReportController)와 서비스(ReportService), 레포지토리(ReportRepository)가 각각 구현되었습니다.
    • 신고 중복 방지를 위한 유니크 제약조건 및 예외 코드가 추가되어, 동일 사용자가 같은 대상을 여러 번 신고하지 못하도록 처리합니다.
    • 테스트 코드(ReportServiceTest)와 테스트용 픽스처(ReportFixture, ReportFixtureBuilder)가 추가되어, 신고 기능의 정상 동작 및 예외 상황을 검증합니다.
    • 기존 PostFixture에 간편 게시글 생성 메서드가 추가되어 테스트 편의성이 향상되었습니다.
    • ErrorCode enum에 신고 관련 에러 코드가 2종 추가되었고, 기존 INVALID_POST_ID에 대한 개선 코멘트가 달렸습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20분

  • 신규 도메인 및 DB 설계, 서비스/컨트롤러/레포지토리 계층 전반, 예외 처리, 테스트 코드까지 전체적인 신고 기능이 일괄 도입되어 검토 범위가 중간 수준의 복합도를 보입니다.

Suggested reviewers

  • wibaek
  • Gyuhyeok99

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nayonsoso nayonsoso marked this pull request as draft July 23, 2025 14:37
coderabbitai[bot]

This comment was marked as resolved.

@nayonsoso nayonsoso force-pushed the feat/401-create-report branch from 4be5a97 to 0d591bd Compare July 23, 2025 14:48
@nayonsoso nayonsoso force-pushed the feat/401-create-report branch from 0d591bd to bdc675c Compare July 23, 2025 14:51
@nayonsoso nayonsoso marked this pull request as ready for review July 23, 2025 14:51
@nayonsoso nayonsoso self-assigned this Jul 23, 2025
Copy link
Member

@whqtker whqtker left a comment

Choose a reason for hiding this comment

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

사용자는 특정 리소스를 한번만 신고 가능해야 한다고 생각해서 unique key 걸어주었습니다!

동의합니다 ! 고생하셨습니다 ~

@@ -0,0 +1,14 @@
package com.example.solidconnection.report.domain;

public enum ReasonType {
Copy link
Member

Choose a reason for hiding this comment

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

제 생각엔 ReportType 또는 ReportReasonType 이 의미적으로 조금 더 와닿는 것 같습니다 ! GPA 제출에도 'reason' 관련 내용이 있기 때문에, 클래스명으로 분명하게 구분하는 것이 좋을 것 같습니다 !

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

동의합니다!
게다가 기존에는 reason 이 문자열로 관리되고 있어서 더 헷갈릴만하겠네요.

ReportType 으로 이름 변경했습니다.
그리고 ReasonType 일 때보다 의미상 더 중요해졌다 생각해서 엔티티에서의 필드 위치 변경했습니다.🫡

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/main/java/com/example/solidconnection/report/domain/Report.java (1)

19-24: 데이터베이스 레벨 중복 방지가 완벽하게 구현되었습니다.

  1. 유니크 제약조건: 이전 리뷰 피드백이 반영되어 reporter_id, target_type, target_id 조합으로 중복 신고를 방지합니다.
  2. 명명 규칙: 제약조건에 명확한 이름(uk_report_reporter_id_target_type_target_id)이 부여되었습니다.
  3. 확장성: PR 목표에 맞게 다양한 타겟 타입을 지원할 수 있는 구조입니다.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bdc675c and ad803d9.

📒 Files selected for processing (7)
  • src/main/java/com/example/solidconnection/report/domain/Report.java (1 hunks)
  • src/main/java/com/example/solidconnection/report/domain/ReportType.java (1 hunks)
  • src/main/java/com/example/solidconnection/report/dto/ReportRequest.java (1 hunks)
  • src/main/java/com/example/solidconnection/report/service/ReportService.java (1 hunks)
  • src/main/resources/db/migration/V24__create_report_table.sql (1 hunks)
  • src/test/java/com/example/solidconnection/report/fixture/ReportFixtureBuilder.java (1 hunks)
  • src/test/java/com/example/solidconnection/report/service/ReportServiceTest.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/example/solidconnection/report/domain/ReportType.java
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/main/resources/db/migration/V24__create_report_table.sql
  • src/test/java/com/example/solidconnection/report/fixture/ReportFixtureBuilder.java
  • src/main/java/com/example/solidconnection/report/service/ReportService.java
  • src/test/java/com/example/solidconnection/report/service/ReportServiceTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
src/main/java/com/example/solidconnection/report/dto/ReportRequest.java (1)

7-17: 신고 요청 DTO 구조가 깔끔하게 설계되었습니다.

  1. Record 패턴 활용: 불변 객체로 설계되어 데이터 전송 용도에 적합합니다.
  2. 확장성 고려: PR 목표에서 언급한 채팅 기능 확장을 위한 구조가 잘 갖춰져 있습니다.
  3. 한국어 검증 메시지: 사용자 친화적인 에러 메시지가 제공됩니다.
src/main/java/com/example/solidconnection/report/domain/Report.java (2)

35-44: Enum 필드 매핑이 적절하게 구성되었습니다.

  1. STRING 타입 저장: EnumType.STRING 사용으로 데이터베이스 가독성과 유지보수성이 향상됩니다.
  2. 명시적 컬럼명: 각 필드의 컬럼명이 명확하게 지정되어 있습니다.
  3. 타입 안정성: enum 타입 사용으로 유효하지 않은 값 입력을 방지합니다.

46-51: 생성자 구현이 깔끔합니다.

모든 필수 필드를 받는 생성자가 제공되어 엔티티 생성이 명확합니다. ID는 자동 생성되므로 생성자에서 제외된 것이 적절합니다.

@NotNull(message = "신고 대상을 포함해주세요.")
TargetType targetType,

long targetId
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

targetId 필드에 검증 로직 추가를 고려해보세요.

현재 targetId에는 검증 어노테이션이 없어 음수나 0값이 들어올 수 있습니다.

+        @Positive(message = "유효한 대상 ID를 입력해주세요.")
         long targetId

필요한 import도 추가해주세요:

+import jakarta.validation.constraints.Positive;
🤖 Prompt for AI Agents
In src/main/java/com/example/solidconnection/report/dto/ReportRequest.java at
line 14, the targetId field lacks validation annotations, allowing invalid
values like negative numbers or zero. Add a validation annotation such as
@Positive to ensure targetId is a positive number, and include the necessary
import for this annotation from javax.validation.constraints or
jakarta.validation.constraints depending on the project setup.

Copy link
Member

@whqtker whqtker left a comment

Choose a reason for hiding this comment

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

확인했습니다 ~! 👍

Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 left a comment

Choose a reason for hiding this comment

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

너무 깔끔하게 잘 나눠서 구현해주셔가지고 코드가 술술 읽혔습니다 ㅎㅎ
고생하셨습니다!! 신고 내역같은 건 어드민에서만 필요하니 나중에 구현해도 문제 없겠네요!
TargetType 추가한 거 너무 좋은 거 같습니다!!

@nayonsoso nayonsoso merged commit 80985c0 into solid-connection:develop Jul 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 신고 기능 구현

3 participants