package common.repository;

import common.model.DmpIncome;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DmpIncomeRepository extends JpaRepository<DmpIncome, Long> {

    @Query(value = "select * from dmp_income where contract_code = ?1 order by income_month", nativeQuery = true)
    List<DmpIncome> findByContractCode(String contractCode);

    @Query(value = "select * from dmp_income where income_month >= ?1 and income_month <=?2 order by income_month", nativeQuery = true)
    List<DmpIncome> findByContractDs(String start, String end);

    @Query(value = "select * from dmp_income where contract_code = ?1 and  income_month =?2 limit 1 ", nativeQuery = true)
    DmpIncome findByCodeMonth(String contractCode, String incomeMonth);
}