diff --git a/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartController.java b/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartController.java index 667905b..8585f44 100644 --- a/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartController.java +++ b/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartController.java @@ -1,5 +1,6 @@ package com.kampus.kbazaar.cart; +import com.kampus.kbazaar.promotion.PromotionRequest; import java.util.List; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -27,8 +28,9 @@ public CartResponse addProduct(@RequestBody CartRequest cartRequest, @PathVariab @PostMapping("/cart/{username}/promotions") public ResponseEntity addPromotionToProduct( - @PathVariable() String username, CartRequest cartRequest) { - cartService.addProduct(cartRequest); + @PathVariable("username") String username, + @RequestBody() PromotionRequest promotionRequest) { + cartService.addProductPromotion(username, promotionRequest); return new ResponseEntity<>("System.", HttpStatus.OK); } } 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 3733740..9726595 100644 --- a/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java +++ b/kbazaar/src/main/java/com/kampus/kbazaar/cart/CartService.java @@ -25,7 +25,8 @@ public class CartService { public CartService( CartRepository cartRepository, CartItemRepository cartItemRepository, - ProductRepository productRepository) { + ProductRepository productRepository, + PromotionRepository promotionRepository) { this.cartRepository = cartRepository; this.cartItemRepository = cartItemRepository; this.productRepository = productRepository; @@ -110,6 +111,7 @@ public ResponseEntity addProductPromotion(String userName, PromotionRequest prom Optional promotion = promotionRepository.findByCode(promotionRequest.promotionCode()); Optional product = productRepository.findBySku(promotionRequest.productSku()); + // System.out.println(product); return null; }