Skip to content

Conversation

@lsy1307
Copy link
Contributor

@lsy1307 lsy1307 commented Nov 10, 2025

관련 이슈

작업 내용

  • mentoring에서 mentor_id와 metee_id에 대해 UK 제약조건을 추가했습니다.
  • schema 변경사항에 대해 flyway script 추가했습니다.
  • 동일 멘티 멘토에 대한 멘토링 존재여부에 대해 CustomException을 추가했습니다.
  • 해당 Custom Exception을 반환하도록 Service 로직을 수정했습니다.
  • 동일 멘티 멘토에 대한 멘토링이 불가능한 것을 확인하는 Test code를 추가했습니다.

특이 사항

성혁님 PR과 Mentoring Repository가 겹치는데 merge되는 순서대로 conflict 해결하면 될 것 같습니다!

리뷰 요구사항 (선택)

- UK 제약조건 추가
- flyway script 추가
- CustomException 추가
- Service 로직 수정
- Test code 추가
@lsy1307 lsy1307 self-assigned this Nov 10, 2025
@lsy1307 lsy1307 requested a review from Gyuhyeok99 as a code owner November 10, 2025 13:17
@lsy1307 lsy1307 added the 버그 Something isn't working label Nov 10, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 10, 2025

Walkthrough

  1. 에러 코드 추가
    ErrorCode 열거형에 ALREADY_EXIST_MENTORING(HttpStatus.BAD_REQUEST.value(), "이미 신청된 멘티, 멘토입니다.") 상수를 추가했습니다.
  2. 데이터베이스 제약 조건 추가
    Mentoring 엔티티에 @Table(... uniqueConstraints = @UniqueConstraint(name = "uk_mentoring_mentor_id_mentee_id", columnNames = {"mentor_id","mentee_id"}))를 선언해 mentor_id와 mentee_id 조합에 유니크 제약을 추가했습니다.
  3. 비즈니스 로직 검증 추가
    MentoringCommandService.applyMentoring에 existsByMentorIdAndMenteeId(mentorId, siteUserId) 사전 검사와 중복일 때 throw new CustomException(ALREADY_EXIST_MENTORING)를 던지는 로직을 추가했습니다.
  4. 데이터베이스 마이그레이션 추가
    V37__add_unique_constraint_to_mentor_id_mentee_id.sql 마이그레이션을 추가해 실제 DB에 uk_mentoring_mentor_id_mentee_id 유니크 제약을 생성합니다.
  5. 테스트 케이스 추가
    동일 멘토/멘티로 재신청 시 ALREADY_EXIST_MENTORING 예외가 발생하는지 확인하는 단위 테스트를 추가했습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • MentoringCommandService의 existsByMentorIdAndMenteeId 호출이 레포지토리에 구현되어 있는지 확인할 필요가 있습니다.
  • 엔티티와 마이그레이션 간 일치 여부 및 기존 데이터에 중복 레코드가 있어 마이그레이션이 실패할 가능성을 검토해야 합니다.
  • 예외 메시지와 ErrorCode가 국제화/한글 문자열 정책에 부합하는지 확인하세요.
  • 테스트가 DB 상태(예: pending 상태 레코드)와 트랜잭션 경계를 올바르게 구성하는지 검토하세요.

Suggested reviewers

  • wibaek
  • whqtker
  • Gyuhyeok99
  • Hexeong

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 요약하고 있습니다. 동일한 멘토-멘티 중복 신청 방지라는 주요 기능이 간결하게 표현되어 있습니다.
Linked Issues check ✅ Passed PR 변경사항이 이슈 #557의 모든 요구사항을 충족합니다. DB 제약조건 추가, 비즈니스 로직 검증, 테스트 코드 작성으로 동일 멘토-멘티 중복 신청을 완벽하게 방지합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #557의 범위 내에 있으며, 동일 멘토-멘티 중복 신청 방지 목표에 직접 관련되어 있습니다.
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 관련 이슈, 작업 내용, 특이 사항을 모두 포함하고 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 2

🧹 Nitpick comments (3)
src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java (1)

40-40: 추출한 변수를 일관되게 사용하는 것이 좋겠습니다.

Line 34에서 이미 mentorId 변수로 추출했는데, Line 40에서는 다시 mentoringApplyRequest.mentorId()를 호출하고 있습니다. 추출한 변수를 재사용하면 코드 일관성이 향상됩니다.

다음과 같이 수정할 수 있습니다:

-        Mentoring mentoring = new Mentoring(mentoringApplyRequest.mentorId(), siteUserId, VerifyStatus.PENDING);
+        Mentoring mentoring = new Mentoring(mentorId, siteUserId, VerifyStatus.PENDING);
src/main/java/com/example/solidconnection/common/exception/ErrorCode.java (1)

121-121: 에러 메시지를 더 명확하게 표현하면 좋겠습니다.

현재 메시지 "이미 신청된 멘티, 멘토입니다."보다는 "이미 해당 멘토에게 멘토링을 신청했습니다." 또는 "이미 신청된 멘토링입니다."가 사용자 입장에서 더 이해하기 쉬울 것 같습니다.

다음과 같이 수정을 고려해보세요:

-    ALREADY_EXIST_MENTORING(HttpStatus.BAD_REQUEST.value(), "이미 신청된 멘티, 멘토입니다."),
+    ALREADY_EXIST_MENTORING(HttpStatus.BAD_REQUEST.value(), "이미 신청된 멘토링입니다."),
src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java (1)

101-111: 테스트 커버리지를 확장하여 더욱 견고한 검증을 완성하세요.

검증 결과, 현재 구현은 데이터베이스 수준의 유니크 제약조건 uk_mentoring_mentor_id_mentee_id로 보호되고 있어서 모든 상태(PENDING, APPROVED, REJECTED)에서 중복 신청을 올바르게 방지하고 있습니다. 다만, 테스트 커버리지를 다음과 같이 강화하면 좋겠습니다:

  1. APPROVED 상태에서의 중복 방지 검증: 이미 승인된 멘토링이 있을 때 재신청이 차단되는지 테스트
  2. REJECTED 상태에서의 중복 방지 검증: 거절된 멘토링도 동일하게 재신청이 차단되는지 테스트

현재 테스트는 PENDING 상태만 확인하고 있는데, APPROVED/REJECTED 시나리오를 추가하면 모든 멘토링 상태에 대해 중복 방지 로직이 정상 작동함을 명확하게 보여줄 수 있습니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8de1c80 and 6f1a898.

📒 Files selected for processing (5)
  • src/main/java/com/example/solidconnection/common/exception/ErrorCode.java (1 hunks)
  • src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java (2 hunks)
  • src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java (2 hunks)
  • src/main/resources/db/migration/V37__add_unique_constraint_to_mentor_id_mentee_id.sql (1 hunks)
  • src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-11T14:39:49.462Z
Learnt from: Gyuhyeok99
Repo: solid-connection/solid-connect-server PR: 443
File: src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql:1-5
Timestamp: 2025-08-11T14:39:49.462Z
Learning: The mentor table currently has no data in production/staging environment, so NULL backfill operations are not needed when adding NOT NULL constraints to the introduction and pass_tip columns in the mentor table.

Applied to files:

  • src/main/resources/db/migration/V37__add_unique_constraint_to_mentor_id_mentee_id.sql
  • src/main/java/com/example/solidconnection/mentor/domain/Mentoring.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 (1)
src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java (1)

34-38: 멘토링 중복 신청 방지 로직이 잘 구현되었습니다.

애플리케이션 레벨에서 중복을 먼저 체크하여 불필요한 DB 작업을 방지하고 있습니다. DB 제약 조건과 함께 이중 방어 체계를 구성하여 동시성 문제도 안전하게 처리됩니다.

- column명 camelCase -> snake_case로 변경
- column명 name으로 명시
Copy link
Contributor

@Hexeong Hexeong left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

확인했습니다 ! 고생하셨습니다 ~!

@lsy1307 lsy1307 merged commit f5c4034 into solid-connection:develop Nov 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

버그 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 동일 멘티-멘토가 계속 멘토링이 신청되는 문제 해결

3 participants