package de.votian.services.repository;

import de.votian.services.entity.EmployeeRights;
import de.votian.services.entity.EmployeeRightsId;
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 EmployeeRightsRepository extends JpaRepository<EmployeeRights, EmployeeRightsId> {

    List<EmployeeRights> findByEmployeeId(Long employeeId);

    @Modifying
    @Query("DELETE FROM EmployeeRights er WHERE er.employeeId = :empId")
    void deleteByEmployeeId(@Param("empId") Long empId);

    @Modifying
    @Query("DELETE FROM EmployeeRights er WHERE er.employeeId = :empId AND er.headquartersId IN :hqIds")
    void deleteByEmployeeIdAndHqIds(@Param("empId") Long empId, @Param("hqIds") List<Long> hqIds);
}
