Merge pull request 'develop' (#90) from develop into main
All checks were successful
CD - Deploy on main / deploy (push) Successful in 46s
All checks were successful
CD - Deploy on main / deploy (push) Successful in 46s
Reviewed-on: #90
This commit was merged in pull request #90.
This commit is contained in:
@@ -153,6 +153,54 @@ public class UniteLogementController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all/by-batiment-id/{batimentId}")
|
||||
public ResponseEntity<?> getAllUniteLogementListByBatiment(@PathVariable Long batimentId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByBatiment(batimentId), "Liste des Enquetes des unites Logements chargé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);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged/by-batiment-id/{batimentId}")
|
||||
public ResponseEntity<?> getAllUniteLogementByBatimentPaged(@PathVariable Long batimentId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByBatimentPageable(batimentId,pageable), "Liste des enquetes des unites de logements chargé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);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
|
||||
try {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private float surfaceAuSol;
|
||||
private Float surfaceAuSol;
|
||||
private String autreMenuisierie;
|
||||
private String autreMur;
|
||||
private boolean sbee;
|
||||
|
||||
@@ -63,6 +63,11 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
private LocalDate dateFinExcemption;
|
||||
|
||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
private LocalDate dateEnquete;
|
||||
private String observation;
|
||||
|
||||
// @JsonIgnore
|
||||
// @ManyToOne(fetch = FetchType.LAZY)
|
||||
// @JsonBackReference
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -51,23 +52,33 @@ public class UniteLogementServiceImpl implements UniteLogementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UniteLogement> getUniteLogementList(Pageable pageable) {
|
||||
return uniteLogementRepository.findAll(pageable);
|
||||
public Page<UniteLogementPaylaodWeb> getUniteLogementList(Pageable pageable) {
|
||||
return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantToDtoPageable(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UniteLogement> getUniteLogementList() {
|
||||
return uniteLogementRepository.findAll();
|
||||
public List<UniteLogementPaylaodWeb> getUniteLogementList() {
|
||||
return uniteLogementRepository.findAllUnitesLogementAvecOccupantCourantToDto();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<UniteLogement> getUniteLogementById(Long id) {
|
||||
public Optional<UniteLogementPaylaodWeb> getUniteLogementById(Long id) {
|
||||
if (uniteLogementRepository.existsById(id)) {
|
||||
return uniteLogementRepository.findById(id);
|
||||
return uniteLogementRepository.findUniteLogementAvecOccupantCourantToDto(id);
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la nouvelle unité de logement spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UniteLogementPaylaodWeb> getUniteLogementListByBatimentPageable(Long batimentId, Pageable pageable) {
|
||||
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDtoPageable(batimentId,pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId) {
|
||||
return uniteLogementRepository.findUnitesLogementAvecOccupantCourantByBatimentToDto(batimentId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package io.gmss.fiscad.interfaces.rfu.metier;
|
||||
import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -17,9 +19,13 @@ public interface UniteLogementService {
|
||||
|
||||
void deleteUniteLogement(Long id) throws NotFoundException;
|
||||
|
||||
Page<UniteLogement> getUniteLogementList(Pageable pageable);
|
||||
Page<UniteLogementPaylaodWeb> getUniteLogementList(Pageable pageable);
|
||||
|
||||
List<UniteLogement> getUniteLogementList();
|
||||
List<UniteLogementPaylaodWeb> getUniteLogementList();
|
||||
|
||||
Optional<UniteLogement> getUniteLogementById(Long id);
|
||||
Optional<UniteLogementPaylaodWeb> getUniteLogementById(Long id);
|
||||
|
||||
Page<UniteLogementPaylaodWeb> getUniteLogementListByBatimentPageable(Long batimentId, Pageable pageable);
|
||||
|
||||
List<UniteLogementPaylaodWeb> getUniteLogementListByBatiment(Long batimentId);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@ public class BatimentPaylaodWeb {
|
||||
private String personneNom;
|
||||
private String personnePrenom;
|
||||
private String personneRaisonSociale;
|
||||
private Float superficieSol;
|
||||
|
||||
public BatimentPaylaodWeb(Long id, String nub, String code, LocalDate dateConstruction, Long parcelleId, String parcelleNup, String parcelleQ, String parcelleI, String parcelleP, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale) {
|
||||
public BatimentPaylaodWeb(Long id, String nub, String code, LocalDate dateConstruction, Long parcelleId, String parcelleNup, String parcelleQ, String parcelleI, String parcelleP, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Float superficieSol) {
|
||||
this.id = id;
|
||||
this.nub = nub;
|
||||
this.code = code;
|
||||
@@ -34,5 +35,7 @@ public class BatimentPaylaodWeb {
|
||||
this.personneNom = personneNom;
|
||||
this.personnePrenom = personnePrenom;
|
||||
this.personneRaisonSociale = personneRaisonSociale;
|
||||
this.superficieSol = superficieSol ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,28 @@ public class UniteLogementPaylaodWeb {
|
||||
private String numeroEtage;
|
||||
private String code;
|
||||
private Long batimentId;
|
||||
private Float superficieSol;
|
||||
private String batimentNub;
|
||||
private String observation;
|
||||
private LocalDate dateConstruction;
|
||||
private Long personneId;
|
||||
private String personneNom;
|
||||
private String personnePrenom;
|
||||
private String personneRaisonSociale;
|
||||
|
||||
public UniteLogementPaylaodWeb(Long id, String nul, String numeroEtage, String code, Long batimentId, Float superficieSol, String batimentNub, String observation, LocalDate dateConstruction, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale) {
|
||||
this.id = id;
|
||||
this.nul = nul;
|
||||
this.numeroEtage = numeroEtage;
|
||||
this.code = code;
|
||||
this.batimentId = batimentId;
|
||||
this.superficieSol = superficieSol;
|
||||
this.batimentNub = batimentNub;
|
||||
this.observation = observation;
|
||||
this.dateConstruction = dateConstruction;
|
||||
this.personneId = personneId;
|
||||
this.personneNom = personneNom;
|
||||
this.personnePrenom = personnePrenom;
|
||||
this.personneRaisonSociale = personneRaisonSociale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public interface BatimentRepository extends JpaRepository<Batiment, Long> {
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
per.raisonSociale,
|
||||
eb.surfaceAuSol
|
||||
)
|
||||
FROM Batiment b
|
||||
JOIN b.parcelle p
|
||||
@@ -77,7 +78,8 @@ public interface BatimentRepository extends JpaRepository<Batiment, Long> {
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
per.raisonSociale,
|
||||
eb.surfaceAuSol
|
||||
)
|
||||
FROM Batiment b
|
||||
JOIN b.parcelle p
|
||||
@@ -108,7 +110,8 @@ public interface BatimentRepository extends JpaRepository<Batiment, Long> {
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
per.raisonSociale,
|
||||
eb.surfaceAuSol
|
||||
)
|
||||
FROM Batiment b
|
||||
JOIN b.parcelle p
|
||||
@@ -144,7 +147,8 @@ public interface BatimentRepository extends JpaRepository<Batiment, Long> {
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
per.raisonSociale,
|
||||
eb.surfaceAuSol
|
||||
)
|
||||
FROM Batiment b
|
||||
JOIN b.parcelle p
|
||||
@@ -166,38 +170,39 @@ public interface BatimentRepository extends JpaRepository<Batiment, Long> {
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb(
|
||||
b.id,
|
||||
b.nub,
|
||||
b.code,
|
||||
b.dateConstruction,
|
||||
p.id,
|
||||
p.nup,
|
||||
p.q,
|
||||
p.i,
|
||||
p.p,
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
)
|
||||
FROM Batiment b
|
||||
JOIN b.parcelle p
|
||||
LEFT JOIN EnqueteBatiment eb
|
||||
ON eb.batiment = b
|
||||
AND eb.dateEnquete = (
|
||||
SELECT MAX(eb2.dateEnquete)
|
||||
FROM EnqueteBatiment eb2
|
||||
WHERE eb2.batiment = b
|
||||
)
|
||||
LEFT JOIN eb.personne per
|
||||
WHERE p.id = :parcelleId
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(b)
|
||||
FROM Batiment b
|
||||
WHERE b.parcelle.id = :parcelleId
|
||||
"""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb(
|
||||
b.id,
|
||||
b.nub,
|
||||
b.code,
|
||||
b.dateConstruction,
|
||||
p.id,
|
||||
p.nup,
|
||||
p.q,
|
||||
p.i,
|
||||
p.p,
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale,
|
||||
eb.surfaceAuSol
|
||||
)
|
||||
FROM Batiment b
|
||||
JOIN b.parcelle p
|
||||
LEFT JOIN EnqueteBatiment eb
|
||||
ON eb.batiment = b
|
||||
AND eb.dateEnquete = (
|
||||
SELECT MAX(eb2.dateEnquete)
|
||||
FROM EnqueteBatiment eb2
|
||||
WHERE eb2.batiment = b
|
||||
)
|
||||
LEFT JOIN eb.personne per
|
||||
WHERE p.id = :parcelleId
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(b)
|
||||
FROM Batiment b
|
||||
WHERE b.parcelle.id = :parcelleId
|
||||
"""
|
||||
)
|
||||
Page<BatimentPaylaodWeb> findAllBatimentsAvecOccupantCourantByParcelleToDtoPageble(
|
||||
@Param("parcelleId") Long parcelleId,
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package io.gmss.fiscad.persistence.repositories.rfu.metier;
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
|
||||
import io.gmss.fiscad.paylaods.response.restoration.UniteLogementPayLoadRestor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -30,4 +34,185 @@ public interface UniteLogementRepository extends JpaRepository<UniteLogement, Lo
|
||||
void deleteByEnqueteId(Long enqueteId);
|
||||
|
||||
Long countByBatiment_Parcelle_Quartier_CodeLike(String codeDecoupage);
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb(
|
||||
ul.id,
|
||||
ul.nul,
|
||||
ul.numeroEtage,
|
||||
ul.code,
|
||||
|
||||
b.id,
|
||||
eul.surfaceLouee,
|
||||
b.nub,
|
||||
eul.observation,
|
||||
ul.dateConstruction,
|
||||
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
)
|
||||
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 ul.id = :uniteLogementId
|
||||
""")
|
||||
Optional<UniteLogementPaylaodWeb> findUniteLogementAvecOccupantCourantToDto(@Param("uniteLogementId") Long uniteLogementId);
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb(
|
||||
ul.id,
|
||||
ul.nul,
|
||||
ul.numeroEtage,
|
||||
ul.code,
|
||||
|
||||
b.id,
|
||||
eul.surfaceLouee,
|
||||
b.nub,
|
||||
eul.observation,
|
||||
ul.dateConstruction,
|
||||
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
)
|
||||
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
|
||||
""")
|
||||
List<UniteLogementPaylaodWeb> findAllUnitesLogementAvecOccupantCourantToDto();
|
||||
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb(
|
||||
ul.id,
|
||||
ul.nul,
|
||||
ul.numeroEtage,
|
||||
ul.code,
|
||||
|
||||
b.id,
|
||||
eul.surfaceLouee,
|
||||
b.nub,
|
||||
eul.observation,
|
||||
ul.dateConstruction,
|
||||
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
)
|
||||
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
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(ul)
|
||||
FROM UniteLogement ul
|
||||
"""
|
||||
)
|
||||
Page<UniteLogementPaylaodWeb> findAllUnitesLogementAvecOccupantCourantToDtoPageable(
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb(
|
||||
ul.id,
|
||||
ul.nul,
|
||||
ul.numeroEtage,
|
||||
ul.code,
|
||||
|
||||
b.id,
|
||||
eul.surfaceLouee,
|
||||
b.nub,
|
||||
eul.observation,
|
||||
ul.dateConstruction,
|
||||
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
)
|
||||
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.id = :batimentId
|
||||
""")
|
||||
List<UniteLogementPaylaodWeb> findUnitesLogementAvecOccupantCourantByBatimentToDto(
|
||||
@Param("batimentId") Long batimentId
|
||||
);
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb(
|
||||
ul.id,
|
||||
ul.nul,
|
||||
ul.numeroEtage,
|
||||
ul.code,
|
||||
|
||||
b.id,
|
||||
eul.surfaceLouee,
|
||||
b.nub,
|
||||
eul.observation,
|
||||
ul.dateConstruction,
|
||||
|
||||
per.id,
|
||||
per.nom,
|
||||
per.prenom,
|
||||
per.raisonSociale
|
||||
)
|
||||
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.id = :batimentId
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(ul)
|
||||
FROM UniteLogement ul
|
||||
WHERE ul.batiment.id = :batimentId
|
||||
"""
|
||||
)
|
||||
Page<UniteLogementPaylaodWeb> findUnitesLogementAvecOccupantCourantByBatimentToDtoPageable(
|
||||
@Param("batimentId") Long batimentId,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user