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

@Repository("indikatorKinerjaDetailDao")
public interface IndikatorKinerjaDetailDao extends PagingAndSortingRepository<IndikatorKinerjaDetail, Integer> {

	@Query("select new Map(ikd.id as id,ikd.detailIndikator as detailIndikator) " + "from IndikatorKinerjaDetail ikd "
			+ "where ikd.statusEnabled is true and ikd.id in (:listDetailId) " + "order by ikd.detailIndikator")
	public List<Map<String, Object>> findByListId(@Param("listDetailId") List<Integer> listIdDetail);

	@Query("select ikd " + "from IndikatorKinerjaDetail ikd " + "where ikd.statusEnabled is true "
			+ "and ikd.indikatorKinerjaId = :indikatorId")
	public List<IndikatorKinerjaDetail> findByIndikator(@Param("indikatorId") Integer idIndikator);

	@Query("select ikd.detailIndikator from IndikatorKinerjaDetail ikd where ikd.id = :indikatorId")
	public String findNamaIndikator(@Param("indikatorId") Integer idIndikator);

}
