45 lines
1.7 KiB
Java
45 lines
1.7 KiB
Java
package com.jasamedika.medifirst2000.dao;
|
|
|
|
import com.jasamedika.medifirst2000.entities.Profesi;
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
import org.springframework.data.jpa.repository.Query;
|
|
import org.springframework.data.repository.query.Param;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @author salmanoe
|
|
* @since Oct 8, 2021
|
|
*/
|
|
public interface ProfesiDao extends JpaRepository<Profesi, Integer> {
|
|
|
|
@Query("select prf from Profesi prf where prf.statusEnabled is true order by prf.namaProfesi asc")
|
|
List<Profesi> findAllActive();
|
|
|
|
String strAllActive = "select new Map(prf.id as id,prf.namaProfesi as namaProfesi) from Profesi prf where prf.statusEnabled is true";
|
|
|
|
String whrJenis = " and prf.jenisProfesi = :jenisId";
|
|
|
|
String srtNama = " order by prf.namaProfesi";
|
|
|
|
@Query(strAllActive + srtNama)
|
|
List<Map<String, Object>> findByStatus();
|
|
|
|
@Query(strAllActive + whrJenis + srtNama)
|
|
List<Map<String, Object>> findByStatus(@Param("jenisId") Short idJenis);
|
|
|
|
String strAllJabatanActive = "select new Map(prf.id as id,prf.namaProfesi as namaProfesi) "
|
|
+ "from MapPegawaiJabatanToUnitKerja mj, MapJabatanProfesi mjp " + "inner join mjp.profesi prf "
|
|
+ "where mj.jabatanId = mjp.jabatanId " + "and mj.statusEnabled is true " + "and prf.statusEnabled is true";
|
|
|
|
String whrPegawai = " and mj.pegawaiId = :pegawaiId";
|
|
|
|
@Query(strAllJabatanActive + whrPegawai + srtNama)
|
|
List<Map<String, Object>> findByStatus(@Param("pegawaiId") Integer idPegawai);
|
|
|
|
@Query(strAllJabatanActive + whrPegawai + whrJenis + srtNama)
|
|
List<Map<String, Object>> findByStatus(@Param("pegawaiId") Integer idPegawai,
|
|
@Param("jenisId") Short idJenis);
|
|
}
|