package com.maternalmall.repository;

import com.maternalmall.domain.CartItem;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

public interface CartItemRepository extends JpaRepository<CartItem, Long> {
    List<CartItem> findByCustomerId(Long customerId);
    Optional<CartItem> findByCustomerIdAndProductId(Long customerId, Long productId);

    @Modifying
    @Transactional
    void deleteByCustomerIdAndProductId(Long customerId, Long productId);

    @Modifying
    @Transactional
    void deleteByCustomerId(Long customerId);
}
