Skip to content

Conversation

@kimyeoungrok
Copy link
Contributor

@kimyeoungrok kimyeoungrok commented May 5, 2025

✅ PR 유형

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

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

📝 작업 내용

#83

  • 알림 기능 수정(토글 식이 아니라 true면 알림 on, false면 off이게끔 -> 직관적이게 수정)
  • 알림 조회 기능 추가

Summary by CodeRabbit

  • 신규 기능
    • 사용자의 알림 정책 정보를 조회할 수 있는 GET 엔드포인트가 추가되었습니다.
    • 알림 정책 정보를 반환하는 응답 객체가 도입되었습니다.
  • 버그 수정
    • 알림 설정 업데이트 시 요청 값에 따라 정확하게 반영되도록 동작이 개선되었습니다.
  • 테스트
    • 알림 정책 조회 및 업데이트에 대한 테스트가 추가 및 개선되었습니다.
  • 문서화
    • API 응답 객체에 Swagger 예시 및 설명이 추가되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented May 5, 2025

Walkthrough

이번 변경에서는 알림(Notification) 관련 도메인 로직과 API가 확장 및 리팩토링되었습니다. Notification 엔티티의 Boolean 필드 업데이트 메서드가 명시적으로 값을 받도록 변경되었고, 회원의 알림 정책을 조회하는 새로운 GET API가 추가되었습니다. 이를 위해 DTO와 컨트롤러, 파사드, 서비스 계층이 수정 및 보완되었습니다. 또한 테스트 코드가 새로운 로직에 맞게 보강되었습니다.

Changes

파일/경로 요약 변경 내용 요약
.../member/domain/entity/Notification.kt updateDday, updatePartnerStatus 메서드가 Boolean 파라미터를 받아 직접 값 할당하도록 시그니처 변경
.../member/domain/service/NotificationService.kt initNotification에서 조건문 제거, 두 필드 모두 명시적으로 Boolean 값 전달하여 업데이트하도록 수정
.../member/dto/response/MyNotificationResponse.kt dday, partnerStatus 필드가 있는 DTO 신설, Notification → DTO 변환 팩토리 메서드 추가
.../member/facade/MemberInfoFacade.kt 알림 업데이트 메서드 내부 로직 변경(조건문 제거, 값 직접 전달), 알림 조회 메서드 신설
.../member/presentation/ApiPath.kt MY_NOTIFICATION 경로 상수 추가
.../member/presentation/MemberInfoController.kt 회원 알림 정책 조회용 GET API 엔드포인트 및 핸들러 메서드 추가
.../member/facade/MemberInfoFacadeTest.kt 알림 업데이트 테스트 로직 수정, 알림 조회 테스트 메서드 신설

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant Facade
    participant Service
    participant Repository
    participant DTO

    User->>Controller: GET /v1/member/my-notification
    Controller->>Facade: getMyNotification(customUserDetails)
    Facade->>Repository: findNotificationByUserId(userId)
    Repository-->>Facade: Notification
    Facade->>DTO: MyNotificationResponse.of(Notification)
    DTO-->>Facade: MyNotificationResponse
    Facade-->>Controller: MyNotificationResponse
    Controller-->>User: ApiResponse<MyNotificationResponse>
Loading

Poem

알림 정책 새로워진 오늘,
당근처럼 똑똑하게 값을 골라주네.
GET으로 살짝 물어보면,
내 알림 상태 토끼 귀처럼 쫑긋!
코드는 더 깔끔, 테스트도 든든,
🥕 알림의 봄바람이 불어오네!


📜 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 312bad8 and 2288178.

📒 Files selected for processing (1)
  • src/main/kotlin/gomushin/backend/member/domain/service/NotificationService.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/kotlin/gomushin/backend/member/domain/service/NotificationService.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.

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

🧹 Nitpick comments (2)
.github/workflows/deploy.yml (1)

6-7: pull_request 이벤트 트리거 추가
main 브랜치를 대상으로 PR 이벤트에서 CI/CD가 실행되도록 설정된 것은 적절합니다. 다만, 외부 포크 PR에서는 secrets 접근이 차단되어 워크플로가 실패할 수 있으므로, 경우에 따라 pull_request_target 이벤트 사용이나 secrets 스텝에 대한 조건부 실행 설정을 고려해 보세요.

src/main/kotlin/gomushin/backend/member/facade/MemberInfoFacade.kt (1)

65-68: 알림 설정 조회 기능 추가

사용자의 알림 설정을 조회하는 새로운 메서드가 올바르게 구현되었습니다. 트랜잭션 어노테이션이 누락되었지만, 읽기 전용 작업이므로 필수는 아닙니다. 다만, 읽기 전용 트랜잭션으로 명시하는 것을 고려해볼 수 있습니다.

+@Transactional(readOnly = true)
 fun getMyNotification(customUserDetails: CustomUserDetails): MyNotificationResponse {
     val notification = notificationService.getByMemberId(customUserDetails.getId())
     return MyNotificationResponse.of(notification)
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d1efc9 and 84c7596.

📒 Files selected for processing (7)
  • .github/workflows/deploy.yml (1 hunks)
  • src/main/kotlin/gomushin/backend/member/domain/entity/Notification.kt (1 hunks)
  • src/main/kotlin/gomushin/backend/member/dto/response/MyNotificationResponse.kt (1 hunks)
  • src/main/kotlin/gomushin/backend/member/facade/MemberInfoFacade.kt (2 hunks)
  • src/main/kotlin/gomushin/backend/member/presentation/ApiPath.kt (1 hunks)
  • src/main/kotlin/gomushin/backend/member/presentation/MemberInfoController.kt (2 hunks)
  • src/test/kotlin/gomushin/backend/member/facade/MemberInfoFacadeTest.kt (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/kotlin/gomushin/backend/member/facade/MemberInfoFacade.kt (1)
src/main/kotlin/gomushin/backend/member/domain/entity/Notification.kt (2)
  • changeDday (41-43)
  • changePartnerStatus (45-47)
🔇 Additional comments (8)
src/main/kotlin/gomushin/backend/member/presentation/ApiPath.kt (1)

13-13: 중복된 API 경로 상수가 있습니다.

UPDATE_MY_NOTIFICATION_POLICY(11줄)와 MY_NOTIFICATION(13줄) 상수가 동일한 값 "/v1/member/my-notification"을 가지고 있습니다. 두 상수는 HTTP 메서드(POST/GET)로만 구분되므로 혼란을 야기할 수 있습니다.

가능한 개선 방안:

  1. 경로 값에 HTTP 메서드를 포함시키거나 (예: /v1/member/my-notification/get, /v1/member/my-notification/update)
  2. 상수 이름에 HTTP 메서드를 포함시키는 것 (예: GET_MY_NOTIFICATION, UPDATE_MY_NOTIFICATION)

이것은 코드의 명확성을 위한 제안이며, 현재 구현도 기술적으로는 문제가 없습니다.

src/test/kotlin/gomushin/backend/member/facade/MemberInfoFacadeTest.kt (2)

175-182: 코드 변경이 요구 사항을 충족하며 적절하게 구현되었습니다.

기존 토글 방식에서 boolean 값을 직접 설정하는 방식으로 변경되었으며, 테스트 코드도 이에 맞게 잘 수정되었습니다.


184-194: 알림 설정 조회 테스트가 잘 추가되었습니다.

새로운 알림 설정 조회 기능에 대한 테스트 케이스가 잘 작성되었습니다. given-when-then 패턴을 따라 모든 필요한 검증을 포함하고 있습니다.

src/main/kotlin/gomushin/backend/member/presentation/MemberInfoController.kt (1)

117-125: 새로운 알림 설정 조회 API 엔드포인트가 잘 구현되었습니다.

알림 설정을 조회하는 새로운 GET 엔드포인트가 컨트롤러에 적절하게 추가되었습니다. Swagger 어노테이션을 포함한 코드 구조가 기존 패턴을 잘 따르고 있습니다.

src/main/kotlin/gomushin/backend/member/domain/entity/Notification.kt (1)

41-47: 직접 값을 설정하는 메서드 추가가 적절하게 구현되었습니다.

기존의 토글 메서드(updateDday, updatePartnerStatus)와 함께 값을 직접 설정할 수 있는 새로운 메서드(changeDday, changePartnerStatus)가 잘 추가되었습니다. 이는 PR의 목표인 알림 설정 방식 변경을 적절히 지원합니다.

src/main/kotlin/gomushin/backend/member/dto/response/MyNotificationResponse.kt (1)

1-18: 적절한 응답 DTO 구현

알림 설정을 조회하는 API의 응답 데이터를 위한 DTO가 잘 구현되었습니다. Swagger 문서화를 위한 Schema 어노테이션도 적절히 적용되어 있고, companion object를 통한 도메인 객체 변환 메서드도 깔끔하게 구현되었습니다.

src/main/kotlin/gomushin/backend/member/facade/MemberInfoFacade.kt (2)

14-14: 적절한 임포트 추가

새로 추가된 MyNotificationResponse 클래스를 위한 임포트가 올바르게 추가되었습니다.


59-62: 토글 로직에서 직접 값 설정 방식으로 변경

알림 설정 업데이트 로직이 토글 방식에서 직접 값을 설정하는 방식으로 변경되었습니다. 이는 PR의 목적에 부합하는 변경이며, 도메인 엔티티에 새로 추가된 changeDdaychangePartnerStatus 메서드를 적절히 활용하고 있습니다.

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.

this.partnerStatus = !this.partnerStatus
}

fun changeDday(dday: Boolean) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

아예 이렇게 새로 만들지 말고, updateDday랑 updatePartnerStatus 를 수정하는게 낫지 않을까?

물론 그러면 온보딩 쪽에 엮여있는 코드도 수정해야하긴 하는데, 어렵진 않을꺼야

notificationService.getByMemberId(customUserDetails.getId()).apply {
if (updateMyNotificationRequest.dday) updateDday()
if (updateMyNotificationRequest.partnerStatus) updatePartnerStatus()
changeDday(updateMyNotificationRequest.dday)
Copy link
Collaborator

Choose a reason for hiding this comment

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

updateDday랑 updatePartnerStatus 를 수정하면 이 코드는 없어도 될 듯?

…따로 changeDday/PartenerStatus와 같이 추가적인 메서드 안 만들게) #83
if (isNotification) {
notification.updateDday()
notification.updatePartnerStatus()
notification.updateDday(true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

isNotification 이 Boolean 값이고, 알림 받겠다고 했으면 true, 아니면 false 값이니까
true 보다

notification.updateDday(isNotification);

이렇게 가는게 더 이어지는 거 같아

@kimyeoungrok kimyeoungrok merged commit 95c5043 into main May 5, 2025
1 check passed
@kimyeoungrok kimyeoungrok deleted the issue/#83-improveNotificationSetting branch May 5, 2025 06:42
@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