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.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.jasamedika.medifirst2000.entities.MapKebutuhanSaranaToKamar;

public interface MapKebutuhanSaranaToKamarDao extends CrudRepository<MapKebutuhanSaranaToKamar, Integer>{
	
	@Query("select new map(a.id as id, a.namaExternal as namaKebutuhan, " +
			" a.jumlah as jumlah, a.harga as harga, a.satuan as satuan, r.id as idKamar, " +
			" r.namaKamar as namaKamar) from MapKebutuhanSaranaToKamar a " +
			" left join a.kamar r where r.id=:idKamar and a.statusEnabled in('true')")
	List<Map<String, Object>> getAll(@Param("idKamar")Integer idKamar);
	
	@Query("select new map(a.id as id, a.namaExternal as namaExternal, " +
			" a.jumlah as jumlah, a.harga as harga, a.satuan as satuan, r.id as idKamar, " +
			" r.namaKamar as namaKamar, a.statusEnabled as statusEnabled) " +
			" from MapKebutuhanSaranaToKamar a left join a.kamar r where a.id=:id")
	List<Map<String, Object>> getDataById(@Param("id")Integer id);
	

}
