Skip to content

Commit

Permalink
#103 feature: 방 및 숙소 응답 가격이 0원일 떄, 기본적으로 100,000을
Browse files Browse the repository at this point in the history
      응답으로 보내게 수정
  • Loading branch information
wocjf0513 committed Dec 10, 2023
1 parent 85ee29b commit 5896626
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ public class ProductMapper {

public static ProductResponse toProductResponse(Product product) {

List<Room> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 5896626

Please sign in to comment.