package com.jasamedika.medifirst2000.dao;

import java.util.List;
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.HistoryDataPegawai;

@Repository("HistoryDataPegawaiDao")
public interface HistoryDataPegawaiDao extends PagingAndSortingRepository<HistoryDataPegawai, String> {

	@Query("select new map (model.tanggal as tanggal, model.id as id, model.perubahan as perubahan, "
			+ "pegawai.id as iPegawai, pegawai.namaLengkap as pegawai, "
			+ "petugas.id as idPetugas, petugas.namaLengkap as petugas) " + "from HistoryDataPegawai model "
			+ "join model.pegawai pegawai "
			+ "join model.petugas petugas where model.pegawaiId = :pegawaiId and petugas.id not in (:listPetugasId) order by model.tanggal desc")
	public List<Map<String, Object>> getHistoryDataPegawaiByIdPegawai(@Param("pegawaiId") Integer pegawaiId, @Param("listPetugasId") List<Integer> listPetugasId);

	@Query("select model from HistoryDataPegawai model  where model.noRec = :id ")
	public HistoryDataPegawai getHistoryDataPegawaiById(@Param("id") String id);

}
