diff --git a/src/main/java/com/jangburich/domain/order/application/OrderService.java b/src/main/java/com/jangburich/domain/order/application/OrderService.java index 1f29350..df28e01 100644 --- a/src/main/java/com/jangburich/domain/order/application/OrderService.java +++ b/src/main/java/com/jangburich/domain/order/application/OrderService.java @@ -100,20 +100,22 @@ public CartResponse getCartItems(String userProviderId) { List carts = cartRepository.findAllByUserAndStatus(user, Status.ACTIVE); if (carts.isEmpty()) { - return CartResponse.of(List.of(), 0); + return CartResponse.of(null, null, null, List.of(), 0); } List cartItems = carts.stream() .map(cart -> GetCartItemsResponse.of( - cart.getMenu().getName(), - cart.getMenu().getDescription(), - cart.getQuantity(), - cart.getMenu().getPrice() + cart.getMenu().getId(), + cart.getMenu().getImageUrl(), + cart.getMenu().getName(), + cart.getMenu().getDescription(), + cart.getQuantity(), + cart.getMenu().getPrice() )) .toList(); int discountAmount = 0; - CartResponse cartResponse = CartResponse.of(cartItems, discountAmount); + CartResponse cartResponse = CartResponse.of(carts.get(0).getStore().getId(), carts.get(0).getStore().getName(), carts.get(0).getStore().getCategory().getDisplayName(), cartItems, discountAmount); return cartResponse; } diff --git a/src/main/java/com/jangburich/domain/order/dto/response/CartResponse.java b/src/main/java/com/jangburich/domain/order/dto/response/CartResponse.java index 08df2e6..8655a6c 100644 --- a/src/main/java/com/jangburich/domain/order/dto/response/CartResponse.java +++ b/src/main/java/com/jangburich/domain/order/dto/response/CartResponse.java @@ -1,14 +1,18 @@ package com.jangburich.domain.order.dto.response; +import com.jangburich.domain.store.domain.Category; import java.util.List; public record CartResponse( + Long storeId, + String storeName, + String storeCategory, List cartItems, Integer totalAmount, Integer discountAmount, Integer finalAmount ) { - public static CartResponse of(List cartItems, Integer discountAmount) { + public static CartResponse of(Long storeId, String storeName, String storeCategory, List cartItems, Integer discountAmount) { int totalAmount = cartItems.stream() .mapToInt(item -> item.menuPrice() * item.quantity()) .sum(); @@ -17,7 +21,7 @@ public static CartResponse of(List cartItems, Integer disc int finalAmount = totalAmount - discountAmount; - return new CartResponse(cartItems, totalAmount, discountAmount, finalAmount); + return new CartResponse(storeId, storeName, storeCategory, cartItems, totalAmount, discountAmount, finalAmount); } } diff --git a/src/main/java/com/jangburich/domain/order/dto/response/GetCartItemsResponse.java b/src/main/java/com/jangburich/domain/order/dto/response/GetCartItemsResponse.java index 1c0b120..74b0d07 100644 --- a/src/main/java/com/jangburich/domain/order/dto/response/GetCartItemsResponse.java +++ b/src/main/java/com/jangburich/domain/order/dto/response/GetCartItemsResponse.java @@ -1,13 +1,15 @@ package com.jangburich.domain.order.dto.response; public record GetCartItemsResponse( + Long menuId, + String menuImg, String menuName, String menuDescription, Integer quantity, Integer menuPrice ) { - public static GetCartItemsResponse of(String menuName, String menuDescription, Integer quantity, + public static GetCartItemsResponse of(Long menuId, String menuImg, String menuName, String menuDescription, Integer quantity, Integer menuPrice) { - return new GetCartItemsResponse(menuName, menuDescription, quantity, menuPrice); + return new GetCartItemsResponse(menuId, menuImg, menuName, menuDescription, quantity, menuPrice); } }