Skip to content

Refactor: is bookmark 기능 리팩토링#179

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

Refactor: is bookmark 기능 리팩토링#179
Jjiggu merged 6 commits into
developfrom
refactor/#178-isBookmark

Conversation

@Jjiggu

@Jjiggu Jjiggu commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

작업 요약

  • 주점 조회 내 is bookmark 기능 리팩토링
  • dto 내 fromEntity 통일

Issue Link

#178

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 매장 정보 응답에 북마크 여부(isBookmark) 필드가 추가되어, 사용자가 매장을 북마크했는지 여부를 확인할 수 있습니다.
  • 개선 사항

    • 매장 목록 및 상세 조회 시 응답 데이터 구조가 개선되어, 북마크 상태 정보가 일관되게 제공됩니다.
    • 검색 및 목록 조회 응답이 새로운 데이터 구조(StorePageReadResponse)로 통일되어 더 많은 매장 정보를 확인할 수 있습니다.

@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

Walkthrough

이번 변경에서는 즐겨찾기(북마크) 관련 DTO와 서비스 메서드의 시그니처 및 내부 구현이 전반적으로 리팩토링되었습니다. 북마크 여부를 나타내는 필드가 통일되고, 관련 메서드들이 새로운 파라미터와 DTO를 사용하도록 수정되었습니다. 또한, 새로운 DTO 클래스가 추가되었습니다.

Changes

Cohort / File(s) Change Summary
BookmarkService 북마크 처리 개선
nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java
getBookmarks 메서드가 북마크된 store ID의 Set을 생성하여 storeService.getAllStoresByPageAndDeparments에 추가 인자로 전달하도록 변경됨.
StoreDepartmentReadResponse DTO 타입 변경
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDepartmentReadResponse.java
내부 리스트 필드 타입이 StorePageReadDto에서 StorePageReadResponse로 변경됨. 정적 팩토리 메서드도 이에 맞게 수정됨.
StoreDetailReadResponse 북마크 필드 및 팩토리 메서드 통합
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java
isBookmarked 필드가 isBookmark로 교체되고, 팩토리 메서드가 통합되어 북마크 여부를 파라미터로 받음. 별도의 북마크용 팩토리 메서드는 삭제됨.
StorePageReadDto 북마크 필드 및 팩토리 메서드 통합
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadDto.java
isBookmarked 필드가 isBookmark로 변경되고, 팩토리 메서드가 통합되어 북마크 여부를 파라미터로 받음. 별도의 북마크용 팩토리 메서드는 삭제됨.
StorePageReadResponse 신규 DTO 추가
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java
상세 정보와 북마크 여부를 포함하는 새로운 DTO 클래스 추가. 엔티티 및 이미지 리스트, 부서명, 대기열 수를 받아 객체를 생성하는 팩토리 메서드 포함.
StoreService 인터페이스 시그니처 변경
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java
searchByKeywordNative의 반환 타입이 StorePageReadDto에서 StorePageReadResponse로 변경. getAllStoresByPageAndDeparmentsSet<Long> 북마크 ID 추가 파라미터를 받도록 변경됨.
StoreServiceImpl 구현 및 DTO 적용
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java
여러 메서드에서 새로운 DTO(StorePageReadResponse)를 사용하도록 변경. 북마크 여부 처리 로직이 통합되고, 관련 메서드 시그니처 및 내부 매핑 로직이 변경됨.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BookmarkService
    participant StoreService
    participant StoreRepository

    User->>BookmarkService: getBookmarks(CustomOAuth2User)
    BookmarkService->>BookmarkService: 북마크된 storeId 리스트 조회
    BookmarkService->>BookmarkService: storeId 리스트로 Set<Long> bookmarkedSet 생성
    BookmarkService->>StoreService: getAllStoresByPageAndDeparments(storeIds, bookmarkedSet)
    StoreService->>StoreRepository: storeId 리스트로 매장 정보 조회
    StoreService->>StoreService: 각 매장에 대해 bookmarkedSet 포함 여부로 isBookmark 설정
    StoreService-->>BookmarkService: StorePageReadDto/StorePageReadResponse 리스트 반환
    BookmarkService-->>User: 북마크 매장 리스트 반환
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20분

Possibly related PRs

Suggested reviewers

  • HyemIin

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ 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 03:13

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

🧹 Nitpick comments (3)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java (1)

32-59: 코드 중복 개선을 위한 리팩토링 제안

fromEntity 메서드의 이미지 필터링 로직이 StoreReadDto와 StorePageReadDto에서도 동일하게 반복되고 있습니다. 이런 공통 로직을 유틸리티 메서드로 추출하여 코드 중복을 줄이는 것을 고려해보세요.

예시 리팩토링:

+ // 공통 유틸리티 클래스에서
+ public static class StoreImageUtils {
+   public static StoreImageUploadResponse getProfileImage(List<StoreImageUploadResponse> allImages) {
+     return allImages.stream()
+       .filter(image -> image.getImageType() == ImageType.PROFILE)
+       .findFirst()
+       .orElse(null);
+   }
+   
+   public static List<StoreImageUploadResponse> getBannerImages(List<StoreImageUploadResponse> allImages) {
+     return allImages.stream()
+       .filter(image -> image.getImageType() == ImageType.BANNER)
+       .toList();
+   }
+ }
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDepartmentReadResponse.java (1)

14-22: DTO 타입 변경 확인

StorePageReadDto에서 StorePageReadResponse로의 타입 변경이 일관되게 적용되었습니다. 다만 필드명 storePageReadDtos가 복수형 Dtos를 사용하고 있는데, 새로운 타입인 StorePageReadResponse와 일치하도록 storePageReadResponses로 변경하는 것이 더 명확할 것 같습니다.

- private List<StorePageReadResponse> storePageReadDtos;
+ private List<StorePageReadResponse> storePageReadResponses;
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java (1)

34-36: 메서드 시그니처 통합 완료

북마크 상태를 매개변수로 받도록 메서드를 통합한 것이 좋습니다. 다만 매개변수가 6개로 늘어났으므로, 향후 매개변수 객체 패턴을 고려해볼 수 있습니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e444d99 and 0340240.

📒 Files selected for processing (7)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java (2 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDepartmentReadResponse.java (1 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java (4 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadDto.java (4 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadResponse.java (1 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 (8 hunks)
👮 Files not reviewed due to content moderation or server errors (2)
  • 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/service/StoreServiceImpl.java
🧰 Additional context used
🧬 Code Graph Analysis (3)
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/StoreReadDto.java (1)
  • StoreReadDto (13-52)
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/dto/StorePageReadDto.java (1)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreReadDto.java (2)
  • StoreReadDto (13-52)
  • fromEntity (28-51)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreDetailReadResponse.java (2)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreReadDto.java (1)
  • StoreReadDto (13-52)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreImageUploadResponse.java (1)
  • StoreImageUploadResponse (9-25)
🔇 Additional comments (35)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/bookmark/service/BookmarkService.java (2)

3-3: 새로운 import 추가 확인

HashSet과 Set 임포트가 북마크 처리 최적화를 위해 적절히 추가되었습니다.

Also applies to: 6-6


65-67: 북마크 상태 처리 최적화

storeIds 리스트를 HashSet으로 변환하여 O(1) 조회 성능을 확보하고, 이를 storeService에 전달하여 각 스토어의 북마크 상태를 효율적으로 확인할 수 있도록 개선된 구현입니다. 이 방식은 기존의 반복적인 조회보다 성능상 유리합니다.

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

4-4: 새로운 import 추가 확인

Set과 StorePageReadResponse 임포트가 메서드 시그니처 변경에 맞춰 적절히 추가되었습니다.

Also applies to: 11-11


21-21: 반환 타입 변경 확인

searchByKeywordNative 메서드의 반환 타입이 새로운 StorePageReadResponse DTO로 변경되었습니다. 구현체에서도 동일하게 변경되었는지 확인이 필요합니다.


25-25: 북마크 처리를 위한 메서드 시그니처 개선

getAllStoresByPageAndDeparments 메서드에 Set bookmarkedSet 파라미터가 추가되어 북마크 상태를 효율적으로 처리할 수 있게 되었습니다. 이는 BookmarkService에서의 변경사항과 일치합니다.

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

18-18: 북마크 필드 통합

isBookmark Boolean 필드가 명확하게 정의되어 북마크 상태 처리가 단순화되었습니다.


33-33: 팩토리 메서드 통합 및 개선

fromEntity 메서드에 Boolean isBookmark 파라미터가 추가되어 북마크 상태를 명시적으로 전달받도록 개선되었습니다. 이는 여러 팩토리 메서드를 하나로 통합하여 코드 복잡성을 줄이는 좋은 리팩토링입니다.

Also applies to: 46-46

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

18-18: 북마크 필드명 표준화 완료

isBookmarked에서 isBookmark로 필드명을 변경하여 다른 DTO들과 일관성을 맞춘 것이 좋습니다.


49-49: 빌더에서 새로운 매개변수 사용 확인

새로운 isBookmark 매개변수를 올바르게 빌더에 적용했습니다.


63-63: 생성 시간 필드 추가 확인

createdAt 필드를 빌더에 추가하여 DTO의 완성도를 높인 것이 좋습니다.


18-18: 필드명 표준화가 잘 적용되었습니다.

isBookmarked에서 isBookmark로 변경하여 북마크 관련 필드명을 전체 코드베이스에서 통일한 것이 좋습니다.


34-36: 메서드 통합이 잘 이루어졌습니다.

fromEntity 메서드가 Boolean isBookmark 파라미터를 추가로 받도록 업데이트되어 이전의 fromEntityWithBookmark 메서드 기능을 통합한 것이 좋습니다. 이는 메서드 중복을 제거하고 일관된 DTO 생성 방식을 제공합니다.


49-49: 빌더 패턴 사용이 올바르게 업데이트되었습니다.

새로운 isBookmark 파라미터와 createdAt 필드가 빌더에 올바르게 매핑되어 통합된 메서드 기능이 제대로 구현되었습니다.

Also applies to: 63-63


18-18: 북마크 필드명 표준화가 잘 적용되었습니다.

isBookmarked에서 isBookmark로 변경하여 다른 DTO들과 일관된 네이밍 컨벤션을 유지하고 있습니다.


34-36: 팩토리 메서드 통합이 잘 구현되었습니다.

fromEntity 메서드가 북마크 상태를 매개변수로 받도록 변경되어, 이전의 별도 메서드들의 기능을 하나로 통합했습니다. 이는 유지보수성을 개선하고 DTO 생성의 일관성을 높입니다.


49-49: 빌더 패턴이 올바르게 업데이트되었습니다.

새로운 필드명과 매개변수를 사용하여 빌더가 정확히 구성되었습니다.


63-63: 생성일시 필드 추가가 적절합니다.

createdAt 필드를 빌더에 추가하여 스토어의 완전한 정보를 응답에 포함하도록 개선되었습니다.

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

8-8: 필요한 import 추가 확인

북마크된 스토어 ID 집합을 처리하기 위한 Set import 추가가 적절합니다.


28-28: 새로운 응답 DTO import 추가 확인

StorePageReadResponse DTO import 추가가 적절합니다.


109-109: DTO 타입 변경 완료

StorePageReadDto에서 StorePageReadResponse로 일관되게 변경한 것이 좋습니다.

Also applies to: 117-117


140-141: 북마크 처리 로직 개선

북마크 상태를 한 번만 조회하여 DTO 생성자에 전달하는 방식으로 개선한 것이 효율적입니다.

Also applies to: 152-152


156-156: 검색 메서드 반환 타입 업데이트

검색 메서드의 반환 타입을 새로운 응답 DTO로 일관되게 변경했습니다.

Also applies to: 213-213


288-288: 북마크 집합을 활용한 효율적인 처리

북마크된 스토어 ID 집합을 매개변수로 받아 개별 데이터베이스 조회를 피하고 효율적으로 북마크 상태를 확인하는 방식이 우수합니다.

Also applies to: 339-341


8-8: 필요한 import가 적절히 추가되었습니다.

Set import가 새로운 bookmarkedSet 파라미터를 지원하기 위해 추가되었습니다.


28-28: 새로운 DTO 클래스 import가 추가되었습니다.

StorePageReadResponse import가 추가되어 기존 StorePageReadDto를 대체하는 리팩토링을 지원합니다.


109-109: DTO 클래스 변경이 일관되게 적용되었습니다.

StorePageReadDto에서 StorePageReadResponse로의 변경이 반환 타입과 팩토리 메서드 호출에서 일관되게 적용되었습니다.

Also applies to: 117-117


140-141: 북마크 처리 로직이 효율적으로 통합되었습니다.

북마크 존재 여부를 한 번만 확인하여 boolean 변수로 저장하고, 이를 fromEntity 메서드에 전달하는 방식으로 개선되었습니다. 이는 코드의 명확성과 일관성을 향상시킵니다.

Also applies to: 152-152


156-156: 검색 메서드도 일관된 DTO 변경이 적용되었습니다.

searchByKeywordNative 메서드의 반환 타입과 팩토리 메서드 호출이 새로운 StorePageReadResponse DTO를 사용하도록 일관되게 업데이트되었습니다.

Also applies to: 213-213


288-288: 북마크 세트를 활용한 효율적인 처리가 구현되었습니다.

Set<Long> bookmarkedSet 파라미터를 받아서 각 매장의 북마크 상태를 contains() 메서드로 효율적으로 확인하는 방식이 잘 구현되었습니다. 이는 대량의 매장 데이터를 처리할 때 성능상 이점을 제공합니다.

Also applies to: 339-341


8-8: 필요한 임포트가 추가되었습니다.

북마크된 스토어 ID 집합을 처리하기 위한 Set 임포트가 적절히 추가되었습니다.


28-28: 새로운 DTO 임포트가 추가되었습니다.

StorePageReadResponse 임포트 추가로 리팩토링된 DTO 구조를 반영하고 있습니다.


109-109: DTO 타입 변경이 일관되게 적용되었습니다.

반환 타입과 팩토리 메서드 호출이 새로운 StorePageReadResponse DTO를 사용하도록 올바르게 변경되었습니다.

Also applies to: 117-117


140-141: 북마크 처리 로직이 개선되었습니다.

북마크 상태를 한 번만 조회하여 변수에 저장하고, 이를 DTO 생성 시 전달하는 방식으로 효율성과 일관성이 향상되었습니다.

Also applies to: 152-152


156-156: 검색 메서드의 DTO 타입이 일관되게 변경되었습니다.

검색 기능에서도 새로운 StorePageReadResponse DTO를 사용하도록 올바르게 업데이트되었습니다.

Also applies to: 213-213


288-288: 북마크 세트를 활용한 메서드 오버로딩이 잘 구현되었습니다.

북마크된 스토어 ID 집합을 매개변수로 받아 효율적으로 북마크 상태를 확인하고 DTO에 전달하는 로직이 깔끔하게 구현되었습니다.

Also applies to: 339-341

@Jjiggu Jjiggu merged commit 3a27095 into develop Jul 29, 2025
2 checks passed
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