-
Notifications
You must be signed in to change notification settings - Fork 0
feat(store): store 검색 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feature/#26_Store\uAC80\uC0C9"
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,10 +1,13 @@ | ||||||
| package com.example.gtable.store.service; | ||||||
|
|
||||||
| import java.util.List; | ||||||
|
|
||||||
| import com.example.gtable.store.dto.StoreCreateRequest; | ||||||
| import com.example.gtable.store.dto.StoreCreateResponse; | ||||||
| import com.example.gtable.store.dto.StoreReadDto; | ||||||
| import com.example.gtable.store.dto.StoreReadResponse; | ||||||
| import com.example.gtable.store.dto.StoreUpdateRequest; | ||||||
| import com.example.gtable.store.model.Store; | ||||||
|
|
||||||
| public interface StoreService { | ||||||
|
|
||||||
|
|
@@ -18,4 +21,6 @@ public interface StoreService { | |||||
|
|
||||||
| String deleteStore(Long storeId); | ||||||
|
|
||||||
| List<Store> searchStoresByName(String name); | ||||||
|
|
||||||
|
||||||
| 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.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -91,4 +91,10 @@ public String deleteStore(Long storeId) { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return "Store ID " + storeId + " 삭제되었습니다."; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||
| public List<Store> searchStoresByName(String name) { | ||||||||||||||||||||||||||||
| return storeRepository.findByNameContainingIgnoreCase(name); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 트랜잭션 옵션·삭제 필터·DTO 변환 누락
아래와 같이 한 번에 개선해 주세요. - @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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
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