Skip to content

Conversation

@kimyeoungrok
Copy link
Contributor

@kimyeoungrok kimyeoungrok commented May 5, 2025

✅ PR 유형

어떤 변경 사항이 있었나요?

  • 새로운 기능 추가
  • 버그 수정
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

📝 작업 내용

#85

  • 커플 생년월일 조회 기능 구현
  • 커플 생년월일 조회 기능 테스트 코드 작성

Summary by CodeRabbit

  • 신규 기능

    • 커플의 생년월일 정보를 조회할 수 있는 새로운 API 엔드포인트(/v1/couple/birthday)가 추가되었습니다.
  • 테스트

    • 커플 생년월일 조회 기능에 대한 테스트가 추가되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented May 5, 2025

Walkthrough

이번 변경 사항에서는 커플의 생년월일 정보를 조회하는 새로운 API 엔드포인트가 추가되었습니다. 이를 위해 커플 생년월일 응답용 DTO가 신설되었고, Facade 계층과 Controller 계층에 관련 메서드가 추가되었습니다. API 경로 상수도 추가되었으며, 커플 생년월일 조회 기능에 대한 단위 테스트가 작성되었습니다. 기존 로직에는 영향이 없으며, 새로운 기능과 관련된 코드만 변경되었습니다.

Changes

파일 경로 변경 요약
src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt 커플 생년월일 정보를 담는 DTO 클래스 및 정적 팩토리 메서드 추가
src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt 커플 생년월일 조회용 public 메서드 getCoupleBirthDay 추가
src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt 커플 생년월일 조회 API 경로 상수(COUPLE_BIRTHDAY) 추가
src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt /couple/birthday GET 엔드포인트 및 관련 컨트롤러 메서드 추가
src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt 테스트 데이터에 생년월일 명시, 커플 생년월일 조회 테스트 케이스 추가

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant Facade
    participant CoupleInfoService
    participant MemberService

    User->>Controller: GET /v1/couple/birthday
    Controller->>Facade: getCoupleBirthDay(customUserDetails)
    Facade->>CoupleInfoService: findCoupleMember(userId)
    Facade->>MemberService: getById(userId)
    Facade->>Facade: CoupleBirthDayResponse.of(coupleMember, myMember)
    Facade->>Controller: CoupleBirthDayResponse
    Controller->>User: ApiResponse<CoupleBirthDayResponse>
Loading

Suggested reviewers

  • HoyeongJeon

Poem

🐰
커플의 생일을 찾아서
토끼가 코드를 달려가네
생년월일 두 개, 응답에 담아
API로 살포시 전해주네
테스트도 꼼꼼히 챙겼으니
오늘도 평화로운 개발의 숲!
🎂🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b060f9 and 7023b93.

📒 Files selected for processing (2)
  • src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt (1 hunks)
  • src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt
  • src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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 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.

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.

@kimyeoungrok kimyeoungrok changed the title Issue: (#85) MY_02 (기능보완) 커플 생년월알 조회 기능 Issue: (#85) MY_02 (기능보완) 커플 생년월일 조회 기능 May 5, 2025
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

🧹 Nitpick comments (5)
src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt (1)

134-134: 메서드 이름 대소문자 일관성 개선 필요

getCoupleBirthDay에서 'Day'가 대문자로 되어 있지만, 일반적인 Kotlin 네이밍 컨벤션에서는 'day'나 'date'를 사용합니다. getCoupleBirthday 또는 getCoupleBirthDate로 변경하는 것이 더 일관된 스타일이 될 것입니다.

src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt (3)

7-12: 속성 이름 대소문자 일관성 개선 필요

coupleBirthDaymyBirthDay에서 'Day'가 대문자로 되어 있습니다. Kotlin 네이밍 컨벤션에 따라 coupleBirthday 또는 coupleBirthDate와 같이 소문자로 통일하는 것이 좋습니다.

data class CoupleBirthDayResponse (
    @Schema(description = "커플 생년월일", example = "2001-04-01")
-    val coupleBirthDay : LocalDate?,
+    val coupleBirthdate : LocalDate?,
    @Schema(description = "내 생년월일", example = "2001-03-01")
-    val myBirthDay : LocalDate?
+    val myBirthdate : LocalDate?
) {

9-11: null 처리에 대한 명확한 문서화 필요

두 속성이 모두 nullable(LocalDate?)로 선언되어 있습니다. 사용자가 생년월일을 설정하지 않은 경우 이 값들이 null일 수 있다는 것을 명확히 하기 위해 Swagger 문서에 이 정보를 추가하는 것이 좋습니다.

@Schema(description = "커플 생년월일", example = "2001-04-01")
val coupleBirthDay : LocalDate?,
@Schema(description = "내 생년월일", example = "2001-03-01")
val myBirthDay : LocalDate?

수정 예시:

@Schema(description = "커플 생년월일 (설정되지 않은 경우 null)", example = "2001-04-01", nullable = true)
val coupleBirthDay : LocalDate?,
@Schema(description = "내 생년월일 (설정되지 않은 경우 null)", example = "2001-03-01", nullable = true)
val myBirthDay : LocalDate?

14-17: companion object의 팩토리 메서드에서 매개변수 명확성 개선 필요

현재 매개변수 이름 coupleMembermyMember는 상대방과 자신을 구분하는데 약간 모호할 수 있습니다. partnerMembercurrentMember와 같이 더 명확한 이름을 사용하는 것이 좋습니다.

companion object {
-    fun of(coupleMember : Member, myMember : Member) = CoupleBirthDayResponse(
-        coupleMember.birthDate,
-        myMember.birthDate
+    fun of(partnerMember : Member, currentMember : Member) = CoupleBirthDayResponse(
+        partnerMember.birthDate,
+        currentMember.birthDate
    )
}
src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt (1)

209-222: 커플 생년월일 조회 기능의 테스트 케이스가 잘 구현되었습니다.

Given-When-Then 패턴을 명확하게 따르고 있으며, 필요한 서비스 호출이 적절하게 모킹되었습니다. 또한 결과값에 대한 검증도 적절히 이루어지고 있습니다.

추가 제안: 테스트의 완전성을 위해 customUserDetails.getId()가 호출되는 부분도 모킹하고 검증하는 것을 고려해 보세요.

 //given
+`when`(customUserDetails.getId()).thenReturn(1L)
 `when`(memberService.getById(customUserDetails.getId())).thenReturn(member1)
 `when`(coupleInfoService.findCoupleMember(customUserDetails.getId())).thenReturn(member2)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95c5043 and 6b060f9.

📒 Files selected for processing (6)
  • .github/workflows/deploy.yml (1 hunks)
  • src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt (1 hunks)
  • src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt (1 hunks)
  • src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt (1 hunks)
  • src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt (1 hunks)
  • src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt (3 hunks)
🔇 Additional comments (4)
.github/workflows/deploy.yml (1)

6-7: Pull Request에 대한 CI/CD 파이프라인 실행이 추가되었습니다.

main 브랜치를 대상으로 하는 Pull Request에 대해서도 워크플로우가 실행되도록 설정이 추가되었습니다. 이는 코드가 main 브랜치에 병합되기 전에 모든 테스트와 검증을 통과하도록 하는 좋은 방식입니다.

src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt (1)

19-19: 커플 생년월일 조회 API 경로가 적절하게 추가되었습니다.

기존의 API 경로 네이밍 컨벤션과 일관되게 새로운 엔드포인트가 추가되었습니다.

src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt (1)

65-65: 테스트 데이터 초기화가 적절하게 이루어졌습니다.

커플 생년월일 조회 기능 테스트를 위해 Member 객체들에 명시적인 생년월일 값을 설정한 것이 좋습니다. 이전에는 null 값이었던 것을 구체적인 날짜로 변경하여 테스트의 명확성을 높였습니다.

Also applies to: 76-76

src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt (1)

75-83: 커플 생년월일 조회 API 엔드포인트가 적절하게 구현되었습니다.

새로운 기능에 대한 API 엔드포인트가 기존 컨트롤러 패턴과 일관성 있게 추가되었습니다. HTTP 상태 코드, 엔드포인트 경로, Swagger 문서화가 모두 적절히 구성되어 있습니다.

서비스 계층과의 연계도 잘 구현되어 있으며, 응답 형식도 기존 API 패턴을 따르고 있습니다.

Comment on lines +134 to +138
fun getCoupleBirthDay(customUserDetails: CustomUserDetails): CoupleBirthDayResponse {
val couple = coupleInfoService.findCoupleMember(customUserDetails.getId())
val member = memberService.getById(customUserDetails.getId())
return CoupleBirthDayResponse.of(couple, member)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

커플 연결 여부에 대한 예외 처리가 필요합니다.

현재 구현에서는 사용자가 커플로 연결되어 있지 않은 경우에 대한 예외 처리가 누락되어 있습니다. getInfo() 메서드(24-33줄)와 같이 checkIsCouple()을 통해 사용자가 커플로 연결되어 있는지 확인하는 로직을 추가해야 합니다.

fun getCoupleBirthDay(customUserDetails: CustomUserDetails): CoupleBirthDayResponse {
+    val member = memberService.getById(customUserDetails.getId())
+
+    if (!member.checkIsCouple()) {
+        throw BadRequestException("saranggun.couple.not-connected")
+    }
+
    val couple = coupleInfoService.findCoupleMember(customUserDetails.getId())
-    val member = memberService.getById(customUserDetails.getId())
    return CoupleBirthDayResponse.of(couple, member)
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fun getCoupleBirthDay(customUserDetails: CustomUserDetails): CoupleBirthDayResponse {
val couple = coupleInfoService.findCoupleMember(customUserDetails.getId())
val member = memberService.getById(customUserDetails.getId())
return CoupleBirthDayResponse.of(couple, member)
}
fun getCoupleBirthDay(customUserDetails: CustomUserDetails): CoupleBirthDayResponse {
val member = memberService.getById(customUserDetails.getId())
if (!member.checkIsCouple()) {
throw BadRequestException("saranggun.couple.not-connected")
}
val couple = coupleInfoService.findCoupleMember(customUserDetails.getId())
return CoupleBirthDayResponse.of(couple, member)
}

Copy link
Collaborator

@HoyeongJeon HoyeongJeon left a comment

Choose a reason for hiding this comment

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

굿

@kimyeoungrok kimyeoungrok merged commit 1fe5193 into main May 5, 2025
1 check passed
@kimyeoungrok kimyeoungrok deleted the issue/#85-getCoupleBirthDay branch May 5, 2025 15:02
@kimyeoungrok kimyeoungrok self-assigned this May 6, 2025
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.

3 participants