add api instansi and user management
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.iconplus.smartproc.repository;
|
||||
|
||||
import com.iconplus.smartproc.model.entity.Bidang;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface BidangRepository extends JpaRepository<Bidang, LokasiRepository> {
|
||||
|
||||
Optional<Bidang> findByIdAndIsDeleteFalse(Long id);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.iconplus.smartproc.repository;
|
||||
|
||||
import com.iconplus.smartproc.model.entity.Instansi;
|
||||
import com.iconplus.smartproc.model.projection.InstansiView;
|
||||
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 InstansiRepository extends JpaRepository<Instansi, Long> {
|
||||
|
||||
@Query(value = "SELECT i.id as id," +
|
||||
"i.instansi as instansi, " +
|
||||
"i.alamat as alamat, " +
|
||||
"i.keterangan as keterangan, " +
|
||||
"i.isActive as isActive, " +
|
||||
"i.isDelete as isDelete " +
|
||||
"FROM Instansi i " +
|
||||
"WHERE i.isDelete = false " +
|
||||
"AND (:search = '' or UPPER(i.instansi) like :search)")
|
||||
Page<InstansiView> getListInstansi(String search, Pageable pageable);
|
||||
|
||||
Optional<Instansi> findByIdAndIsDeleteFalse(Long id);
|
||||
|
||||
Optional<Instansi> findByInstansiAndIsDeleteFalse(String instansi);
|
||||
}
|
@@ -15,13 +15,21 @@ public interface UsersRepository extends JpaRepository<Users, Long> {
|
||||
|
||||
@Query("SELECT u.id as id, " +
|
||||
"u.nama as nama, " +
|
||||
"u.username as username, " +
|
||||
"u.jabatan as jabatan, " +
|
||||
"u.roleId as roleId, " +
|
||||
"r.role as role, " +
|
||||
"u.bidangId as bidangId, " +
|
||||
"b.bidang as bidang, " +
|
||||
"u.instansiId as instansiId, " +
|
||||
"i.instansi as instansi, " +
|
||||
"u.email as email, " +
|
||||
"u.isActive as isActive, " +
|
||||
"u.isDelete as isDelete " +
|
||||
"FROM Users u " +
|
||||
"JOIN Roles r ON r.id = u.roleId " +
|
||||
"JOIN Bidang b ON b.id = u.bidangId " +
|
||||
"JOIN Instansi i ON i.id = u.instansiId " +
|
||||
"Where u.isDelete = false " +
|
||||
"AND (:search='' " +
|
||||
"or (UPPER(u.nama) like :search " +
|
||||
@@ -33,5 +41,28 @@ public interface UsersRepository extends JpaRepository<Users, Long> {
|
||||
Page<UserRoleView> getAllUsersAndDeletedFase(String search, Pageable pageable);
|
||||
|
||||
Optional<Users> findByEmailAndIsDeleteFalse(String email);
|
||||
|
||||
Optional<Users> findByIdAndIsDeleteFalse(Long id);
|
||||
|
||||
@Query("SELECT u.id as id, " +
|
||||
"u.nama as nama, " +
|
||||
"u.username as username, " +
|
||||
"u.jabatan as jabatan, " +
|
||||
"u.roleId as roleId, " +
|
||||
"r.role as role, " +
|
||||
"u.bidangId as bidangId, " +
|
||||
"b.bidang as bidang, " +
|
||||
"u.instansiId as instansiId, " +
|
||||
"i.instansi as instansi, " +
|
||||
"u.email as email, " +
|
||||
"u.isActive as isActive, " +
|
||||
"u.isDelete as isDelete " +
|
||||
"FROM Users u " +
|
||||
"JOIN Roles r ON r.id = u.roleId " +
|
||||
"JOIN Bidang b ON b.id = u.bidangId " +
|
||||
"JOIN Instansi i ON i.id = u.instansiId " +
|
||||
"Where u.isDelete = false " +
|
||||
"AND u.id = :id")
|
||||
Optional<UserRoleView> getUserByIdAndDeletedFase(Long id);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user