package com.jasamedika.medifirst2000.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.ModulAplikasi;
import com.jasamedika.medifirst2000.entities.ObjekModulAplikasi;

@Repository("ModulAplikasiDao")
public interface ModulAplikasiDao extends JpaRepository<ModulAplikasi,Integer> {

	ModulAplikasi findById(@Param("id") Integer id);
	
	@Query("select m from ModulAplikasi m where m.kdModulAplikasiHead is null AND m.id <> 0 and m.statusEnabled=true order by m.noUrut asc")
	List<ModulAplikasi> findAllSubSytemOrderByModulNoUrutAsc();
	
	@Query("select m from ModulAplikasi m where m.kdModulAplikasiHead = :kdModulAplikasi and m.statusEnabled=true order by m.noUrut asc")
	List<ModulAplikasi> findAllSubModulOrderByModulNoUrutAsc(@Param("kdModulAplikasi") Integer kdModulAplikasi);

	@Query("Select m.objekModulAplikasi from ModulAplikasi m where m.id = :id and m.statusEnabled=true")
	List<ObjekModulAplikasi> findObjekModulAplikasiById(@Param("id") Integer id);
}
