Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#125) from features/crud_entites into develop

Reviewed-on: #125
This commit was merged in pull request #125.
This commit is contained in:
2026-02-20 19:33:57 +00:00
5 changed files with 64 additions and 1 deletions

View File

@@ -224,4 +224,27 @@ public class UniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/by-parcelle-id/{id}")
public ResponseEntity<?> getUniteLogementByParcelleId(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByParcelle(id), "Unite de de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
} }

View File

@@ -86,4 +86,9 @@ public class UniteLogementServiceImpl implements UniteLogementService {
public List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId) { public List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId) {
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDto(batimentId); return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDto(batimentId);
} }
@Override
public List<UniteLogementPaylaodWeb> getUniteLogementListByParcelle(Long parcelleId) {
return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantByParcelleToDto(parcelleId);
}
} }

View File

@@ -28,4 +28,6 @@ public interface UniteLogementService {
Page<UniteLogementPaylaodWeb> getUniteLogementListByBatimentPageable(Long batimentId, Pageable pageable); Page<UniteLogementPaylaodWeb> getUniteLogementListByBatimentPageable(Long batimentId, Pageable pageable);
List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId); List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId);
List<UniteLogementPaylaodWeb> getUniteLogementListByParcelle(Long parcelleId);
} }

View File

@@ -52,7 +52,7 @@ public class EnqueteBatimentPayloadWeb {
private String enqueteurNom; private String enqueteurNom;
private String enqueteurPrenom; private String enqueteurPrenom;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@JsonIgnore // @JsonIgnore
private StatutEnquete statutEnquete; private StatutEnquete statutEnquete;
private Long exerciceId; private Long exerciceId;
private Integer exerciceAnnee; private Integer exerciceAnnee;

View File

@@ -224,5 +224,38 @@ public interface UniteLogementRepository extends JpaRepository<UniteLogement, Lo
Pageable pageable Pageable pageable
); );
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb(
ul.id,
ul.nul,
ul.numeroEtage,
ul.code,
b.id,
eul.superficieAuSol,
eul.superficieLouee,
b.nub,
eul.observation,
ul.dateConstruction,
per.id,
per.nom,
per.prenom,
per.raisonSociale,
eul.id
)
FROM UniteLogement ul
JOIN ul.batiment b
LEFT JOIN EnqueteUniteLogement eul
ON eul.uniteLogement = ul
AND eul.dateEnquete = (
SELECT MAX(eul2.dateEnquete)
FROM EnqueteUniteLogement eul2
WHERE eul2.uniteLogement = ul
)
LEFT JOIN eul.personne per
where b.parcelle.id = :parcelleId
""")
List<UniteLogementPaylaodWeb> findAllUnitesLogementAvecOccupantCourantByParcelleToDto(@Param("parcelleId") Long parcelleId);
} }