package de.votian.services.repository;

import de.votian.services.entity.CustomerServiceAssignment;
import de.votian.services.entity.CustomerServiceAssignmentId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CustomerServiceAssignmentRepository extends JpaRepository<CustomerServiceAssignment, CustomerServiceAssignmentId> {

    List<CustomerServiceAssignment> findByCustomerIdOrderBySort(Long customerId);

    @Modifying
    @Query("DELETE FROM CustomerServiceAssignment csa WHERE csa.customerId = :customerId")
    void deleteByCustomerId(@Param("customerId") Long customerId);
}
