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

@Repository("MappingAlatToBundleDao")
public interface MappingAlatToBundleDao extends PagingAndSortingRepository<MappingAlatToBundle, Integer> {
	@Query("select new map(a.id as id, a.namaAlat as namaAlat, " +
			" b.id as idSatuan, b.satuanStandar as satuanStandar) " +
			" from Alat a left join a.satuanStandar b where a.statusEnabled in('true')")
	List<Map<String, Object>> getAlatAll();
	
	@Query("select new map(alat.id as idalat, alat.namaAlat as namaAlat, " +
			" satuanStandar.id as idSatuan, " +
			" satuanStandar.satuanStandar as satuanStandar, " +
			" mappingAlatToBundle.jumlah as jumlah, " +
			" mappingAlatToBundle.id as id) " +
			" from MappingAlatToBundle mappingAlatToBundle "+
			" left join mappingAlatToBundle.alat alat " +
			" left join mappingAlatToBundle.bundleSetAlat bundleSetAlat "+
			" left join alat.satuanStandar satuanStandar " +
			" where bundleSetAlat.id=:idBundle and mappingAlatToBundle.statusEnabled in('true')")
	List<Map<String, Object>> getAlatByBundle(@Param("idBundle")Integer idBundle);
	
	
}
