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.KelompokJabatan;

@Repository
public interface KelompokJabatanDao extends PagingAndSortingRepository<KelompokJabatan, Integer> {

	@Query("select new map (model.id as id, model.namaKelompokJabatan as namaKelompokJabatan) from KelompokJabatan model where model.statusEnabled is true")
	public List<Map<String, Object>> getAllByStatusEnabled();

	@Query("select new Map(jb.kelompokJabatanId as kelompokJabatanId,mj.subUnitKerjaPegawaiId as subunitKerjaId) "
			+ "from MapPegawaiJabatanToUnitKerja mj " + "inner join mj.jabatan jb " + "where mj.statusEnabled is true "
			+ "and mj.pegawaiId = :pegawaiId " + "and jb.kelompokJabatanId in (3,4,5,6) "
			+ "order by jb.kelompokJabatanId")
	public List<Map<String, Object>> findIdByLoginLogbookSkor(@Param("pegawaiId") Integer idPegawai);

}
