package de.votian.services.repository;

import de.votian.services.entity.CustomerServiceTypeAssignment;
import de.votian.services.entity.CustomerServiceTypeAssignmentId;
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 CustomerServiceTypeAssignmentRepository extends JpaRepository<CustomerServiceTypeAssignment, CustomerServiceTypeAssignmentId> {

    List<CustomerServiceTypeAssignment> findByCustomerIdOrderBySort(Long customerId);

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