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

@Repository("MapLoginUserToRuanganDao")
public interface MapLoginUserToRuanganDao extends PagingAndSortingRepository<MapLoginUserToRuangan, Integer> {

	@Query("select NEW map (c.id as ruanganId, c.namaRuangan as namaRuangan) "
			+ "from MapLoginUserToRuangan a left join a.loginUser b left join a.ruangan c "
			+ "where b.id=:userLogin")
	List<Map<String, Object>> findCurrentRoomByUserLogin(@Param("userLogin") Integer userLogin);
	
//	List<MapObjekModulToKelompokUser> findByKelompokUser(@Param("kelompokUser")  Integer kelompokUser);
	
	/// Alter Syamsu
	@Query("select NEW map (c.id as ruanganId, c.namaRuangan as namaRuangan) from MapLoginUserToRuangan "
			+ "a left join a.loginUser b left join a.ruangan c where b.id=:userLogin"
			+ " and c.modulAplikasiId = :modulAplikasiId")
	List<Map<String, Object>> findCurrentRoomByUserLoginAndModulAplikasi(@Param("userLogin") Integer userLogin, 
			@Param("modulAplikasiId") Integer modulAplikasiId);
	
}
