From a570aa2f9c161acd4675ae7910dc38cdb8664104 Mon Sep 17 00:00:00 2001 From: naruepracht Date: Sun, 24 Mar 2024 12:59:27 +0700 Subject: [PATCH] fix issue return one object --- kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java b/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java index 5541d01..fe4e1e0 100644 --- a/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java +++ b/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java @@ -71,6 +71,7 @@ public ApplyCodeResponse applyCode(String username, ApplyCodeRequest request) { @Transactional public CreateCartResponse createCart(String userName, CartRequest cartRequest) { CreateCartResponse response = new CreateCartResponse(); + response.setItems(new ArrayList<>()); Optional shopper = shopperRepository.findByUsername(userName); Optional checkShopperHaveCart = cartRepository.findByShopperId(shopper.get().getId()); @@ -115,7 +116,6 @@ public CreateCartResponse createCart(String userName, CartRequest cartRequest) { item.getFinalPrice()); totalPriceForReturn = item.getFinalPrice().plus(); totalDiscountForReturn = item.getDiscount().plus(); - response.setItems(new ArrayList<>()); response.getItems().add(cartItem); } if (enableShippingFee) {