diff --git a/src/main/java/com/fc/shimpyo_be/domain/product/util/ProductMapper.java b/src/main/java/com/fc/shimpyo_be/domain/product/util/ProductMapper.java index f5979b60..3f0969be 100644 --- a/src/main/java/com/fc/shimpyo_be/domain/product/util/ProductMapper.java +++ b/src/main/java/com/fc/shimpyo_be/domain/product/util/ProductMapper.java @@ -18,18 +18,19 @@ public class ProductMapper { public static ProductResponse toProductResponse(Product product) { + List rooms = product.getRooms(); + long price = rooms.isEmpty()? 0 : rooms.stream().map(PricePickerByDateUtil::getPrice) + .min((o1, o2) -> Math.toIntExact( + o1 - o2)).orElseThrow(); + price = price == 0 ? 100000: price; + return ProductResponse.builder().productId(product.getId()).productName(product.getName()) .address( product.getAddress().getAddress() + " " + product.getAddress().getDetailAddress()) .category(product.getCategory().getName()) .image(product.getThumbnail()) .starAvg(product.getStarAvg()) - .price(product.getRooms().isEmpty() - ? 0 : - product.getRooms().stream().map(PricePickerByDateUtil::getPrice) - .map(price->price==0?100000:price) - .min((o1, o2) -> Math.toIntExact(o1 - o2)) - .orElseThrow()) + .price(price) .capacity(product.getRooms().isEmpty() ? 0 : Long.valueOf( product.getRooms().stream().map(Room::getCapacity).min((o1, o2) -> o2 - o1) diff --git a/src/main/java/com/fc/shimpyo_be/domain/room/util/RoomMapper.java b/src/main/java/com/fc/shimpyo_be/domain/room/util/RoomMapper.java index f9ecb1dc..3a90c189 100644 --- a/src/main/java/com/fc/shimpyo_be/domain/room/util/RoomMapper.java +++ b/src/main/java/com/fc/shimpyo_be/domain/room/util/RoomMapper.java @@ -13,11 +13,14 @@ public static RoomResponse toRoomResponse(Room room) { boolean isPeakTime = PricePickerByDateUtil.isPeakTime(); boolean isWeekend = PricePickerByDateUtil.isWeekend(); + long price = PricePickerByDateUtil.getPrice(room); + price = price == 0 ? 100000 : price; + return RoomResponse.builder() .roomId(room.getId()) .roomName(room.getName()) // TODO 날짜에 따라 가격이 달라지므로 로직 수정이 필요함 - .price((PricePickerByDateUtil.getPrice(room))) + .price(price) .standard((long) (room.getStandard())) .capacity((long) room.getCapacity()) .description(room.getDescription())