add crud jabatan
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package com.iconplus.smartproc.repository;
|
||||
|
||||
import com.iconplus.smartproc.model.entity.Jabatan;
|
||||
import com.iconplus.smartproc.model.projection.JabatanView;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface JabatanRepository extends JpaRepository<Jabatan, Long> {
|
||||
|
||||
Optional<Jabatan> findByIdAndIsDeleteFalse(Long id);
|
||||
|
||||
Optional<Jabatan> findByJabatanAndIsDeleteFalse(String jabatan);
|
||||
|
||||
@Query(value = "SELECT j.id as id, " +
|
||||
"j.jabatan as jabatan, " +
|
||||
"j.instansiId as instansiId, " +
|
||||
"j.keterangan as keterangan, " +
|
||||
"i.instansi as instansi, " +
|
||||
"j.bidangId as bidangId, " +
|
||||
"b.bidang as bidang, " +
|
||||
"j.isActive as isActive, " +
|
||||
"j.isDelete as isDelete " +
|
||||
"FROM Jabatan j " +
|
||||
"JOIN Bidang b ON b.id = j.bidangId " +
|
||||
"JOIN Instansi i ON i.id = j.instansiId " +
|
||||
"WHERE j.isDelete = false " +
|
||||
"AND j.id = :jabatanId")
|
||||
Optional<JabatanView> getJabatanDetails(Long jabatanId);
|
||||
|
||||
@Query(value = "SELECT j.id as id, " +
|
||||
"j.jabatan as jabatan, " +
|
||||
"j.keterangan as keterangan, " +
|
||||
"j.instansiId as instansiId, " +
|
||||
"i.instansi as instansi, " +
|
||||
"j.bidangId as bidangId, " +
|
||||
"b.bidang as bidang, " +
|
||||
"j.isActive as isActive, " +
|
||||
"j.isDelete as isDelete " +
|
||||
"FROM Jabatan j " +
|
||||
"JOIN Bidang b ON b.id = j.bidangId " +
|
||||
"JOIN Instansi i ON i.id = j.instansiId " +
|
||||
"WHERE j.isDelete = false " +
|
||||
"AND (:search = '' or UPPER(j.jabatan) like :search) " +
|
||||
"ORDER BY j.id")
|
||||
Page<JabatanView> getListJabatan(String search, Pageable pageable);
|
||||
}
|
Reference in New Issue
Block a user