-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/상품조회 #9
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/\uC0C1\uD488\uC870\uD68C"
Feature/상품조회 #9
Changes from all commits
83221dc
3e2edf0
87dca7b
ea07f4b
c04fcbc
42e8674
3ad33f1
38047ee
84a11dc
1ea84d6
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.yscp.catchtable.application.amenity; | ||
|
|
||
| import com.yscp.catchtable.domain.amenity.repository.AmenityRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class AmenityReadService { | ||
| private final AmenityRepository amenityRepository; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.yscp.catchtable.application.amenity; | ||
|
|
||
| import com.yscp.catchtable.application.amenity.dto.StoreAmenityDto; | ||
| import com.yscp.catchtable.domain.amenity.entity.StoreAmenity; | ||
| import com.yscp.catchtable.domain.amenity.repository.StoreAmenityRepository; | ||
| import com.yscp.catchtable.exception.BadRequestError; | ||
| import com.yscp.catchtable.exception.CatchTableException; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| @Service | ||
| public class StoreAmenityReadService { | ||
| private final StoreAmenityRepository storeAmenityRepository; | ||
|
|
||
| public List<StoreAmenity> findByStoreIdx(Long idx) { | ||
| if (idx == null) { | ||
| throw new CatchTableException(BadRequestError.NULL_EXCEPTION, "상품이 존재하지 않습니다."); | ||
| } | ||
|
|
||
| return storeAmenityRepository.findByStoreIdx(idx); | ||
| } | ||
|
|
||
| public List<StoreAmenityDto> findAmenityDtoByStoreIdx(Long idx) { | ||
| return findByStoreIdx(idx) | ||
| .stream() | ||
| .map(StoreAmenityDto::from) | ||
| .toList(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.yscp.catchtable.application.amenity.dto; | ||
|
|
||
| import com.yscp.catchtable.domain.amenity.entity.StoreAmenity; | ||
|
|
||
| public record StoreAmenityDto( | ||
| String code, | ||
| String memo, | ||
| String image | ||
| ) { | ||
|
|
||
| public static StoreAmenityDto from(StoreAmenity amenity) { | ||
| return new StoreAmenityDto(amenity.getAmenity().getCode(), | ||
| amenity.getMemo(), | ||
| amenity.getAmenity().getImageUrl()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.yscp.catchtable.application.location.dto; | ||
|
|
||
| import org.locationtech.jts.geom.Point; | ||
|
|
||
| public record LocationDto( | ||
| String addressCode, | ||
| String name, | ||
| double xCoordinate, | ||
| double yCoordinate | ||
| ) { | ||
| public LocationDto(String addressCode, String name, Point point) { | ||
| this(addressCode, name, point.getX(), point.getY()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.yscp.catchtable.application.menu; | ||
|
|
||
| import com.yscp.catchtable.application.menu.dto.MenuDto; | ||
| import com.yscp.catchtable.domain.menu.entity.Menu; | ||
| import com.yscp.catchtable.domain.menu.entity.sort.MenuSort; | ||
| import com.yscp.catchtable.domain.menu.repository.MenuRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| @Service | ||
| public class MenuReadService { | ||
| private final MenuRepository menuRepository; | ||
|
|
||
| public List<Menu> findByStoreIdx(Long idx, MenuSort menuSort) { | ||
| Objects.requireNonNull(idx, "Store idx must not be null"); | ||
|
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.
Collaborator
Author
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.
추가적으로 도메인에 대한 NPE 관련 에러는 미리 만들어두고 사용하는 편일까요?
|
||
| return menuRepository.findByStoreIdx(idx, menuSort.getSort()); | ||
| } | ||
|
|
||
| public List<MenuDto> findMenuDtoByStoreIdx(Long idx, MenuSort menuSort) { | ||
|
|
||
| return findByStoreIdx(idx, menuSort) | ||
| .stream() | ||
| .map(MenuDto::from) | ||
| .toList(); | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.yscp.catchtable.application.menu.dto; | ||
|
|
||
| import com.yscp.catchtable.domain.menu.entity.Menu; | ||
|
|
||
| public record MenuDto( | ||
| Long idx, | ||
| String name, | ||
| String menuImageUrl | ||
| ) { | ||
| public static MenuDto from(Menu menu) { | ||
| return new MenuDto(menu.getIdx(), menu.getName(), menu.getImageUrl()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| package com.yscp.catchtable.application.store; | ||
|
|
||
| import com.yscp.catchtable.application.store.dto.StoreBusinessDto; | ||
| import com.yscp.catchtable.domain.store.entity.value.DayType; | ||
| import com.yscp.catchtable.domain.store.repository.StoreBusinessHourRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.function.Function; | ||
|
|
@@ -17,10 +19,15 @@ | |
| public class StoreBusinessHourService { | ||
| private final StoreBusinessHourRepository storeBusinessHourRepository; | ||
|
|
||
| public Map<Long, StoreBusinessDto> findBusinessMap(List<Long> idxes) { | ||
| return storeBusinessHourRepository.findByStoreIdxIn(idxes) | ||
| public Map<Long, StoreBusinessDto> findBusinessMap(List<Long> idxes, LocalDate localDate) { | ||
| DayType day = DayType.from(localDate); | ||
| return storeBusinessHourRepository.findByStoreIdxIn(idxes, day) | ||
|
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. LocalDate.now()가 있어서 테스트가 어려워 질 수 있겠는데용?
Collaborator
Author
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. 제일 외부 층인 컨트롤러에서 시간을 가져올 수 있도록 기능을 수정하겠습니다! |
||
| .stream() | ||
| .map(StoreBusinessDto::from) | ||
| .collect(Collectors.toMap(StoreBusinessDto::getStoreIdx, Function.identity())); | ||
| } | ||
|
|
||
| public List<StoreBusinessDto> findByStoreIdx(Long storeIdx) { | ||
| return storeBusinessHourRepository.findByStoreIdx(storeIdx); | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package com.yscp.catchtable.application.store; | ||
|
|
||
| import com.yscp.catchtable.application.amenity.StoreAmenityReadService; | ||
| import com.yscp.catchtable.application.amenity.dto.StoreAmenityDto; | ||
| import com.yscp.catchtable.application.location.dto.LocationDto; | ||
| import com.yscp.catchtable.application.menu.MenuReadService; | ||
| import com.yscp.catchtable.application.menu.dto.MenuDto; | ||
| import com.yscp.catchtable.application.reserve.ReserveService; | ||
| import com.yscp.catchtable.application.reserve.dto.ReserveDto; | ||
| import com.yscp.catchtable.application.reserve.dto.StoreReserveDto; | ||
| import com.yscp.catchtable.application.store.dto.StoreBusinessDto; | ||
| import com.yscp.catchtable.application.store.dto.StoreDetailDto; | ||
| import com.yscp.catchtable.application.store.dto.StoreDtos; | ||
| import com.yscp.catchtable.domain.menu.entity.sort.MenuSort; | ||
| import com.yscp.catchtable.domain.store.entity.Store; | ||
| import com.yscp.catchtable.domain.store.entity.Stores; | ||
| import com.yscp.catchtable.presentation.store.dto.request.StoreSearchRequestDto; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| @Service | ||
| public class StoreReader { | ||
| private final StoreReadService storeReadService; | ||
| private final StoreBusinessHourService storeBusinessHourService; | ||
| private final ReserveService reserveService; | ||
| private final MenuReadService menuReadservice; | ||
| private final StoreAmenityReadService amenityReadService; | ||
|
|
||
| public StoreDtos getStoreListDto(StoreSearchRequestDto storeSearchRequestDto, LocalDate date) { | ||
| Stores stores = Stores.from(storeReadService.findBySearchDto(storeSearchRequestDto.toSearchDto())); | ||
|
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. 어디는 list를 사용하시고 아래에는 es라는 복수를 사용하시네요 |
||
|
|
||
| List<Long> idxes = stores.idxes(); | ||
|
|
||
| Map<Long, List<StoreReserveDto>> reserveDtoMap = reserveService.findReserveDtoMapByStores(idxes, | ||
| date.plusDays(14)); | ||
|
|
||
| Map<Long, StoreBusinessDto> businessHourMap = storeBusinessHourService.findBusinessMap(idxes, date); | ||
| return StoreDtos.of(stores, | ||
| reserveDtoMap, | ||
| businessHourMap); | ||
| } | ||
|
|
||
| public StoreDetailDto getStoreDetailDto(Long idx, LocalDate date) { | ||
| Store store = storeReadService.findByIdx(idx); | ||
|
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. 요기는 get or find을 붙이지 않는 이유는 무엇인가요?
Collaborator
Author
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라는 네이밍으로 유추할 수 있다고 생각했는데, 동사로 시작해야 하는 규칙을 깬 것 같아 수정하겠습니다! |
||
| List<ReserveDto> reserveDtoList = reserveService.findReserveDtos(store.getIdx(), date.plusDays(14)); | ||
| // 메뉴 조회 | ||
| List<MenuDto> menuList = menuReadservice.findMenuDtoByStoreIdx(store.getIdx(), MenuSort.ORD_DESC); | ||
| // 편의시설 조회 | ||
| List<StoreAmenityDto> storeAmenities = amenityReadService.findAmenityDtoByStoreIdx(store.getIdx()); | ||
| // 영업시간 조회 | ||
| List<StoreBusinessDto> businessDto = storeBusinessHourService.findByStoreIdx(store.getIdx()); | ||
| // 위치정보 조회 | ||
| LocationDto locationDto = new LocationDto(store.getAddressCode(), | ||
| store.getLocationName(), | ||
| store.getPoint()); | ||
|
|
||
| return new StoreDetailDto( | ||
| store.getIdx(), | ||
| store.getCategory().getName(), | ||
| store.getTel(), | ||
| store.getIntroduce(), | ||
| store.getFeeInformation(), | ||
| locationDto, | ||
| reserveDtoList, | ||
| menuList, | ||
| storeAmenities, | ||
| businessDto | ||
| ); | ||
| } | ||
| } | ||
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.
포인트의 맥락에서는 x, y가 맞는 것 같기는한데요
location의 xCoor~와 다르게 한 이유가 있나요?
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.
@f-lab-k
라이브러리에서 제공해주는 메소드를 쓰고있는 부분인데 location에서 동일한 형태로 맞출 때
메소드명이 구체적이지 않은 것 같아.. 우선 임의로 수정했습니다!