gestion revu de code en utilisant uniquement les DTO #125
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,4 +86,9 @@ public class UniteLogementServiceImpl implements UniteLogementService {
|
||||
public List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId) {
|
||||
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDto(batimentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UniteLogementPaylaodWeb> getUniteLogementListByParcelle(Long parcelleId) {
|
||||
return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantByParcelleToDto(parcelleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,6 @@ public interface UniteLogementService {
|
||||
Page<UniteLogementPaylaodWeb> getUniteLogementListByBatimentPageable(Long batimentId, Pageable pageable);
|
||||
|
||||
List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId);
|
||||
|
||||
List<UniteLogementPaylaodWeb> getUniteLogementListByParcelle(Long parcelleId);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class EnqueteBatimentPayloadWeb {
|
||||
private String enqueteurNom;
|
||||
private String enqueteurPrenom;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@JsonIgnore
|
||||
// @JsonIgnore
|
||||
private StatutEnquete statutEnquete;
|
||||
private Long exerciceId;
|
||||
private Integer exerciceAnnee;
|
||||
|
||||
@@ -224,5 +224,38 @@ public interface UniteLogementRepository extends JpaRepository<UniteLogement, Lo
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user