package com.jasamedika.medifirst2000.dao;

import java.util.Map;

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

import com.jasamedika.medifirst2000.entities.PegawaiHistoriRekap;

@Repository("PegawaiHistoriRekapDao")
public interface PegawaiHistoriRekapDao extends CrudRepository<PegawaiHistoriRekap, Integer> {
	@Query("select new Map(model.totalHargaGajiAdd as totalGajiAdd,"
			+ "model.totalHargaGajiMin as totalGajiMin,"
			+ "pegawai.id as pegawaiId) "
			+"from PegawaiHistoriRekap model "
			+"left join model.strukHistory strukhistory "
			+"left join model.pegawai pegawai "
			+"where strukhistory.noRec=:noRecStrukHistori " 
			+"and pegawai.id=:idPegawai")
	Map<String,Object> getTotalHarga(@Param("noRecStrukHistori")String noRecStrukHistori,
			@Param("idPegawai")Integer idPegawai);
	
	@Query("select pegawaiHistoriRekap "+
			"from PegawaiHistoriRekap pegawaiHistoriRekap "+
			"left join pegawaiHistoriRekap.pegawai pegawai "+
			"where pegawai.id = :idPegawai "+
			"and pegawaiHistoriRekap.periode = :periode")
	PegawaiHistoriRekap getPegawaiHistoriRekap(@Param("periode")String periode,
			@Param("idPegawai")Integer idPegawai);
}
