-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [feat] 구매자 매장 상세 조회 서비스 * [feat] 구매자 매장 상세 조회 Response 객체 - 구매자는 기본적인 매장 상세 정보를 확인할 수 있어야 함 * [feat] 가게주소, 가게카테고리에 대한 getter 추가 호출자 쪽에서의 getter depth 를 줄이기 위함 * [feat] 가게 id로 메뉴 목록을 조회하는 기능 * [feat] 가게 전시 응답에 가게 메뉴를 포함 * [feat] getter 추가 * [feat] 가게 전시 API 엔드포인트 구현 * [refactor] 가게 전시 메서드 이름 변경 * [test] 가게 전시 서비스 계층 단위 테스트 - responseDTO 을 적절히 매핑하여 반환하는지 테스트하기 위함 * [test] 가게 전시 API 컨트롤러 계층 단위 테스트 - API response 명세를 검증 및 추적하기 위함 * [text] 가게 조회 API 단위 테스트 - 메뉴 리스트 검증하도록 수정 및 테스트 * [merge] 머지 컨플릭트 해결
- Loading branch information
Showing
11 changed files
with
412 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/camp/woowak/lab/store/service/StoreDisplayService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package camp.woowak.lab.store.service; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import camp.woowak.lab.menu.domain.Menu; | ||
import camp.woowak.lab.menu.repository.MenuRepository; | ||
import camp.woowak.lab.store.domain.Store; | ||
import camp.woowak.lab.store.exception.NotFoundStoreException; | ||
import camp.woowak.lab.store.repository.StoreRepository; | ||
import camp.woowak.lab.store.service.response.StoreDisplayResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class StoreDisplayService { | ||
|
||
private final StoreRepository storeRepository; | ||
private final MenuRepository menuRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public StoreDisplayResponse displayStore(final Long storeId) { | ||
Store store = findStoreById(storeId); | ||
List<Menu> storeMenus = findMenusByStore(store.getId()); | ||
|
||
return StoreDisplayResponse.of(store, mapFrom(storeMenus)); | ||
} | ||
|
||
private Store findStoreById(final Long storeId) { | ||
return storeRepository.findById(storeId) | ||
.orElseThrow(() -> new NotFoundStoreException(storeId + "의 가게를 찾을 수 없습니다.")); | ||
} | ||
|
||
private List<Menu> findMenusByStore(final Long storeId) { | ||
return menuRepository.findByStoreId(storeId); | ||
} | ||
|
||
private List<StoreDisplayResponse.MenuDisplayResponse> mapFrom(final List<Menu> menus) { | ||
return menus.stream() | ||
.map(StoreDisplayResponse.MenuDisplayResponse::of) | ||
.toList(); | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/camp/woowak/lab/store/service/response/StoreDisplayResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package camp.woowak.lab.store.service.response; | ||
|
||
import java.time.LocalTime; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import camp.woowak.lab.menu.domain.Menu; | ||
import camp.woowak.lab.store.domain.Store; | ||
|
||
public record StoreDisplayResponse( | ||
|
||
Long storeId, | ||
String storeName, | ||
String storeAddress, | ||
String storePhoneNumber, | ||
Integer storeMinOrderPrice, | ||
|
||
Long storeCategoryId, | ||
String storeCategoryName, | ||
|
||
LocalTime storeStartTime, | ||
LocalTime storeEndTime, | ||
|
||
UUID vendorId, | ||
String vendorName, | ||
|
||
List<MenuDisplayResponse> menus | ||
) { | ||
|
||
public static StoreDisplayResponse of(final Store store, final List<MenuDisplayResponse> menus) { | ||
return new StoreDisplayResponse( | ||
store.getId(), | ||
store.getName(), | ||
store.getStoreAddress(), | ||
store.getPhoneNumber(), | ||
store.getMinOrderPrice(), | ||
|
||
store.getStoreCategoryId(), | ||
store.getStoreCategoryName(), | ||
|
||
store.getStoreStartTime(), | ||
store.getStoreEndTime(), | ||
|
||
store.getVendorId(), | ||
store.getVendorName(), | ||
menus | ||
); | ||
} | ||
|
||
public record MenuDisplayResponse( | ||
Long menuCategoryId, | ||
String menuCategoryName, | ||
|
||
Long menuId, | ||
String menuName, | ||
Long menuPrice | ||
) { | ||
|
||
public static MenuDisplayResponse of(final Menu menu) { | ||
return new MenuDisplayResponse( | ||
menu.getMenuCategoryId(), | ||
menu.getMenuCategoryName(), | ||
|
||
menu.getId(), | ||
menu.getName(), | ||
menu.getPrice() | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.