package de.votian.services.repository;

import de.votian.services.entity.ServiceZoneMapping;
import de.votian.services.entity.ServiceZoneMappingId;
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.Collection;
import java.util.List;

public interface ServiceZoneMappingRepository extends JpaRepository<ServiceZoneMapping, ServiceZoneMappingId> {

    List<ServiceZoneMapping> findByZoneIdIn(Collection<Long> zoneIds);

    @Modifying
    @Query("DELETE FROM ServiceZoneMapping szm WHERE szm.zoneId = :zoneId")
    void deleteByZoneId(@Param("zoneId") Long zoneId);
}
