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

@Repository("RekananSkKontrakDao")
public interface RekananSkKontrakDao extends PagingAndSortingRepository<RekananSkKontrak, String> {

	@Query("select new Map( rekanan.namaRekanan as namaRekanan,model.noSk as noSk,model.namaKontrak as namaKontrak) from RekananSkKontrak model left join model.rekanan rekanan where model.noRec=:noRec ")
	Map<String,Object> findRekananSkKonrak(@Param("noRec") String noRec);

	@Query("select new Map( model.noRec as noRec,rekanan.namaRekanan as namaRekanan,model.noSk as noSk,model.namaKontrak as namaKontrak) from RekananSkKontrak model left join model.rekanan rekanan ")
	List<Map<String,Object>> findKontrak();

	@Query("select new map(produk.namaProduk as namaProduk,p.noRec as noRec) from RekananSkKontrakDetail p left join p.produk produk left join p.rekananSkKontrak rks where rks.noRec=:noRec")
	List<Map<String,Object>> findKontrakDetail(@Param("noRec") String noRec);
}
	
	
