From c384fdb91f569d7793648e0cdb8857c3558b2ad7 Mon Sep 17 00:00:00 2001 From: WorabordinC Date: Sun, 31 Mar 2024 13:11:38 +0700 Subject: [PATCH] clean comment --- .../com/kampus/kbazaar/cart/CartService.java | 48 ++----------------- 1 file changed, 3 insertions(+), 45 deletions(-) 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 b30649d..a20372c 100644 --- a/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java +++ b/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java @@ -1,6 +1,5 @@ package com.kampus.kbazaar.cart; -import com.kampus.kbazaar.cartitem.CartItemRepository; import com.kampus.kbazaar.cartitem.CartItemService; import com.kampus.kbazaar.promotion.PromotionApplyCartRequest; import com.kampus.kbazaar.shopper.Shopper; @@ -11,8 +10,6 @@ @Service public class CartService { - private final CartRepository cartRepository; - private final CartItemRepository cartItemRepository; private final CartItemService cartItemService; private final ShopperRepository shopperRepository; @@ -22,13 +19,7 @@ public CartResponse applyCartPromotion( return new CartResponse(); } - public CartService( - CartRepository cartRepository, - CartItemRepository cartItemRepository, - ShopperRepository shopperRepository, - CartItemService cartItemService) { - this.cartRepository = cartRepository; - this.cartItemRepository = cartItemRepository; + public CartService(ShopperRepository shopperRepository, CartItemService cartItemService) { this.shopperRepository = shopperRepository; this.cartItemService = cartItemService; } @@ -40,41 +31,8 @@ public List getAllCart() { List usernameList = shopperRepository.findAll().stream().map(Shopper::getUsername).toList(); - // for loop getcartby usernam - List carts = - usernameList.stream().map(cartItemService::getCartByUsername).toList(); + // for loop get cart by username - return carts; + return usernameList.stream().map(cartItemService::getCartByUsername).toList(); } - - // public List getAllCart() { - // List carts = cartRepository.findAll(); - // List cartResponseDto = new ArrayList<>(); - // for (Cart cart : carts) { - // List cartItems = cartItemRepository.findByUsername(cart.getUsername()); - // List cartItemDtos = new ArrayList<>(); - // for (CartItem cartItem : cartItems) { - // cartItemDtos.add( - // new CartItemDto( - // cartItem.getId(), - // cartItem.getUsername(), - // cartItem.getSku(), - // cartItem.getPrice(), - // cartItem.getQuantity(), - // cartItem.getDiscount(), - // cartItem.getPromotionCodes())); - // } - // - // CartResponseDto cartResponse = - // new CartResponseDto( - // cart.getUsername(), - // cartItemDtos, - // cart.getDiscount(), - // cart.getTotalDiscount(), - // cart.getSubtotal(), - // cart.getGrandTotal()); - // } - // - // return cartResponseDto; - // } }