Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#113) from features/crud_entites into develop
Reviewed-on: #113
This commit was merged in pull request #113.
This commit is contained in:
@@ -51,9 +51,9 @@ public class ParcelleController {
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
|
||||
try {
|
||||
Parcelle parcelle = parcelleService.createParcelle(parcellePayLoadWeb);
|
||||
parcellePayLoadWeb = parcelleService.createParcelle(parcellePayLoadWeb);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, parcelle, "parcelle créée avec succès."),
|
||||
new ApiResponse<>(true, parcellePayLoadWeb, "parcelle créée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
|
||||
|
||||
@Override
|
||||
public Parcelle createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException {
|
||||
public ParcellePayLoadWeb createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException {
|
||||
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoadWeb.getNatureDomaineId());
|
||||
if (!optionalNatureDomaine.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant");
|
||||
@@ -61,11 +61,12 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
parcelle.setNatureDomaine(optionalNatureDomaine.orElse(null));
|
||||
parcelle.setQuartier(optionalQuartier.orElse(null));
|
||||
parcelle = getParcelleFromPayload(parcelle, parcellePayLoadWeb);
|
||||
return parcelleRepository.save(parcelle);
|
||||
parcelle= parcelleRepository.save(parcelle);
|
||||
return parcelleRepository.findParcelleToDtoById(parcelle.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelle updateParcelle(Long id, ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException {
|
||||
public ParcellePayLoadWeb updateParcelle(Long id, ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException {
|
||||
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoadWeb.getId());
|
||||
if (!optionalParcelle.isPresent()) {
|
||||
throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier");
|
||||
@@ -86,7 +87,8 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
parcelle.setNatureDomaine(optionalNatureDomaine.orElse(null));
|
||||
parcelle.setQuartier(optionalQuartier.orElse(null));
|
||||
parcelle = getParcelleFromPayload(optionalParcelle.get(), parcellePayLoadWeb);
|
||||
return parcelleRepository.save(parcelle);
|
||||
parcelle= parcelleRepository.save(parcelle);
|
||||
return parcelleRepository.findParcelleToDtoById(parcelle.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.Optional;
|
||||
public interface ParcelleService {
|
||||
|
||||
|
||||
Parcelle createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException;
|
||||
ParcellePayLoadWeb createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException;
|
||||
|
||||
Parcelle updateParcelle(Long id,ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException;
|
||||
ParcellePayLoadWeb updateParcelle(Long id,ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException;
|
||||
|
||||
void deleteParcelle(Long id) throws NotFoundException;
|
||||
Optional<Parcelle> getParcelleById(Long id);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package io.gmss.fiscad.paylaods.request.crudweb;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class BatimentPaylaodWeb {
|
||||
private Long id;
|
||||
|
||||
@@ -4,10 +4,11 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class DeclarationNcPayloadWeb {
|
||||
private Long id;
|
||||
|
||||
@@ -274,6 +274,61 @@ public interface ParcelleRepository extends JpaRepository<Parcelle, Long>, JpaSp
|
||||
);
|
||||
|
||||
|
||||
@Query("""
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb(
|
||||
p.id,
|
||||
p.q,
|
||||
p.i,
|
||||
p.p,
|
||||
p.nup,
|
||||
p.nupProvisoire,
|
||||
p.numeroTitreFoncier,
|
||||
p.longitude,
|
||||
p.latitude,
|
||||
p.altitude,
|
||||
p.superficie,
|
||||
p.observation,
|
||||
p.situationGeographique,
|
||||
p.numEntreeParcelle,
|
||||
q.id,
|
||||
q.code,
|
||||
q.nom,
|
||||
nd.id,
|
||||
nd.libelle,
|
||||
td.id,
|
||||
td.libelle,
|
||||
r.id,
|
||||
r.numero,
|
||||
r.nom,
|
||||
pers.id,
|
||||
pers.ifu,
|
||||
pers.npi,
|
||||
pers.nom,
|
||||
pers.prenom,
|
||||
pers.raisonSociale,
|
||||
e.id
|
||||
)
|
||||
FROM Parcelle p
|
||||
LEFT JOIN p.quartier q
|
||||
LEFT JOIN p.natureDomaine nd
|
||||
LEFT JOIN p.typeDomaine td
|
||||
LEFT JOIN p.rue r
|
||||
LEFT JOIN Enquete e
|
||||
ON e.parcelle = p
|
||||
AND e.dateEnquete = (
|
||||
SELECT MAX(e2.dateEnquete)
|
||||
FROM Enquete e2
|
||||
WHERE e2.parcelle = p
|
||||
)
|
||||
LEFT JOIN e.personne pers
|
||||
INNER JOIN SecteurDecoupage sd on sd.quartier=p.quartier
|
||||
WHERE p.id = :parcelleId
|
||||
""")
|
||||
Optional<ParcellePayLoadWeb> findParcelleToDtoById(
|
||||
@Param("parcelleId") Long parcelleId
|
||||
);
|
||||
|
||||
|
||||
@Query(
|
||||
value = """
|
||||
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb(
|
||||
|
||||
Reference in New Issue
Block a user