Skip to content

Refactor: 북마크 조회 시 bookmarkId 추가#191

Merged
Jjiggu merged 3 commits into
developfrom
refactor/#178-isBookmark
Jul 29, 2025
Merged

Refactor: 북마크 조회 시 bookmarkId 추가#191
Jjiggu merged 3 commits into
developfrom
refactor/#178-isBookmark

Conversation

@Jjiggu

@Jjiggu Jjiggu commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

작업 요약

북마크 조회 시 bookmarkId 추가

Issue Link

#178

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 매장 상세 및 목록 조회 시 북마크 ID 정보가 추가로 제공됩니다.
  • 버그 수정

    • 이미 삭제된 북마크에 대한 예외 처리가 명확하게 구분되어 안내 메시지가 개선되었습니다.
  • 리팩터

    • 북마크 처리 로직이 북마크 ID 기반으로 개선되어 데이터 일관성이 향상되었습니다.
  • 기타

    • 불필요한 저장소 및 레포지토리 메서드가 정리되었습니다.
    • 예외 메시지 및 반환 코드가 보다 명확하게 분리되었습니다.

@Jjiggu Jjiggu self-assigned this Jul 29, 2025
@Jjiggu Jjiggu added the refactor 리팩토링 label Jul 29, 2025
@coderabbitai

coderabbitai Bot commented Jul 29, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

이 변경사항은 북마크 기능의 데이터 구조를 기존의 북마크된 매장 ID 집합(Set)에서 매장 ID와 북마크 ID를 매핑하는 Map 구조로 전환합니다. 이에 따라 관련 서비스, DTO, 예외 처리, 저장소 인터페이스, 에러 메시지, 예외 클래스 등이 일관되게 수정되었습니다.

Changes

Cohort / File(s) Change Summary
Bookmark 서비스 및 저장소 리팩토링
nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java,
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/repository/BookmarkRepository.java,
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/AlreadyDeletedBookmarkException.java,
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/BookmarkNotFoundException.java
북마크 조회 시 Set에서 Map으로 구조 변경, 삭제 예외를 BookmarkNotFoundException에서 AlreadyDeletedBookmarkException으로 분리, 관련 예외 클래스 및 저장소 메서드 삭제 및 수정.
Store 서비스 및 DTO 구조 변경
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java,
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java,
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java,
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java
Store 관련 서비스 및 DTO에서 북마크 ID를 명시적으로 전달하도록 변경. 서비스 메서드 시그니처를 Set에서 Map으로 변경하고, DTO에 bookmarkId 필드 및 생성자 파라미터 추가.
예외 처리 및 에러 메시지 분리
nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java,
nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java
북마크 삭제 예외와 미존재 예외를 분리하여 각각의 핸들러 및 에러 메시지, 코드로 대응. 기존 에러 메시지 삭제 및 신규 메시지 추가.
StoreRepository 메서드 정리
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreRepository.java
사용되지 않는 findAllByDeletedFalse 메서드 삭제.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BookmarkService
    participant BookmarkRepository
    participant StoreService
    participant StoreRepository
    participant StoreDTO

    User->>BookmarkService: getBookmarks(userId)
    BookmarkService->>BookmarkRepository: findAllByUserAndDeletedFalse(user)
    BookmarkRepository-->>BookmarkService: List<Bookmark>
    BookmarkService->>StoreService: getAllStoresByPageAndDeparments(storeIds, bookmarkMap)
    StoreService->>StoreRepository: findStoresByIds(storeIds)
    StoreRepository-->>StoreService: List<Store>
    StoreService->>StoreDTO: fromEntity(store, bookmarkId, ...)
    StoreDTO-->>StoreService: StorePageReadResponse
    StoreService-->>BookmarkService: List<StorePageReadResponse>
    BookmarkService-->>User: List<StorePageReadResponse>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • refactor(Bookmark): Bookmark 응답 response 변경 #157: BookmarkService.getBookmarks가 매장 ID 리스트를 인자로 받는 새로운 getAllStoresByPageAndDeparments 메서드를 호출하도록 변경하는 등 북마크 관련 서비스 메서드 호출 방식에 차이가 있으나 동일 기능 영역을 다룸.
  • Refactor: 북마크 조회 시 bookmarkId 추가 #191: 본 PR과 동일하게 북마크 ID 매핑 구조 도입, 예외 처리 분리, DTO 필드 추가 등 북마크 처리 로직을 변경하는 동일한 변경사항을 포함.
  • Refactor: is bookmark 기능 리팩토링 #179: 북마크 기능을 Set에서 Map 구조로 전환하는 변경과 관련된 PR로, 북마크 데이터 구조와 DTO 처리 방식에 차이가 있으나 연관된 기능 개선을 수행.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61ff34d and 8aa41fc.

📒 Files selected for processing (1)
  • nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.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 refactor/#178-isBookmark

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.

@github-actions github-actions Bot requested a review from HyemIin July 29, 2025 14:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/AlreadyDeletedBookmarkException.java (1)

6-6: 코드 포맷팅 일관성 개선 고려

기능적으로는 올바른 구현이지만, 다른 유사한 예외 클래스들(StatisticViewUnauthorizedException 등)과의 일관성을 위해 생성자를 여러 줄로 포맷하는 것을 고려해보세요.

-	public AlreadyDeletedBookmarkException() { super(ErrorMessage.ALREADY_DELETED_BOOKMARK.getMessage()); }
+	public AlreadyDeletedBookmarkException() {
+		super(ErrorMessage.ALREADY_DELETED_BOOKMARK.getMessage());
+	}
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (1)

3-3: 불필요한 임포트를 제거해주세요.

java.awt.print.Book 임포트는 코드에서 사용되지 않으며 북마크 기능과 관련이 없습니다.

-import java.awt.print.Book;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1681bb2 and 61ff34d.

📒 Files selected for processing (11)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java (4 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java (2 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java (3 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java (3 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java (2 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (12 hunks)
  • nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java (1 hunks)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreRepository.java (0 hunks)
  • nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/AlreadyDeletedBookmarkException.java (1 hunks)
  • nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/BookmarkNotFoundException.java (1 hunks)
  • nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/repository/BookmarkRepository.java (0 hunks)
💤 Files with no reviewable changes (2)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreRepository.java
  • nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/repository/BookmarkRepository.java
🧰 Additional context used
🧬 Code Graph Analysis (4)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java (1)
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/AlreadyDeletedBookmarkException.java (1)
  • AlreadyDeletedBookmarkException (5-7)
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/AlreadyDeletedBookmarkException.java (1)
nowait-domain/domain-redis/src/main/java/com/nowait/domaincoreredis/rank/exception/MenuCounterUpdateException.java (1)
  • MenuCounterUpdateException (5-7)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java (2)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadDto.java (2)
  • StorePageReadDto (13-54)
  • fromEntity (29-53)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreImageUploadResponse.java (1)
  • StoreImageUploadResponse (9-25)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (4)
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/BookmarkNotFoundException.java (1)
  • BookmarkNotFoundException (5-9)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadDto.java (1)
  • StorePageReadDto (13-54)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java (1)
  • getAllStoresByPageAndDeparments (43-57)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreRepository.java (1)
  • StoreRepository (16-37)
🔇 Additional comments (17)
nowait-domain/domain-user-rdb/src/main/java/com/nowait/domainuserrdb/bookmark/exception/BookmarkNotFoundException.java (1)

7-7: LGTM!

에러 메시지 enum 리팩토링과 일치하는 올바른 변경사항입니다.

nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java (1)

98-98: LGTM!

AlreadyDeletedBookmarkException 사용이 올바르며, 더 구체적인 예외 처리를 통해 에러 처리가 개선되었습니다.

nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java (1)

4-4: LGTM!

북마크 리팩토링을 지원하기 위한 올바른 import 추가입니다.

nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java (2)

18-18: 북마크 ID 필드 추가가 적절합니다.

새로운 bookmarkId 필드가 논리적인 위치에 잘 배치되었고, 기존 북마크 관련 필드들과 함께 그룹화되어 있습니다.


35-35: 팩토리 메서드 업데이트가 올바르게 구현되었습니다.

새로운 bookmarkId 매개변수가 메서드 시그니처와 빌더 패턴에 일관되게 통합되었습니다.

Also applies to: 48-48

nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java (1)

18-18: 일관된 북마크 ID 통합이 잘 구현되었습니다.

StorePageReadResponse와 동일한 패턴으로 bookmarkId 필드와 팩토리 메서드가 업데이트되어 일관성이 유지되었습니다.

Also applies to: 37-37, 51-51

nowait-app-user-api/src/main/java/com/nowait/applicationuser/exception/GlobalExceptionHandler.java (3)

40-40: 새로운 예외 클래스 임포트가 적절히 추가되었습니다.

AlreadyDeletedBookmarkException 임포트가 올바른 위치에 배치되었습니다.


157-158: 북마크 예외 처리의 에러 코드 업데이트가 적절합니다.

NOT_FOUND_BOOKMARK 에러 코드로의 변경이 새로운 에러 메시지 체계와 일치합니다.


160-167: 새로운 예외 핸들러가 올바르게 구현되었습니다.

AlreadyDeletedBookmarkException 핸들러가 기존 패턴을 따라 적절히 구현되었고, 로깅, 알람, 에러 응답이 모두 포함되어 있습니다.

nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (8)

6-6: 새로운 기능에 필요한 임포트들이 적절히 추가되었습니다.

Collection, Optional, BookmarkNotFoundException 임포트가 새로운 북마크 처리 로직에 필요합니다.

Also applies to: 11-11, 48-48


67-68: 메서드 시그니처 변경이 적절합니다.

사용자별 북마크 정보를 조회하기 위해 CustomOAuth2User 매개변수가 추가된 것이 합리적입니다.


87-98: Redis 접근 에러 처리가 개선되었습니다.

Redis 접근 실패 시 0L을 반환하는 예외 처리가 추가되어 시스템 안정성이 향상되었습니다.


116-123: 북마크 조회 로직이 효과적으로 리팩토링되었습니다.

Set에서 Map으로의 변경을 통해 북마크 ID 추적이 가능해졌고, 더 상세한 북마크 관리가 가능합니다.


127-128: DTO 매핑 로직이 깔끔하게 구현되었습니다.

bookmarkId 추출과 isBookmark 계산 로직이 명확하고, 팩토리 메서드 호출도 올바르게 업데이트되었습니다.

Also applies to: 133-133


146-148: 매장 상세 조회 메서드가 일관되게 개선되었습니다.

Optional 패턴을 사용한 북마크 조회와 매개변수 검증 로직이 깔끔하게 구현되었습니다.

Also applies to: 157-159, 171-172


290-291: 정렬 로직의 포매팅이 개선되었습니다.

코드 가독성을 향상시키는 minor한 포매팅 변경입니다.


309-310: 오버로드된 메서드가 일관되게 업데이트되었습니다.

북마크 매개변수가 Set<Long>에서 Map<Long, Long>으로 변경되어 새로운 북마크 ID 추적 방식과 일치합니다.

Also applies to: 354-355, 364-365

Comment thread nowait-common/src/main/java/com/nowait/common/exception/ErrorMessage.java Outdated
@Jjiggu Jjiggu merged commit 8d0bda8 into develop Jul 29, 2025
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant