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

@Repository("KelasDao")
public interface KelasDao extends PagingAndSortingRepository<Kelas, Integer> {
	// custom query
	@Query("select r from Kelas r where r.id in (Select cast(s.nilaiField as int) from  SettingDataFixed s where s.namaField='KdKelasIII') ")
	public Kelas findKelas3();
	
	@Query("select r from Kelas r where r.id = :kelasId")
	public Kelas findKelasById(@Param("kelasId") Integer kelasId);
	
	@Query("select r from Kelas r where r.id in (Select cast(s.nilaiField as int) from  SettingDataFixed s where s.namaField='KdKelasTidakAdaKelas') ")
	public Kelas findNonKelas();
	
	@Query("select new Map(model.kelas.id as id,model.kelas.namaKelas as namaKelas) from MapRuanganToKelas model where model.ruangan.id=:ruanganId")
	public List<Map<String, Object>> findKelasByRuangan(@Param("ruanganId") Integer ruanganId);
}
