Skip to content

Conversation

@HyemIin
Copy link
Member

@HyemIin HyemIin commented Jun 16, 2025

작업 요약

Issue Link

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 매장 이름을 기준으로 부분 일치 검색이 가능한 새로운 검색 API가 추가되었습니다.
  • 스타일

    • 불필요한 import 문이 제거되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Jun 16, 2025

"""

Walkthrough

이번 변경에서는 매장 이름을 부분적으로 검색할 수 있는 새로운 GET 엔드포인트(/stores/search)가 추가되었습니다. 이를 위해 컨트롤러, 서비스 인터페이스 및 구현체, 리포지토리에 검색 관련 메서드가 각각 도입되었으며, 불필요한 import 문도 일부 정리되었습니다.

Changes

파일/경로 변경 요약
.../store/controller/StoreController.java /stores/search GET 엔드포인트 및 searchStores 메서드 추가
.../store/service/StoreService.java
.../store/service/StoreServiceImpl.java
searchStoresByName 메서드 인터페이스 및 구현 추가
.../store/repository/StoreRepository.java findByNameContainingIgnoreCaseAndDeletedFalse 검색 메서드 추가
.../user/service/UserService.java 불필요한 OAuth2User import 제거

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant StoreController
    participant StoreService
    participant StoreRepository

    Client->>StoreController: GET /stores/search?name=XXX
    StoreController->>StoreService: searchStoresByName(name)
    StoreService->>StoreRepository: findByNameContainingIgnoreCaseAndDeletedFalse(name)
    StoreRepository-->>StoreService: List<Store>
    StoreService-->>StoreController: List<StoreReadDto>
    StoreController-->>Client: ApiUtils.success(List<StoreReadDto>)
Loading

Poem

🌟
매장 이름을 찾아서,
검색 창에 살며시 입력해요.
대소문자 구분 없이,
부분 일치도 놓치지 않죠!
새로운 엔드포인트와 함께
더 똑똑해진 우리 서비스,
오늘도 반짝입니다.

"""


📜 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 654ebf3 and bcca43a.

📒 Files selected for processing (3)
  • src/main/java/com/example/gtable/store/repository/StoreRepository.java (1 hunks)
  • src/main/java/com/example/gtable/store/service/StoreService.java (2 hunks)
  • src/main/java/com/example/gtable/store/service/StoreServiceImpl.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/com/example/gtable/store/service/StoreService.java
  • src/main/java/com/example/gtable/store/repository/StoreRepository.java
  • src/main/java/com/example/gtable/store/service/StoreServiceImpl.java
✨ 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.
    • 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 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.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7096e3b and 654ebf3.

📒 Files selected for processing (5)
  • src/main/java/com/example/gtable/store/controller/StoreController.java (2 hunks)
  • src/main/java/com/example/gtable/store/repository/StoreRepository.java (1 hunks)
  • src/main/java/com/example/gtable/store/service/StoreService.java (2 hunks)
  • src/main/java/com/example/gtable/store/service/StoreServiceImpl.java (1 hunks)
  • src/main/java/com/example/gtable/user/service/UserService.java (0 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/com/example/gtable/user/service/UserService.java
🔇 Additional comments (1)
src/main/java/com/example/gtable/store/controller/StoreController.java (1)

12-13: @RequestParam 임포트는 적절합니다
필요한 임포트가 잘 추가되었습니다. 별다른 이슈 없습니다.

Comment on lines 24 to 25
List<Store> searchStoresByName(String name);

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

서비스 계층이 엔티티를 직접 노출하고 있습니다
다른 메서드는 모두 DTO(StoreReadDto, StoreReadResponse 등)를 반환하는데, 새로 추가된 searchStoresByNameStore 엔티티를 그대로 반환하여 API 스키마가 불일치합니다. 민감 필드 노출 가능성과 계층 분리 훼손이 우려됩니다. DTO 리스트 혹은 별도 Response 클래스로 바꾸는 리팩터가 필요합니다.

-	List<Store> searchStoresByName(String name);
+	List<StoreReadDto> searchStoresByName(String name);
📝 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
List<Store> searchStoresByName(String name);
List<StoreReadDto> searchStoresByName(String name);
🤖 Prompt for AI Agents
In src/main/java/com/example/gtable/store/service/StoreService.java around lines
24 to 25, the method searchStoresByName currently returns a List of Store
entities directly, which breaks the API schema consistency and risks exposing
sensitive fields. Refactor this method to return a List of appropriate DTOs such
as StoreReadDto or a dedicated response class instead of the entity. Update the
method signature and implementation accordingly to map Store entities to the
DTOs before returning.

Comment on lines 95 to 98
@Override
public List<Store> searchStoresByName(String name) {
return storeRepository.findByNameContainingIgnoreCase(name);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

트랜잭션 옵션·삭제 필터·DTO 변환 누락

  1. readOnly 속성이 없어 불필요한 쓰기 락이 걸릴 수 있습니다.
  2. 삭제된 매장까지 함께 조회됩니다.
  3. 엔티티를 그대로 반환하여 외부 노출 위험이 있습니다.

아래와 같이 한 번에 개선해 주세요.

-	@Override
-	public List<Store> searchStoresByName(String name) {
-		return storeRepository.findByNameContainingIgnoreCase(name);
-	}
+	@Override
+	@Transactional(readOnly = true)
+	public List<StoreReadDto> searchStoresByName(String name) {
+		return storeRepository.findByNameContainingIgnoreCaseAndDeletedFalse(name)
+			.stream()
+			.map(StoreReadDto::fromEntity)
+			.toList();
+	}
📝 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
@Override
public List<Store> searchStoresByName(String name) {
return storeRepository.findByNameContainingIgnoreCase(name);
}
@Override
@Transactional(readOnly = true)
public List<StoreReadDto> searchStoresByName(String name) {
return storeRepository
.findByNameContainingIgnoreCaseAndDeletedFalse(name)
.stream()
.map(StoreReadDto::fromEntity)
.toList();
}
🤖 Prompt for AI Agents
In src/main/java/com/example/gtable/store/service/StoreServiceImpl.java around
lines 95 to 98, the searchStoresByName method lacks a readOnly transaction
annotation, does not filter out deleted stores, and returns entity objects
directly, risking external exposure. Add @Transactional(readOnly = true) to
optimize transaction handling, modify the repository query or add filtering to
exclude deleted stores, and convert the resulting entities to DTOs before
returning to prevent exposing internal entity details.

Comment on lines +91 to +100
@GetMapping("/search")
public ResponseEntity<?> searchStores(@RequestParam("name") String name) {
return ResponseEntity
.ok()
.body(
ApiUtils.success(
storeService.searchStoresByName(name)
)
);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

엔티티 직접 반환으로 API 응답 일관성/보안 문제
서비스가 Store 엔티티를 그대로 반환하므로 컨트롤러도 그대로 노출하고 있습니다. 기존 엔드포인트는 모두 DTO를 사용하므로 API 스키마가 달라집니다. 또한 내부 필드(삭제 플래그 등) 노출 가능성이 있습니다. 서비스·DTO 구조가 정리된 뒤 응답 타입도 함께 수정해 주세요.
추가로 name 파라미터에 대해 @NotBlank 등 검증을 적용하면 부적절한 요청을 미연에 방지할 수 있습니다.

🤖 Prompt for AI Agents
In src/main/java/com/example/gtable/store/controller/StoreController.java around
lines 91 to 100, the searchStores method currently returns Store entities
directly, causing inconsistency with other endpoints that use DTOs and risking
exposure of internal fields. Refactor the method to convert the Store entities
returned by storeService.searchStoresByName(name) into appropriate DTOs before
returning them in the response. Also, add validation annotation such as
@NotBlank to the 'name' request parameter to prevent invalid requests early.

@HyemIin HyemIin merged commit 3f47b85 into develop Jun 16, 2025
1 check passed
@HyemIin HyemIin deleted the feature/#26_Store검색 branch June 16, 2025 07:41
@coderabbitai coderabbitai bot mentioned this pull request Jun 16, 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.

2 participants