inisialisasi
This commit is contained in:
23
src/main/java/org/sadigit/repository/AppUserRepository.java
Normal file
23
src/main/java/org/sadigit/repository/AppUserRepository.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.sadigit.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.sadigit.entity.AppUser;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class AppUserRepository implements PanacheRepositoryBase<AppUser, Long> {
|
||||
public AppUser findByUsername(String username) {
|
||||
return find("username", username).count() > 0 ? find("username", username).firstResult() : null;
|
||||
}
|
||||
|
||||
public AppUser findByUsernameAndPassword(String username, String password) {
|
||||
return find("username = ?1 and password = ?2", username, password).firstResult();
|
||||
}
|
||||
|
||||
public List<AppUser> findByUnitIdAndPositionId(Long unitId, Long positionId) {
|
||||
return find("unitId = ?1 and positionId = ?2 and isActive='1'", unitId, positionId).list();
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package org.sadigit.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.sadigit.entity.Issuetype;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class IssueTypeRepository implements PanacheRepositoryBase<Issuetype, Long> {
|
||||
public List<Issuetype> findIssueTypeKeluhan() {
|
||||
return find("projectId = ?1", 2).list();
|
||||
}
|
||||
|
||||
public List<Issuetype> findIssueTypeActiveKeluhan() {
|
||||
return find("projectId = ?1 AND isActive = ?2", 2, "1").list();
|
||||
}
|
||||
}
|
27
src/main/java/org/sadigit/repository/KeluhanRepository.java
Normal file
27
src/main/java/org/sadigit/repository/KeluhanRepository.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.sadigit.repository;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import org.sadigit.entity.Keluhan;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@ApplicationScoped
|
||||
public class KeluhanRepository implements PanacheRepositoryBase<Keluhan, Long> {
|
||||
public List<Keluhan> findKeluhanByUnitId(Long unitId, String startDate, String endDate) {
|
||||
|
||||
Date start = Date.valueOf(startDate);
|
||||
Date end = Date.valueOf(endDate);
|
||||
|
||||
log.info("start: {}", start);
|
||||
|
||||
return find("unit = ?1 and date(createdDate) >= ?2 and date(createdDate)<= ?3", unitId, start, end)
|
||||
.list();
|
||||
}
|
||||
}
|
27
src/main/java/org/sadigit/repository/UnitRepository.java
Normal file
27
src/main/java/org/sadigit/repository/UnitRepository.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.sadigit.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.query.Query;
|
||||
import org.sadigit.model.dto.UnitDto;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
||||
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@ApplicationScoped
|
||||
public class UnitRepository implements PanacheRepositoryBase<UnitDto, Long> {
|
||||
@Inject
|
||||
Session session;
|
||||
|
||||
public List<UnitDto> findByUnitTypeId(Long unitTypeId) {
|
||||
Query<UnitDto> query = session.createQuery(
|
||||
"SELECT (SELECT B.unitName FROM Unit B WHERE B.unitId = A.unitParent) AS unitJaringan, A.unitName, A.unitId, A.unitTypeId, A.unitParent "
|
||||
+ "FROM Unit A WHERE unitTypeId = ?1",
|
||||
UnitDto.class);
|
||||
query.setParameter(1, unitTypeId);
|
||||
return query.list();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user