From 429c66b59a5a9b2a43663dd0153dd22c9efba4d9 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Thu, 5 Sep 2024 14:38:34 +0200 Subject: [PATCH] [PPANTT-106] feat: updated Stazioni with new filter in stazioni repository --- .../repository/StazioniRepository.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/gov/pagopa/apiconfig/starter/repository/StazioniRepository.java b/src/main/java/it/gov/pagopa/apiconfig/starter/repository/StazioniRepository.java index a292cca..76a60f5 100644 --- a/src/main/java/it/gov/pagopa/apiconfig/starter/repository/StazioniRepository.java +++ b/src/main/java/it/gov/pagopa/apiconfig/starter/repository/StazioniRepository.java @@ -26,21 +26,37 @@ public interface StazioniRepository extends JpaRepository, JpaSp "select distinct s from Stazioni s, PaStazionePa r where (:fkIntermediario is null or" + " s.fkIntermediarioPa = :fkIntermediario) and (r.fkPa = :fkPa and r.fkStazione = s)" + " and (:idStazione is null or upper(s.idStazione) like concat('%'," - + " upper(:idStazione), '%')) ") + + " upper(:idStazione), '%')) " + + " AND (cast(cast(:createDateBefore as text) as timestamp) IS NULL OR s.dataCreazione < cast(cast(:createDateBefore as text) as timestamp)) " + + " AND (cast(cast(:createDateAfter as text) as timestamp) IS NULL OR s.dataCreazione > cast(cast(:createDateAfter as text) as timestamp)) " + + " AND ((:connectionType IS NULL OR :connectionType = 'NONE') " + + " OR (:connectionType = 'SYNC' AND servizio LIKE '%gpd%')" + + " OR (:connectionType = 'ASYNC' AND (servizio IS NULL or servizio NOT LIKE '%gpd%')))") Page findAllByFilters( @Param("fkIntermediario") Long fkIntermediario, @Param("fkPa") Long fkPa, @Param("idStazione") String idStazione, + @Param("createDateBefore") OffsetDateTime createDateBefore, + @Param("createDateAfter") OffsetDateTime createDateAfter, + @Param("connectionType") String connectionType, Pageable pageable); @Query( value = "select distinct s from Stazioni s where (:fkIntermediario is null or s.fkIntermediarioPa" + " = :fkIntermediario) and (:idStazione is null or upper(s.idStazione) like" - + " concat('%', upper(:idStazione), '%')) ") + + " concat('%', upper(:idStazione), '%')) " + + " AND (cast(cast(:createDateBefore as text) as timestamp) IS NULL OR s.dataCreazione < cast(cast(:createDateBefore as text) as timestamp)) " + + " AND (cast(cast(:createDateAfter as text) as timestamp) IS NULL OR s.dataCreazione > cast(cast(:createDateAfter as text) as timestamp)) " + + " AND ((:connectionType IS NULL OR :connectionType = 'NONE') " + + " OR (:connectionType = 'SYNC' AND servizio LIKE '%gpd%')" + + " OR (:connectionType = 'ASYNC' AND (servizio IS NULL or servizio NOT LIKE '%gpd%')))") Page findAllByFilters( @Param("fkIntermediario") Long fkIntermediario, @Param("idStazione") String idStazione, + @Param("createDateBefore") OffsetDateTime createDateBefore, + @Param("createDateAfter") OffsetDateTime createDateAfter, + @Param("connectionType") String connectionType, Pageable pageable); @Query(