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

@Repository("ipsrsSertifikatKalibrasiDao")
public interface IpsrsSertifikatKalibrasiDao extends PagingAndSortingRepository<IpsrsSertifikatKalibrasi, Integer>{

	@Query("select NEW Map ("
			+ "a.id as id, "
			+ "a.tglKalibrasi as tglKalibrasi, "
			+ "a.noSertifikat as noSertifikat, "
			+ "a.fileName as fileName) "
			+ "from IpsrsSertifikatKalibrasi a "
			+ "where noRecKalibrasi=:noRecKalibrasi")
	List<Map<String, Object>> getSertifikatKalibrasi(
			@Param("noRecKalibrasi") String noRecKalibrasi);
	
	@Query("select NEW Map ("
			+ "a.file as file) "
			+ "from IpsrsSertifikatKalibrasi a "
			+ "where a.id=:id")
	Map<String, Object> downloadSertifikatKalibrasi(
			@Param("id") Integer id);
}
