features/crud_entites #105

Merged
judaur2005 merged 3 commits from features/crud_entites into develop 2026-02-16 20:55:25 +00:00
8 changed files with 130 additions and 8 deletions
Showing only changes of commit 962af9b48c - Show all commits

View File

@@ -116,10 +116,9 @@ public class PersonneController {
@PostMapping("/recherche")
public ResponseEntity<?> rechercherPersonne(@RequestBody RecherchePersonneResquestBody recherchePersonneResquestBody ) {
try{
personneService.recherchePersonne(recherchePersonneResquestBody);
// personneService.recherchePersonne(recherchePersonneResquestBody);
return new ResponseEntity<>(
new ApiResponse<>(true, null, "Personne retrouvée avec succès."),
new ApiResponse<>(true, personneService.recherchePersonne(recherchePersonneResquestBody), "Personne retrouvée avec succès."),
HttpStatus.OK
);
}catch (Exception e){

View File

@@ -2,5 +2,8 @@ package io.gmss.fiscad.enums;
public enum Origine {
WEB,
MOBILE
MOBILE,
SIGIBE,
RFU_LOGIL,
ANIP
}

View File

@@ -26,6 +26,8 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -194,9 +196,60 @@ public class PersonneServiceImpl implements PersonneService {
}
@Override
public List<Personne> recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody) {
callAPIService.callGetIfuEnLigneToken();
public List<PersonnePayLoadWeb> recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
List<PersonnePayLoadWeb> personnePayLoadWebsRfuLoggil = new ArrayList<>();
personnePayLoadWebsRfuLoggil = recherchePersonneLocal(recherchePersonneResquestBody);
return personnePayLoadWebsRfuLoggil;
}
private List<PersonnePayLoadWeb> recherchePersonneLocal(RecherchePersonneResquestBody recherchePersonneResquestBody) {
List<PersonnePayLoadWeb> personnePayLoadWebs=
personneRepository.findByFilters(
recherchePersonneResquestBody.getIfu()==null?null:recherchePersonneResquestBody.getIfu().trim().toLowerCase(),
recherchePersonneResquestBody.getNpi()==null?null:recherchePersonneResquestBody.getNpi().trim().toLowerCase(),
recherchePersonneResquestBody.getNom()==null?null:recherchePersonneResquestBody.getNom().trim().toLowerCase(),
recherchePersonneResquestBody.getPrenom()==null?null:recherchePersonneResquestBody.getPrenom().trim().toLowerCase(),
recherchePersonneResquestBody.getRaisonSociale()==null?null:recherchePersonneResquestBody.getRaisonSociale().trim().toLowerCase(),
recherchePersonneResquestBody.getNomMere()==null?null:recherchePersonneResquestBody.getNomMere().trim().toLowerCase(),
recherchePersonneResquestBody.getDateNaissance()
);
return personnePayLoadWebs ;
}
private List<PersonnePayLoadWeb> recherchePersonneSigibe(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
return null;
}
private List<PersonnePayLoadWeb> recherchePersonneAnip(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
return null;
}
private String like(String value) {
if (value == null) {
return null;
}
value = value.trim();
if (value.isEmpty()) {
return null;
}
return "%" + value + "%";
}
}

View File

@@ -26,5 +26,5 @@ public interface PersonneService {
Optional<Personne> getPersonneById(Long id);
PersonneCompletDTO getPersonneComplete(Long id);
List<Personne> recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody);
List<PersonnePayLoadWeb> recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody);
}

View File

@@ -2,11 +2,15 @@ package io.gmss.fiscad.paylaods.request;
import lombok.Data;
import java.time.LocalDate;
@Data
public class RecherchePersonneResquestBody {
private String ifu;
private String npi;
private String nom;
private String nomMere;
private String prenom;
private String dateNaissance;
private String raisonSociale;
private LocalDate dateNaissance;
}

View File

@@ -1,6 +1,7 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import io.gmss.fiscad.enums.Categorie;
import io.gmss.fiscad.enums.Origine;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import lombok.Data;
@@ -44,5 +45,22 @@ public class PersonnePayLoadWeb {
private String indicatifTel1;
private String indicatifTel2;
private String sexe;
@Enumerated(EnumType.STRING)
private Origine source;
public PersonnePayLoadWeb(Long id, String ifu, String nom, String prenom, String raisonSociale, String numRavip, String npi, LocalDate dateNaissanceOuConsti, String lieuNaissance, String tel1, String nomJeuneFille, String nomMere,Origine source) {
this.id = id;
this.ifu = ifu;
this.nom = nom;
this.prenom = prenom;
this.raisonSociale = raisonSociale;
this.numRavip = numRavip;
this.npi = npi;
this.dateNaissanceOuConsti = dateNaissanceOuConsti;
this.lieuNaissance = lieuNaissance;
this.tel1 = tel1;
this.nomJeuneFille = nomJeuneFille;
this.nomMere = nomMere;
this.source = source;
}
}

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.persistence.repositories.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
import io.gmss.fiscad.paylaods.response.statistique.StatistiqueTypeNombreResponse;
import io.gmss.fiscad.paylaods.response.restoration.PersonnePayLoad;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
@@ -63,5 +66,41 @@ public interface PersonneRepository extends JpaRepository<Personne, Long> {
List<StatistiqueTypeNombreResponse> getNombrePersonnesResponse();
@Query( """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb(
p.id,
p.ifu,
p.nom,
p.prenom,
p.raisonSociale,
p.numRavip,
p.npi,
p.dateNaissanceOuConsti,
p.lieuNaissance,
p.tel1,
p.nomJeuneFille,
p.nomMere,
io.gmss.fiscad.enums.Origine.RFU_LOGIL
)
FROM Personne p
WHERE (:ifu IS NULL OR LOWER(trim(p.ifu)) LIKE (CONCAT('%', :ifu, '%')))
AND (:npi IS NULL OR LOWER(trim(p.npi)) LIKE (CONCAT('%', :npi, '%')))
AND (:nom IS NULL OR LOWER(trim(p.nom)) LIKE (CONCAT('%', :nom, '%')))
AND (:prenom IS NULL OR LOWER(trim(p.prenom)) LIKE (CONCAT('%', :prenom, '%')))
AND (:raisonSociale IS NULL OR LOWER(trim(p.raisonSociale)) LIKE (CONCAT('%', :raisonSociale, '%')))
AND (:nomMere IS NULL OR LOWER(trim(p.nomMere)) LIKE (CONCAT('%', :nomMere, '%')))
AND (:dateNaissance IS NULL OR p.dateNaissanceOuConsti = :dateNaissance)
"""
)
List<PersonnePayLoadWeb> findByFilters(
@Param("ifu") String ifu,
@Param("npi") String npi,
@Param("nom") String nom,
@Param("prenom") String prenom,
@Param("raisonSociale") String raisonSociale,
@Param("nomMere") String nomMere,
@Param("dateNaissance") LocalDate dateNaissance
);
}

View File

@@ -73,3 +73,9 @@ logging.level.org.apache.catalina.connector.ClientAbortException=ERROR
# Affiche les valeurs des param<61>tres bind<6E>s (Hibernate 5.4+)
#logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
#spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.format_sql=true
##logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.type.descriptor.sql=TRACE
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE