Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@Builder
public class CartResponse {
private List<CartItemDto> items;
private int totalQuantity;
private int totalPrice;
private Long cartId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ public CartResponse updateCartItem(Long menuId, int quantity) {
.mapToInt(item->item.getPrice() * item.getQuantity())
.sum();

int totalQuantity = cartItems.stream()
.mapToInt(CartItemDto::getQuantity)
.sum();

return CartResponse.builder().
items(cartItems)
.totalPrice(totalPrice)
.totalQuantity(totalQuantity)
.cartId(cart.getCartId())
.build();
}
Expand Down Expand Up @@ -151,9 +156,14 @@ public CartResponse getCart(){
.mapToInt(item->item.getPrice() * item.getQuantity())
.sum();

int totalQuantity = cartItems.stream()
.mapToInt(CartItemDto::getQuantity)
.sum();

return CartResponse.builder().
items(cartItems)
.totalPrice(totalPrice)
.totalQuantity(totalQuantity)
.cartId(cart.get().getCartId())
.build();
}
Expand Down