package com.jasamedika.medifirst2000.dao;

import java.util.Map;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.FactoRateKelompokShift;

@Repository("FactorRateKelompokShiftDao")
public interface FactorRateKelompokShiftDao extends PagingAndSortingRepository<FactoRateKelompokShift, String> {

	@Query("select new map(kelompokShift.name as namaShift, "+
		   "factoRateKelompokShift.noRec as noRec, "+
		   "factoRateKelompokShift.factorRate as factorRate, "+
		   "factoRateKelompokShift.hari as hari, "+
		   "factoRateKelompokShift.periode as periode) "+
		   "from FactoRateKelompokShift factoRateKelompokShift "+
		   "left join factoRateKelompokShift.kelompokShift kelompokShift "+
		   "where factoRateKelompokShift.periode = :periode and kelompokShift.id = :idKelompokShift") 
	public Map<String,Object> findFactorRateKelompokShift(@Param("idKelompokShift") Integer idKelompokShift, @Param("periode") String periode);
	
	@Query("select factoRateKelompokShift.factorRate "+
			   "from FactoRateKelompokShift factoRateKelompokShift "+
			   "left join factoRateKelompokShift.kelompokShift kelompokShift "+
			   "where factoRateKelompokShift.periode = :periode and kelompokShift.id = :idKelompokShift") 
	public Integer findFactorRateForEachKelompokShift(@Param("idKelompokShift") Integer idKelompokShift, @Param("periode") String periode);

}
