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

import com.jasamedika.medifirst2000.entities.MapPaketToProduk;

@Repository("MapPaketToProdukDao")
public interface MapPaketToProdukDao extends PagingAndSortingRepository<MapPaketToProduk, Integer> {

	@Query("select new Map(mpp.id as idMapping,"
			+ "(case when mpp.statusEnabled = true then 'Aktif' else 'Nonaktif' end) as statusAktif,"
			+ "pk.id as idPaket,pk.namaPaket as namaPaket," + "pd.id as idProduk,pd.namaProduk as namaProduk) "
			+ "from MapPaketToProduk mpp " + "left join mpp.paket pk with pk.statusEnabled is true "
			+ "left join mpp.produk pd with pd.statusEnabled is true " + "order by mpp.id desc")
	public List<Map<String, Object>> getAllData();

}
