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 org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.MapJenisDietToProduk;

@Repository("MapJenisDietToProdukDao")
public interface MapJenisDietToProdukDao extends CrudRepository<MapJenisDietToProduk, Integer>{
	@Query("select new map(a.id as idProduk, a.reportDisplay as namaProduk) " +
			" from Produk a left join a.departemen b where b.id in('6')")
	List<Map<String, Object>> getProdukGizi();
	
	@Query("select new map(a.id as id, a.jenisDiet as jenisDiet) "+
			" from JenisDiet a where a.statusEnabled in('true')" )
	List<Map<String, Object>> getMapJenisDietToProduk();
	
	@Query("select new map(a.id as idMapJenisDietToProduk, " +
			" b.id as id, b.jenisDiet as jenisDiet, " +
			" a.berat as berat, c.id as idProduk, " +
			" c.reportDisplay as namaProduk, " +
			" d.id as jenisWaktu, d.jenisWaktu as jenisWaktu, " +
			" e.id as idSatuanStandar, e.satuanStandar as satuanStandar) " +
			" from MapJenisDietToProduk a " +
			" left join a.JenisDiet b " +
			" left join a.produk c " +
			" left join a.jenisWaktu d " +
			" left join c.satuanStandar e" +
			" where b.id=:id and b.statusEnabled in('true')")
	List<Map<String, Object>> getProdukToJenisDiet(@Param("id")Integer id);

}
