Skip to content

Commit

Permalink
Merge branch 'main' of github.com:KBTG-Kampus-ClassNest-SE-Java/works…
Browse files Browse the repository at this point in the history
…hopb2-group-3
  • Loading branch information
n-jaisabai committed Mar 31, 2024
2 parents 3d4d50c + 00795cc commit 4cf7f64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,6 +111,7 @@ public ResponseEntity addProductPromotion(String userName, PromotionRequest prom
Optional<Promotion> promotion =
promotionRepository.findByCode(promotionRequest.promotionCode());
Optional<Product> product = productRepository.findBySku(promotionRequest.productSku());
// System.out.println(product);

return null;
}
Expand Down

0 comments on commit 4cf7f64

Please sign in to comment.