Skip to content

Conversation

@7dngur7
Copy link
Contributor

@7dngur7 7dngur7 commented Aug 31, 2025

#️⃣ Issue Number

📝 요약(Summary)

feat: 약관동의 html 제공 기능 및 user 약관동의 저장 기능 추가

📸 기능 스크린 샷 공유

💬 공유사항 to 리뷰어

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

Summary by CodeRabbit

  • New Features
    • Added the ability to view the latest versions of Terms of Service, Privacy Policy, and optional Marketing Agreement by type.
    • Enabled signed-in users to submit consent to selected terms in one request.
    • Responses now include clear success messages and structured payloads.
    • Introduced a user-friendly error when the requested terms are unavailable, guiding users to valid selections.

@7dngur7 7dngur7 self-assigned this Aug 31, 2025
@7dngur7 7dngur7 requested a review from minhyuk2 as a code owner August 31, 2025 07:52
@coderabbitai
Copy link

coderabbitai bot commented Aug 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a complete “Terms” module: JPA entities, DTOs, repositories, services, and REST controllers for fetching latest terms by type and recording user agreements. Introduces a new error code TERMS_NOT_FOUND and integrates authentication principal usage for agreement submission.

Changes

Cohort / File(s) Summary
Controllers
.../domain/terms/controller/TermsController.java, .../domain/terms/controller/TermsAgreementController.java
New REST endpoints: GET /api/terms?type=… to fetch latest terms; POST /api/terms-agreement to persist a user’s agreements. Responses wrapped in BaseResponse.
Domain Entities
.../domain/terms/domain/Terms.java, .../domain/terms/domain/TermsType.java, .../domain/terms/domain/UserTermsAgreement.java
New JPA entities for Terms and UserTermsAgreement, plus TermsType enum. Includes auditing for agreement timestamps and enum persistence as STRING.
DTOs
.../domain/terms/dto/TermsResponseDto.java, .../domain/terms/dto/TermsAgreementRequest.java
DTOs introduced: TermsResponseDto (with static mapper) and TermsAgreementRequest (record with agreedTermsIds).
Repositories
.../domain/terms/repository/TermsRepository.java, .../domain/terms/repository/UserTermsAgreementRepository.java
Spring Data repositories. TermsRepository adds finder for latest terms by type; UserTermsAgreementRepository provides CRUD baseline.
Services
.../domain/terms/service/TermsService.java, .../domain/terms/service/TermsAgreementService.java
Business logic to fetch latest terms and handle agreement flow (user lookup, terms validation, save agreements). Transactional boundaries defined.
Error Codes
.../global/exception/ErrorCode.java
New enum constant TERMS_NOT_FOUND; minor formatting adjustment to preceding constant.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant TermsController as TermsController (/api/terms)
  participant TermsService as TermsService
  participant TermsRepo as TermsRepository
  participant BaseResponse as BaseResponse

  Client->>TermsController: GET /api/terms?type=TERMS_OF_SERVICE
  TermsController->>TermsService: getLatestTerms(type)
  TermsService->>TermsRepo: findFirstByTypeOrderByEffectiveDateDescVersionDesc(type)
  alt Terms exists
    TermsRepo-->>TermsService: Terms
    TermsService-->>TermsController: TermsResponseDto
    TermsController-->>Client: 200 BaseResponse{data=TermsResponseDto}
  else Terms missing
    TermsRepo-->>TermsService: Optional.empty
    TermsService-->>TermsController: throw CustomException(TERMS_NOT_FOUND)
    TermsController-->>Client: Error response
  end
Loading
sequenceDiagram
  autonumber
  actor Client
  participant TermsAgreementController as TermsAgreementController (/api/terms-agreement)
  participant TermsAgreementService as TermsAgreementService
  participant UserRepo as UserRepository
  participant TermsRepo as TermsRepository
  participant UTARepo as UserTermsAgreementRepository

  Client->>TermsAgreementController: POST /api/terms-agreement\nAuthorization: Bearer ...\nBody: { agreedTermsIds: [...] }
  TermsAgreementController->>TermsAgreementService: agreeToTerms(principal, request)
  TermsAgreementService->>UserRepo: findById(principal.userId)
  alt User found
    UserRepo-->>TermsAgreementService: User
    TermsAgreementService->>TermsRepo: findAllById(agreedTermsIds)
    alt All IDs resolved
      TermsRepo-->>TermsAgreementService: List<Terms>
      TermsAgreementService->>UTARepo: saveAll(List<UserTermsAgreement>)
      TermsAgreementService-->>TermsAgreementController: void
      TermsAgreementController-->>Client: 200 BaseResponse{message="약관 동의가 성공적으로 처리되었습니다."}
    else Missing/invalid IDs
      TermsRepo-->>TermsAgreementService: Partial/empty
      TermsAgreementService-->>TermsAgreementController: throw CustomException(TERMS_NOT_FOUND)
      TermsAgreementController-->>Client: Error response
    end
  else User missing
    UserRepo-->>TermsAgreementService: empty
    TermsAgreementService-->>TermsAgreementController: throw CustomException(USER_NOT_FOUND)
    TermsAgreementController-->>Client: Error response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • feat : login 추가 #3 — Introduces CustomOAuth2User and authentication plumbing referenced by the new terms agreement endpoint.

Suggested reviewers

  • minhyuk2

Poem

I hop through clauses, nibbling lines of law,
New terms bloom fresh—no loopholes to gnaw.
With a thump, I agree, ears held high,
Logs record the moment, timestamps fly.
Fetch, post, return—so tidy and bright,
A bunny signs off: “All terms are right.” ✅🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f509a0d and 6e1ed4d.

📒 Files selected for processing (12)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/controller/TermsAgreementController.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/controller/TermsController.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/domain/Terms.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/domain/TermsType.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/domain/UserTermsAgreement.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/dto/TermsAgreementRequest.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/dto/TermsResponseDto.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/repository/TermsRepository.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/repository/UserTermsAgreementRepository.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/service/TermsAgreementService.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/domain/terms/service/TermsService.java (1 hunks)
  • greatjourney/src/main/java/backend/greatjourney/global/exception/ErrorCode.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v1-terms

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@7dngur7 7dngur7 merged commit bc26542 into develop Aug 31, 2025
1 check was pending
@7dngur7 7dngur7 deleted the v1-terms branch August 31, 2025 09:34
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.

2 participants