Add ProfesiService
Pembuatan service daftar profesi berdasarkan id pegawai login dan jenis profesi
This commit is contained in:
parent
efbc22d1f7
commit
2a55a324a1
@ -1,9 +1,11 @@
|
||||
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.Profesi;
|
||||
@ -14,8 +16,33 @@ import com.jasamedika.medifirst2000.entities.Profesi;
|
||||
*/
|
||||
@Repository("profesiDao")
|
||||
public interface ProfesiDao extends PagingAndSortingRepository<Profesi, Integer> {
|
||||
|
||||
|
||||
@Query("select prf from Profesi prf where prf.statusEnabled is true")
|
||||
public 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)
|
||||
public List<Map<String, Object>> findByStatus();
|
||||
|
||||
@Query(strAllActive + whrJenis + srtNama)
|
||||
public 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)
|
||||
public List<Map<String, Object>> findByStatus(@Param("pegawaiId") Integer idPegawai);
|
||||
|
||||
@Query(strAllJabatanActive + whrPegawai + whrJenis + srtNama)
|
||||
public List<Map<String, Object>> findByStatus(@Param("pegawaiId") Integer idPegawai,
|
||||
@Param("jenisId") Short idJenis);
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.jasamedika.medifirst2000.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
|
||||
@ -12,7 +13,9 @@ import com.jasamedika.medifirst2000.vo.ProfesiVO;
|
||||
* @since Oct 8, 2021
|
||||
*/
|
||||
public interface ProfesiService extends BaseVoService<Profesi, ProfesiVO, Integer> {
|
||||
|
||||
|
||||
public List<ProfesiVO> findAllActive() throws JpaSystemException;
|
||||
|
||||
public List<Map<String, Object>> findByStatus(Integer idPegawai, Short idJenis) throws JpaSystemException;
|
||||
|
||||
}
|
||||
|
||||
@ -113,4 +113,23 @@ public class ProfesiServiceImpl extends BaseVoServiceImpl implements ProfesiServ
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> findByStatus(Integer idPegawai, Short idJenis) throws JpaSystemException {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
|
||||
if (CommonUtil.isNotNullOrEmpty(idJenis)) {
|
||||
result = profesiDao.findByStatus(idPegawai, idJenis);
|
||||
if (CommonUtil.isNullOrEmpty(result)) {
|
||||
result = profesiDao.findByStatus(idJenis);
|
||||
}
|
||||
} else {
|
||||
result = profesiDao.findByStatus(idPegawai);
|
||||
if (CommonUtil.isNullOrEmpty(result)) {
|
||||
result = profesiDao.findByStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user