package br.gov.sigefp.rh.repository;

import br.gov.sigefp.rh.domain.SalaryGrid;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;

@Repository
public interface SalaryGridRepository extends JpaRepository<SalaryGrid, UUID> {

    @Query("SELECT g FROM SalaryGrid g WHERE g.step.id = :stepId AND :date BETWEEN g.validFrom AND COALESCE(g.validTo, '2999-12-31')")
    SalaryGrid findByStepIdAndDate(@Param("stepId") UUID stepId, @Param("date") LocalDate date);

    List<SalaryGrid> findByStepId(UUID stepId);
}
