diff --git a/src/main/java/team7/inplace/place/application/PlaceService.java b/src/main/java/team7/inplace/place/application/PlaceService.java index 24e354f6..1ff63d1e 100644 --- a/src/main/java/team7/inplace/place/application/PlaceService.java +++ b/src/main/java/team7/inplace/place/application/PlaceService.java @@ -82,11 +82,26 @@ private Page getPlacesByDistance( List influencerFilters ) { return placeRepository.getPlacesByDistanceAndFilters( - placesCoordinateCommand.latitude(), + placesCoordinateCommand.topLeftLongitude(), + placesCoordinateCommand.topLeftLatitude(), + placesCoordinateCommand.bottomRightLongitude(), + placesCoordinateCommand.bottomRightLatitude(), placesCoordinateCommand.longitude(), + placesCoordinateCommand.latitude(), categoryFilters, influencerFilters, - placesCoordinateCommand.pageable()); + placesCoordinateCommand.pageable() + ); + } + + public PlaceDetailInfo getPlaceDetailInfo(Long placeId) { + Place place = placeRepository.findById(placeId) + .orElseThrow(() -> new IllegalArgumentException("PlaceService.getPlaceDetailInfo(): " + + "Place Id가 존재하지 않습니다.")); + Video video = videoRepository.findByPlaceId(placeId) + .orElseThrow(() -> new IllegalArgumentException("PlaceService.getPlaceDetailInfo(): " + + "Place Id가 존재하지 않습니다.")); + return PlaceDetailInfo.from(place, video.getInfluencer(), video); } public List createPlaces(List placeCommands) { @@ -114,4 +129,4 @@ public List createPlaces(List placeCommands) { return savedPlacesId; } -} +} \ No newline at end of file diff --git a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java index 5d005e03..376f2351 100644 --- a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java +++ b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java @@ -11,11 +11,14 @@ public class PlacesCommand { public record PlacesCoordinateCommand( + String topLeftLongitude, + String topLeftLatitude, + String bottomRightLongitude, + String bottomRightLatitude, String longitude, String latitude, Pageable pageable ) { - } public record PlacesFilterParamsCommand( diff --git a/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java b/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java index a90255db..a68cfee7 100644 --- a/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java +++ b/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java @@ -11,22 +11,22 @@ import team7.inplace.video.domain.Video; public record PlaceDetailInfo( - PlaceInfo placeInfo, - JsonNode facilityInfo, - MenuInfos menuInfos, - OpenHour openHour, - PlaceLikes placeLikes, - String videoUrl + PlaceInfo placeInfo, + JsonNode facilityInfo, + MenuInfos menuInfos, + OpenHour openHour, + PlaceLikes placeLikes, + String videoUrl ) { public static PlaceDetailInfo from(Place place, Influencer influencer, Video video) { return new PlaceDetailInfo( - PlaceInfo.of(place, influencer.getName()), - facilityTree(place.getFacility()), - MenuInfos.of(place.getMenus()), - OpenHour.of(place.getOpenPeriods(), place.getOffDays()), - PlaceLikes.of(null), //추후 추가 예정 - video.getVideoUrl() + PlaceInfo.of(place, influencer.getName()), + facilityTree(place.getFacility()), + MenuInfos.of(place.getMenus()), + OpenHour.of(place.getOpenPeriods(), place.getOffDays()), + PlaceLikes.of(null), //추후 추가 예정 + video.getVideoUrl() ); } @@ -41,72 +41,73 @@ private static JsonNode facilityTree(String facility) { public record MenuInfos( - List menuImgUrls, - List menuList, - LocalDateTime timeExp + List menuImgUrls, + List menuList, + LocalDateTime timeExp ) { public static MenuInfos of(List menus) { List menuImgUrls = menus.stream() - .map(Menu::getMenuImgUrl) // 메뉴 이미지 URL을 추출 - .toList(); + .map(Menu::getMenuImgUrl) // 메뉴 이미지 URL을 추출 + .toList(); List menuList = menus.stream() - .map(menu -> new MenuInfo(menu.getPrice().intValue(), menu.isRecommend(), - menu.getMenuName())) - .toList(); + .map(menu -> new MenuInfo(menu.getPrice().intValue(), menu.isRecommend(), + menu.getMenuName())) + .toList(); return new MenuInfos(menuImgUrls, menuList, LocalDateTime.now()); } public record MenuInfo( - Integer price, - Boolean recommend, - String menuName + Integer price, + Boolean recommend, + String menuName ) { } } public record OpenHour( - List periodList, - List offdayList + List periodList, + List offdayList ) { public static OpenHour of(List openTimes, - List closeTimes) { + List closeTimes + ) { List periods = openTimes.stream() - .map(time -> new Period(time.getTimeName(), time.getTimeSE(), time.getDayOfWeek())) - .toList(); + .map(time -> new Period(time.getTimeName(), time.getTimeSE(), time.getDayOfWeek())) + .toList(); List offDays = closeTimes.stream() - .map(closeTime -> new OffDay(closeTime.getHolidayName(), closeTime.getWeekAndDay(), - closeTime.getTemporaryHolidays())) - .toList(); + .map(closeTime -> new OffDay(closeTime.getHolidayName(), closeTime.getWeekAndDay(), + closeTime.getTemporaryHolidays())) + .toList(); return new OpenHour(periods, offDays); } public record Period( - String timeName, - String timeSE, - String dayOfWeek + String timeName, + String timeSE, + String dayOfWeek ) { } public record OffDay( - String holidayName, - String weekAndDay, - String temporaryHolidays + String holidayName, + String weekAndDay, + String temporaryHolidays ) { } } public record PlaceLikes( - Integer like, - Integer dislike + Integer like, + Integer dislike ) { public static PlaceLikes of(Boolean likes) { diff --git a/src/main/java/team7/inplace/place/domain/Menu.java b/src/main/java/team7/inplace/place/domain/Menu.java index a7951cde..316d6e1c 100644 --- a/src/main/java/team7/inplace/place/domain/Menu.java +++ b/src/main/java/team7/inplace/place/domain/Menu.java @@ -22,6 +22,9 @@ public class Menu { @Column(length = 50, nullable = false) private String menuName; + @Column(length = 50) + private String menuImgUrl; + private Menu(Long price, boolean recommend, String menuName) { this.price = price; this.recommend = recommend; diff --git a/src/main/java/team7/inplace/place/domain/OffDay.java b/src/main/java/team7/inplace/place/domain/OffDay.java index d79ac337..f5783a4e 100644 --- a/src/main/java/team7/inplace/place/domain/OffDay.java +++ b/src/main/java/team7/inplace/place/domain/OffDay.java @@ -17,7 +17,7 @@ public class OffDay { private String temporaryHolidays; private OffDay(String holydayName, String weekAndDay, String temporaryHolidays) { - this.holydayName = holydayName; + this.holidayName = holydayName; this.weekAndDay = weekAndDay; this.temporaryHolidays = temporaryHolidays; }