Skip to content

Commit

Permalink
clean comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stormer-wc committed Mar 31, 2024
1 parent 36b3277 commit c384fdb
Showing 1 changed file with 3 additions and 45 deletions.
48 changes: 3 additions & 45 deletions kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,8 +10,6 @@
@Service
public class CartService {

private final CartRepository cartRepository;
private final CartItemRepository cartItemRepository;
private final CartItemService cartItemService;

private final ShopperRepository shopperRepository;
Expand All @@ -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;
}
Expand All @@ -40,41 +31,8 @@ public List<CartResponse> getAllCart() {
List<String> usernameList =
shopperRepository.findAll().stream().map(Shopper::getUsername).toList();

// for loop getcartby usernam
List<CartResponse> carts =
usernameList.stream().map(cartItemService::getCartByUsername).toList();
// for loop get cart by username

return carts;
return usernameList.stream().map(cartItemService::getCartByUsername).toList();
}

// public List<CartResponse> getAllCart() {
// List<Cart> carts = cartRepository.findAll();
// List<CartResponse> cartResponseDto = new ArrayList<>();
// for (Cart cart : carts) {
// List<CartItem> cartItems = cartItemRepository.findByUsername(cart.getUsername());
// List<CartItemDto> 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;
// }
}

0 comments on commit c384fdb

Please sign in to comment.