Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/com/clone/animan/controller/CartController.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public void createCart(@PathVariable Long productId, @RequestBody CartRequestDto
cartService.createCart(productId, requestDto);
}

@PutMapping("/cart/update/{productId}")
public void updateCart(@PathVariable Long productId, @RequestBody CartRequestDto requestDto) {
cartService.updateQuantityCart(productId, requestDto);
}

@DeleteMapping("/cart/{cartId}")
public void deleteCart(@PathVariable Long cartId) {
cartService.deleteCart(cartId);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/clone/animan/dto/CartRequestDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@Getter
public class CartRequestDto {
private Long cartId;
private Long quantity;
private Long productId;
private String title;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/clone/animan/service/CartService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public void updateCart(String username, Long productId, Long quantity) {
cartRepository.save(cart);
}

public void updateQuantityCart(Long productId, CartRequestDto requestDto) {
String username = requestDto.getUsername();
Long quantity = requestDto.getQuantity();
Cart cart = cartRepository.findByProductIdAndUsername(productId, username);
cart.update(quantity);
cartRepository.save(cart);
}

public void deleteCart(Long cartId){
cartRepository.deleteById(cartId);
}
Expand Down