Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#87) from features/crud_entites into develop
Reviewed-on: #87
This commit was merged in pull request #87.
This commit is contained in:
@@ -154,6 +154,53 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/all/by-parcelle-id/{parcelleId}")
|
||||||
|
public ResponseEntity<?> getAllBatimentByParcelleList(@PathVariable Long parcelleId) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, batimentService.getBatimentListByParcelle(parcelleId), "Liste des caractéristiques 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-parcelle-id/{parcelleId}")
|
||||||
|
public ResponseEntity<?> getAllBatimentByParcellePaged(@PathVariable Long parcelleId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
try {
|
||||||
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, batimentService.getBatimentListByParcellePageable(parcelleId,pageable), "Liste des caractéristiques 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}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
|
public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
|
|||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateFinExcemption;
|
private LocalDate dateFinExcemption;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
|
private LocalDate dateEnquete;
|
||||||
|
|
||||||
//@JsonIgnore
|
//@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Personne personne;
|
private Personne personne;
|
||||||
|
|||||||
@@ -156,7 +156,11 @@ public class ParcelleServiceImpl implements ParcelleService {
|
|||||||
@Override
|
@Override
|
||||||
public Page<ParcellePayLoadWeb> getParcelleListByRuePageableToDto(Long userId, Long rueId, Pageable pageable) {
|
public Page<ParcellePayLoadWeb> getParcelleListByRuePageableToDto(Long userId, Long rueId, Pageable pageable) {
|
||||||
List<Long> secteurIds = getSecteurIdListForUser(userId);
|
List<Long> secteurIds = getSecteurIdListForUser(userId);
|
||||||
|
System.out.println(rueId);
|
||||||
|
secteurIds.forEach(aLong -> {
|
||||||
|
System.out.println(aLong);
|
||||||
|
|
||||||
|
});
|
||||||
return parcelleRepository.findAllParcelleByRueToDtoPageable(rueId,secteurIds,pageable);
|
return parcelleRepository.findAllParcelleByRueToDtoPageable(rueId,secteurIds,pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,20 +56,30 @@ public class BatimentServiceImpl implements BatimentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Batiment> getBatimentList(Pageable pageable) {
|
public Page<BatimentPaylaodWeb> getBatimentList(Pageable pageable) {
|
||||||
return batimentRepository.findAll(pageable);
|
return batimentRepository.findAllBatimentsAvecOccupantCourantToDtoPageble(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Batiment> getBatimentList() {
|
public List<BatimentPaylaodWeb> getBatimentList() {
|
||||||
return batimentRepository.findAll();
|
return batimentRepository.findAllBatimentsAvecOccupantCourantToDto();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<BatimentPaylaodWeb> getBatimentListByParcellePageable(Long parcelleId, Pageable pageable) {
|
||||||
|
return batimentRepository.findAllBatimentsAvecOccupantCourantByParcelleToDtoPageble(parcelleId,pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BatimentPaylaodWeb> getBatimentListByParcelle(Long parcelleId) {
|
||||||
|
return batimentRepository.findAllBatimentsAvecOccupantCourantByParcelleToDto(parcelleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Batiment> getBatimentById(Long id) {
|
public Optional<BatimentPaylaodWeb> getBatimentById(Long id) {
|
||||||
if (batimentRepository.existsById(id)) {
|
if (batimentRepository.existsById(id)) {
|
||||||
return batimentRepository.findById(id);
|
return batimentRepository.findBatimentAvecOccupantCourantToDto(id);
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données.");
|
throw new NotFoundException("Impossible de trouver la caractéristique spécifiée dans la base de données.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ public interface BatimentService {
|
|||||||
|
|
||||||
void deleteBatiment(Long id) throws NotFoundException;
|
void deleteBatiment(Long id) throws NotFoundException;
|
||||||
|
|
||||||
Page<Batiment> getBatimentList(Pageable pageable);
|
Page<BatimentPaylaodWeb> getBatimentList(Pageable pageable);
|
||||||
|
|
||||||
List<Batiment> getBatimentList();
|
List<BatimentPaylaodWeb> getBatimentList();
|
||||||
|
|
||||||
Optional<Batiment> getBatimentById(Long id);
|
Page<BatimentPaylaodWeb> getBatimentListByParcellePageable(Long parcelleId, Pageable pageable);
|
||||||
|
|
||||||
|
List<BatimentPaylaodWeb> getBatimentListByParcelle(Long parcelleId);
|
||||||
|
|
||||||
|
Optional<BatimentPaylaodWeb> getBatimentById(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,28 @@ public class BatimentPaylaodWeb {
|
|||||||
private String code;
|
private String code;
|
||||||
private LocalDate dateConstruction;
|
private LocalDate dateConstruction;
|
||||||
private Long parcelleId;
|
private Long parcelleId;
|
||||||
private String observation;
|
private String parcelleNup;
|
||||||
|
private String parcelleQ;
|
||||||
|
private String parcelleI;
|
||||||
|
private String parcelleP;
|
||||||
|
private Long personneId;
|
||||||
|
private String personneNom;
|
||||||
|
private String personnePrenom;
|
||||||
|
private 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) {
|
||||||
|
this.id = id;
|
||||||
|
this.nub = nub;
|
||||||
|
this.code = code;
|
||||||
|
this.dateConstruction = dateConstruction;
|
||||||
|
this.parcelleId = parcelleId;
|
||||||
|
this.parcelleNup = parcelleNup;
|
||||||
|
this.parcelleQ = parcelleQ;
|
||||||
|
this.parcelleI = parcelleI;
|
||||||
|
this.parcelleP = parcelleP;
|
||||||
|
this.personneId = personneId;
|
||||||
|
this.personneNom = personneNom;
|
||||||
|
this.personnePrenom = personnePrenom;
|
||||||
|
this.personneRaisonSociale = personneRaisonSociale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package io.gmss.fiscad.persistence.repositories.rfu.metier;
|
package io.gmss.fiscad.persistence.repositories.rfu.metier;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
||||||
|
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
|
||||||
import io.gmss.fiscad.paylaods.response.restoration.BatimentPayloadRestor;
|
import io.gmss.fiscad.paylaods.response.restoration.BatimentPayloadRestor;
|
||||||
|
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.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -29,4 +33,175 @@ public interface BatimentRepository extends JpaRepository<Batiment, Long> {
|
|||||||
|
|
||||||
Long countByParcelle_Quartier_CodeLike(String codeQuartier);
|
Long countByParcelle_Quartier_CodeLike(String codeQuartier);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
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 b.id = :batimentId
|
||||||
|
""")
|
||||||
|
Optional<BatimentPaylaodWeb> findBatimentAvecOccupantCourantToDto(@Param("batimentId") Long batimentId);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
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
|
||||||
|
""")
|
||||||
|
List<BatimentPaylaodWeb> findAllBatimentsAvecOccupantCourantToDto();
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
|
""",
|
||||||
|
countQuery = """
|
||||||
|
SELECT COUNT(b)
|
||||||
|
FROM Batiment b
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<BatimentPaylaodWeb> findAllBatimentsAvecOccupantCourantToDtoPageble(Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
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
|
||||||
|
""")
|
||||||
|
List<BatimentPaylaodWeb> findAllBatimentsAvecOccupantCourantByParcelleToDto(
|
||||||
|
@Param("parcelleId") Long parcelleId
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Page<BatimentPaylaodWeb> findAllBatimentsAvecOccupantCourantByParcelleToDtoPageble(
|
||||||
|
@Param("parcelleId") Long parcelleId,
|
||||||
|
Pageable pageable
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ spring.profiles.active=${SPRING_PROFILES_ACTIVE}
|
|||||||
spring.jpa.properties.hibernate.id.new_generator_mappings=false
|
spring.jpa.properties.hibernate.id.new_generator_mappings=false
|
||||||
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
|
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
|
||||||
spring.jpa.open-in-view=false
|
spring.jpa.open-in-view=false
|
||||||
spring.jpa.show-sql=true
|
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
jwt.jwtSecret=ImThEVeryB@dS@lt@302839_
|
jwt.jwtSecret=ImThEVeryB@dS@lt@302839_
|
||||||
jwt.jwtExpirationInMs=7776000000
|
jwt.jwtExpirationInMs=7776000000
|
||||||
@@ -63,4 +62,14 @@ server.tomcat.max-http-form-post-size=200MB
|
|||||||
|
|
||||||
# ?? R<>duire le bruit des logs 'client aborted' (optionnel)
|
# ?? R<>duire le bruit des logs 'client aborted' (optionnel)
|
||||||
logging.level.org.springframework.web.servlet.mvc.method.annotation=INFO
|
logging.level.org.springframework.web.servlet.mvc.method.annotation=INFO
|
||||||
logging.level.org.apache.catalina.connector.ClientAbortException=ERROR
|
logging.level.org.apache.catalina.connector.ClientAbortException=ERROR
|
||||||
|
|
||||||
|
|
||||||
|
# Affiche les requ<71>tes SQL
|
||||||
|
#spring.jpa.show-sql=true
|
||||||
|
# Formate le SQL pour la lisibilit<69>
|
||||||
|
#spring.jpa.properties.hibernate.format_sql=true
|
||||||
|
|
||||||
|
# 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
|
||||||
Reference in New Issue
Block a user