diff --git a/src/main/java/io/gmss/fiscad/controllers/rfu/parametre/UsageController.java b/src/main/java/io/gmss/fiscad/controllers/rfu/parametre/UsageController.java new file mode 100644 index 0000000..a333f65 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/controllers/rfu/parametre/UsageController.java @@ -0,0 +1,180 @@ +package io.gmss.fiscad.controllers.rfu.parametre; + +import io.gmss.fiscad.entities.rfu.parametre.Usage; +import io.gmss.fiscad.exceptions.*; +import io.gmss.fiscad.interfaces.rfu.parametre.UsageService; +import io.gmss.fiscad.paylaods.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.client.HttpClientErrorException; + + +@RestController +@RequestMapping(value = "api/usage", produces = MediaType.APPLICATION_JSON_VALUE) +@SecurityRequirement(name = "bearer") +@Tag(name = "Usage") +public class UsageController { + + private final UsageService usageService; + private static final Logger logger = LoggerFactory.getLogger(UsageController.class); + + public UsageController(UsageService usageService) { + this.usageService = usageService; + } + + + @PostMapping("/create") + public ResponseEntity createUsage(@RequestBody @Valid @Validated Usage usage) { + try { + usage = usageService.createUsage(usage); + return new ResponseEntity<>( + new ApiResponse<>(true, usage, "Usage créé 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); + } + } + + @PutMapping("/update/{id}") + public ResponseEntity updateUsage(@PathVariable Long id, @RequestBody Usage usage) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, usageService.updateUsage(id, usage), "Usage mis à jour 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); + } + } + + @DeleteMapping("/delete/{id}") + public ResponseEntity deleteUsager(@PathVariable Long id) { + try { + usageService.deleteUsage(id); + return new ResponseEntity<>( + new ApiResponse<>(true, "Usage supprimé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") + public ResponseEntity getAllUsageList() { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, usageService.getUsageList(), "Liste des usages 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") + public ResponseEntity getAllUsagePaged(@RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + + return new ResponseEntity<>( + new ApiResponse<>(true, usageService.getUsageList(pageable), "Liste des usages 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 getUsageById(@PathVariable Long id) { + try { + return new ResponseEntity<>( + new ApiResponse<>(true, usageService.getUsageById(id), "Usage 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); + } + } + + +} + diff --git a/src/main/java/io/gmss/fiscad/entities/infocad/metier/Parcelle.java b/src/main/java/io/gmss/fiscad/entities/infocad/metier/Parcelle.java index fb1f558..63cc312 100644 --- a/src/main/java/io/gmss/fiscad/entities/infocad/metier/Parcelle.java +++ b/src/main/java/io/gmss/fiscad/entities/infocad/metier/Parcelle.java @@ -6,6 +6,7 @@ import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine; import io.gmss.fiscad.entities.rfu.metier.Batiment; +import io.gmss.fiscad.entities.rfu.parametre.Usage; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.ColumnDefault; @@ -70,6 +71,8 @@ public class Parcelle extends BaseEntity implements Serializable { private String numeroRue ; private Boolean batie; private Integer nombrePiscine; + @ManyToOne + private Usage usage; // private String ncProprietaire ; // @JsonIgnore // @OneToMany(mappedBy = "parcelle") diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/metier/Batiment.java b/src/main/java/io/gmss/fiscad/entities/rfu/metier/Batiment.java index 6dfa473..e71a859 100644 --- a/src/main/java/io/gmss/fiscad/entities/rfu/metier/Batiment.java +++ b/src/main/java/io/gmss/fiscad/entities/rfu/metier/Batiment.java @@ -8,6 +8,7 @@ import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment; +import io.gmss.fiscad.entities.rfu.parametre.Usage; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Data; @@ -51,6 +52,9 @@ public class Batiment extends BaseEntity implements Serializable { @ManyToOne private Parcelle parcelle; + @ManyToOne + private Usage usage; + @ManyToOne private CategorieBatiment categorieBatiment ; diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteBatiment.java b/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteBatiment.java index 24fc3ca..d70f16b 100644 --- a/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteBatiment.java +++ b/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteBatiment.java @@ -14,6 +14,7 @@ import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.rfu.parametre.Caracteristique; import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment; import io.gmss.fiscad.entities.rfu.parametre.Exercice; +import io.gmss.fiscad.entities.rfu.parametre.Usage; import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.enums.StatutEnquete; import io.gmss.fiscad.enums.StatutEnregistrement; @@ -131,4 +132,6 @@ public class EnqueteBatiment extends BaseEntity implements Serializable { private StatutEnquete statutEnquete; @ManyToOne private CategorieBatiment categorieBatiment ; + @ManyToOne + private Usage usage ; } diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteUniteLogement.java b/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteUniteLogement.java index d91dc93..69c2d07 100644 --- a/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteUniteLogement.java +++ b/src/main/java/io/gmss/fiscad/entities/rfu/metier/EnqueteUniteLogement.java @@ -13,6 +13,7 @@ import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment; import io.gmss.fiscad.entities.rfu.parametre.Exercice; +import io.gmss.fiscad.entities.rfu.parametre.Usage; import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.enums.StatutEnquete; import io.gmss.fiscad.enums.StatutEnregistrement; @@ -119,4 +120,6 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable { private StatutEnquete statutEnquete; @ManyToOne private CategorieBatiment categorieBatiment ; + @ManyToOne + private Usage usage ; } diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/metier/UniteLogement.java b/src/main/java/io/gmss/fiscad/entities/rfu/metier/UniteLogement.java index 6ec0cce..58b472b 100644 --- a/src/main/java/io/gmss/fiscad/entities/rfu/metier/UniteLogement.java +++ b/src/main/java/io/gmss/fiscad/entities/rfu/metier/UniteLogement.java @@ -7,6 +7,7 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer; import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment; +import io.gmss.fiscad.entities.rfu.parametre.Usage; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Data; @@ -40,6 +41,8 @@ public class UniteLogement extends BaseEntity implements Serializable { private List enqueteUniteLogements; @ManyToOne private Batiment batiment; + @ManyToOne + private Usage usage; private Long batimentExternalKey; private Long idDerniereEnquete; private Float SuperficieLouee; diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/parametre/Usage.java b/src/main/java/io/gmss/fiscad/entities/rfu/parametre/Usage.java new file mode 100644 index 0000000..1724143 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/entities/rfu/parametre/Usage.java @@ -0,0 +1,29 @@ +package io.gmss.fiscad.entities.rfu.parametre; + +import io.gmss.fiscad.entities.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.Where; + +import java.io.Serializable; + +@EqualsAndHashCode(callSuper = true) +@Entity +@Data +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = " deleted = false") +public class Usage extends BaseEntity implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String code; + private String nom; +} + diff --git a/src/main/java/io/gmss/fiscad/implementations/rfu/parametre/UsageServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/rfu/parametre/UsageServiceImpl.java new file mode 100644 index 0000000..db8020f --- /dev/null +++ b/src/main/java/io/gmss/fiscad/implementations/rfu/parametre/UsageServiceImpl.java @@ -0,0 +1,67 @@ +package io.gmss.fiscad.implementations.rfu.parametre; + +import io.gmss.fiscad.entities.rfu.parametre.Usage; +import io.gmss.fiscad.exceptions.BadRequestException; +import io.gmss.fiscad.exceptions.NotFoundException; +import io.gmss.fiscad.interfaces.rfu.parametre.UsageService; +import io.gmss.fiscad.persistence.repositories.rfu.parametre.UsageRepository; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public class UsageServiceImpl implements UsageService { + private final UsageRepository usageRepository; + + public UsageServiceImpl(UsageRepository usageRepository) { + this.usageRepository = usageRepository; + } + + @Override + public Usage createUsage(Usage usage) throws BadRequestException { + if (usage.getId() != null) { + throw new BadRequestException("Impossible de créer une nouvelle campgne ayant un id non null."); + } + return usageRepository.save(usage); + } + @Override + public Usage updateUsage(Long id, Usage usage) throws NotFoundException { + if (usage.getId() == null) { + throw new BadRequestException("Impossible de mettre à jour une nouvelle usage ayant un id null."); + } + if (!usageRepository.existsById(usage.getId())) { + throw new NotFoundException("Impossible de trouver la usage spécifiée dans notre base de données."); + } + return usageRepository.save(usage); + } + + @Override + public void deleteUsage(Long id) throws NotFoundException { + Optional usageOptional = usageRepository.findById(id); + if (usageOptional.isPresent()) { + usageRepository.deleteById(usageOptional.get().getId()); + } else { + throw new NotFoundException("Impossible de trouver la usage spécifiée dans notre base de données."); + } + } + @Override + public Page getUsageList(Pageable pageable) { + return usageRepository.findAll(pageable); + } + + @Override + public List getUsageList() { + return usageRepository.findAll(); + } + + + + @Override + public Optional getUsageById(Long id) { + return usageRepository.findById(id); + } +} + diff --git a/src/main/java/io/gmss/fiscad/interfaces/rfu/parametre/UsageService.java b/src/main/java/io/gmss/fiscad/interfaces/rfu/parametre/UsageService.java new file mode 100644 index 0000000..6723c01 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/interfaces/rfu/parametre/UsageService.java @@ -0,0 +1,27 @@ +package io.gmss.fiscad.interfaces.rfu.parametre; + +import io.gmss.fiscad.entities.rfu.parametre.Usage; +import io.gmss.fiscad.exceptions.BadRequestException; +import io.gmss.fiscad.exceptions.NotFoundException; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.List; +import java.util.Optional; + +public interface UsageService { + + Usage createUsage(Usage usage) throws BadRequestException; + + Usage updateUsage(Long id, Usage usage) throws NotFoundException; + + void deleteUsage(Long id) throws NotFoundException; + + Page getUsageList(Pageable pageable); + + List getUsageList(); + + + Optional getUsageById(Long id); +} + diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/BatimentPaylaodWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/BatimentPaylaodWeb.java index 9c8705e..a357b0b 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/BatimentPaylaodWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/BatimentPaylaodWeb.java @@ -32,6 +32,9 @@ public class BatimentPaylaodWeb { private Long valeurBatimentEstime; private Long valeurBatimentReel; private Long montantMensuelLocation; + private Long usageId; + private String usageNom; + public BatimentPaylaodWeb(Long id, String nub, String code, @@ -56,7 +59,9 @@ public class BatimentPaylaodWeb { Long montantLocatifAnnuelCalcule, Long valeurBatimentEstime, Long valeurBatimentReel, - Long montantMensuelLocation) { + Long montantMensuelLocation, + Long usageId, + String usageNom) { this.id = id; this.nub = nub; this.code = code; @@ -82,5 +87,7 @@ public class BatimentPaylaodWeb { this.valeurBatimentEstime = valeurBatimentEstime ; this.valeurBatimentReel = valeurBatimentReel ; this.montantMensuelLocation = montantMensuelLocation ; + this.usageId = usageId ; + this.usageNom = usageNom ; } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteBatimentPayloadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteBatimentPayloadWeb.java index 54cdb6b..646cb07 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteBatimentPayloadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteBatimentPayloadWeb.java @@ -65,6 +65,8 @@ public class EnqueteBatimentPayloadWeb { private String categorieBatimentStanding; private Integer nombrePiscine; private Long montantLocatifAnnuelCalcule; + private Long usageId; + private String usageNom; public EnqueteBatimentPayloadWeb(Long id, String observation, String autreMenuisierie, String autreMur, boolean sbee, String numCompteurSbee, boolean soneb, String numCompteurSoneb, int nbreLotUnite, int nbreUniteLocation, Float superficieLouee, Float superficieAuSol, LocalDate dateEnquete, int nbreMenage, int nbreHabitant, Long montantMensuelLocation, Long montantLocatifAnnuelDeclare, Long nbreEtage, Long valeurBatimentEstime, Long valeurBatimentReel, int nbreMoisLocation, String autreCaracteristiquePhysique, LocalDate dateDebutExcemption, LocalDate dateFinExcemption, Long batimentId, String batimentNub, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom, StatutEnquete statutEnquete, @@ -78,7 +80,9 @@ public class EnqueteBatimentPayloadWeb { String categorieBatimentCode, String categorieBatimentStanding, Integer nombrePiscine, - Long montantLocatifAnnuelCalcule + Long montantLocatifAnnuelCalcule, + Long usageId, + String usageNom ) { this.id = id; this.observation = observation; @@ -125,6 +129,7 @@ public class EnqueteBatimentPayloadWeb { this.categorieBatimentStanding = categorieBatimentStanding; this.nombrePiscine = nombrePiscine; this.montantLocatifAnnuelCalcule = montantLocatifAnnuelCalcule; - + this.usageId = usageId ; + this.usageNom = usageNom ; } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteUniteLogementPayloadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteUniteLogementPayloadWeb.java index 8a30fbf..28668a0 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteUniteLogementPayloadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnqueteUniteLogementPayloadWeb.java @@ -54,6 +54,8 @@ public class EnqueteUniteLogementPayloadWeb { private String categorieBatimentStanding; private Long montantLocatifAnnuelCalcule; private Integer nombrePiscine; + private Long usageId; + private String usageNom; public EnqueteUniteLogementPayloadWeb(Long id, String observation, Integer nbrePiece, Integer nbreHabitant, Integer nbreMenage, Boolean enLocation, Integer nbreMoisLocation, Long montantMensuelLocation, Long montantLocatifAnnuelDeclare, Long valeurUniteLogementEstime, Long valeurUniteLogementReel, Float superficieLouee, Float superficieAuSol, LocalDate dateEnquete, Boolean sbee, Boolean soneb, String numCompteurSbee, String numCompteurSoneb, LocalDate dateDebutExemption, LocalDate dateFinExemption, Long uniteLogementId, String uniteLogementNumeroEtage, String uniteLogementNul, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom, Long exerciceId, Integer exerciceAnnee, StatutEnquete statutEnquete, String representantNom, @@ -64,7 +66,9 @@ public class EnqueteUniteLogementPayloadWeb { String categorieBatimentCode, String categorieBatimentStanding, Integer nombrePiscine, - Long montantLocatifAnnuelCalcule + Long montantLocatifAnnuelCalcule, + Long usageId, + String usageNom ) { this.id = id; this.observation = observation; @@ -108,5 +112,7 @@ public class EnqueteUniteLogementPayloadWeb { this.categorieBatimentStanding = categorieBatimentStanding; this.nombrePiscine = nombrePiscine; this.montantLocatifAnnuelCalcule = montantLocatifAnnuelCalcule; + this.usageId = usageId ; + this.usageNom = usageNom ; } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UniteLogementPaylaodWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UniteLogementPaylaodWeb.java index bf2e018..1258fbd 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UniteLogementPaylaodWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UniteLogementPaylaodWeb.java @@ -31,6 +31,8 @@ public class UniteLogementPaylaodWeb { private Long valeurUniteLogementEstime; private Long valeurUniteLogementReel; private Integer nombrePiscine; + private Long usageId; + private String usageNom; public UniteLogementPaylaodWeb(Long id, String nul, String numeroEtage, String code, Long batimentId, Float superficieAuSol, Float superficieLouee, String batimentNub, String observation, LocalDate dateConstruction, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale,Long enqueteUniteLogementCourantId, Long categorieBatimentId, @@ -41,7 +43,10 @@ public class UniteLogementPaylaodWeb { Long montantLocatifAnnuelCalcule, Long valeurUniteLogementEstime, Long valeurUniteLogementReel, - Integer nombrePiscine) { + Integer nombrePiscine, + Long usageId, + String usageNom + ) { this.id = id; this.nul = nul; this.numeroEtage = numeroEtage; @@ -66,5 +71,7 @@ public class UniteLogementPaylaodWeb { this.valeurUniteLogementEstime = valeurUniteLogementEstime; this.valeurUniteLogementReel = valeurUniteLogementReel; this.nombrePiscine = nombrePiscine; + this.usageId = usageId ; + this.usageNom = usageNom ; } } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/BatimentRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/BatimentRepository.java index 3ae1609..8de9d12 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/BatimentRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/BatimentRepository.java @@ -60,7 +60,9 @@ public interface BatimentRepository extends JpaRepository { eb.montantLocatifAnnuelCalcule, eb.valeurBatimentEstime, eb.valeurBatimentReel, - eb.montantMensuelLocation + eb.montantMensuelLocation, + us.id, + us.nom ) FROM Batiment b JOIN b.parcelle p @@ -73,6 +75,7 @@ public interface BatimentRepository extends JpaRepository { WHERE eb2.batiment = b ) LEFT JOIN eb.personne per + LEFT JOIN eb.usage us WHERE b.id = :batimentId """) Optional findBatimentAvecOccupantCourantToDto(@Param("batimentId") Long batimentId); @@ -103,7 +106,9 @@ public interface BatimentRepository extends JpaRepository { eb.montantLocatifAnnuelCalcule, eb.valeurBatimentEstime, eb.valeurBatimentReel, - eb.montantMensuelLocation + eb.montantMensuelLocation, + us.id, + us.nom ) FROM Batiment b JOIN b.parcelle p @@ -116,6 +121,7 @@ public interface BatimentRepository extends JpaRepository { WHERE eb2.batiment = b ) LEFT JOIN eb.personne per + LEFT JOIN eb.usage us """) List findAllBatimentsAvecOccupantCourantToDto(); @@ -147,7 +153,9 @@ public interface BatimentRepository extends JpaRepository { eb.montantLocatifAnnuelCalcule, eb.valeurBatimentEstime, eb.valeurBatimentReel, - eb.montantMensuelLocation + eb.montantMensuelLocation , + us.id, + us.nom ) FROM Batiment b JOIN b.parcelle p @@ -160,6 +168,7 @@ public interface BatimentRepository extends JpaRepository { WHERE eb2.batiment = b ) LEFT JOIN eb.personne per + LEFT JOIN eb.usage us """, countQuery = """ SELECT COUNT(b) @@ -196,7 +205,9 @@ public interface BatimentRepository extends JpaRepository { eb.montantLocatifAnnuelCalcule, eb.valeurBatimentEstime, eb.valeurBatimentReel, - eb.montantMensuelLocation + eb.montantMensuelLocation , + us.id, + us.nom ) FROM Batiment b JOIN b.parcelle p @@ -209,6 +220,7 @@ public interface BatimentRepository extends JpaRepository { WHERE eb2.batiment = b ) LEFT JOIN eb.personne per + LEFT JOIN eb.usage us WHERE p.id = :parcelleId """) List findAllBatimentsAvecOccupantCourantByParcelleToDto( @@ -244,7 +256,9 @@ public interface BatimentRepository extends JpaRepository { eb.montantLocatifAnnuelCalcule, eb.valeurBatimentEstime, eb.valeurBatimentReel, - eb.montantMensuelLocation + eb.montantMensuelLocation, + us.id, + us.nom ) FROM Batiment b JOIN b.parcelle p @@ -257,6 +271,7 @@ public interface BatimentRepository extends JpaRepository { WHERE eb2.batiment = b ) LEFT JOIN eb.personne per + LEFT JOIN eb.usage us WHERE p.id = :parcelleId """, countQuery = """ diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteBatimentRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteBatimentRepository.java index 87c7898..07fa2ae 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteBatimentRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteBatimentRepository.java @@ -105,7 +105,9 @@ public interface EnqueteBatimentRepository extends JpaRepository findEnqueteBatimentByIdToDto(@Param("enqueteBatimentId") Long enqueteBatimentId); @@ -166,7 +169,9 @@ public interface EnqueteBatimentRepository extends JpaRepository findAllEnqueteBatimentToDto(); @@ -227,7 +233,9 @@ public interface EnqueteBatimentRepository extends JpaRepository findAllByBatimentToDto( @@ -358,7 +370,9 @@ public interface EnqueteBatimentRepository extends JpaRepository findEnqueteUniteLogementToDto(@Param("enqueteUniteLogementId") Long enqueteUniteLogementId); @@ -157,7 +160,9 @@ public interface EnqueteUniteLogementRepository extends JpaRepository findAllEnqueteUniteLogementToDto(); @@ -217,7 +223,9 @@ public interface EnqueteUniteLogementRepository extends JpaRepository findAllByUniteLogementToDto( @@ -345,7 +357,9 @@ public interface EnqueteUniteLogementRepository extends JpaRepository findAllByExerciceToDto( @@ -475,7 +493,9 @@ public interface EnqueteUniteLogementRepository extends JpaRepository findUniteLogementAvecOccupantCourantToDto(@Param("uniteLogementId") Long uniteLogementId); @@ -106,7 +109,9 @@ public interface UniteLogementRepository extends JpaRepository findAllUnitesLogementAvecOccupantCourantToDto(); @@ -151,7 +157,9 @@ public interface UniteLogementRepository extends JpaRepository findUnitesLogementAvecOccupantCourantByBatimentToDto( @@ -248,7 +260,9 @@ public interface UniteLogementRepository extends JpaRepository findAllUnitesLogementAvecOccupantCourantByParcelleToDto(@Param("parcelleId") Long parcelleId); diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/parametre/UsageRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/parametre/UsageRepository.java new file mode 100644 index 0000000..6dbecc7 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/parametre/UsageRepository.java @@ -0,0 +1,14 @@ +package io.gmss.fiscad.persistence.repositories.rfu.parametre; + +import io.gmss.fiscad.entities.rfu.parametre.Usage; +import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu; +import io.gmss.fiscad.paylaods.response.synchronisation.ZoneRfuSyncResponse; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface UsageRepository extends JpaRepository { + +} + diff --git a/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java b/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java index c0edb54..24eec72 100644 --- a/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java +++ b/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java @@ -7,10 +7,7 @@ import io.gmss.fiscad.entities.infocad.metier.Piece; import io.gmss.fiscad.entities.infocad.metier.Upload; import io.gmss.fiscad.entities.infocad.parametre.*; import io.gmss.fiscad.entities.rfu.metier.*; -import io.gmss.fiscad.entities.rfu.parametre.Caracteristique; -import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment; -import io.gmss.fiscad.entities.rfu.parametre.Exercice; -import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu; +import io.gmss.fiscad.entities.rfu.parametre.*; import io.gmss.fiscad.entities.user.AvoirFonction; import io.gmss.fiscad.entities.user.Fonction; import io.gmss.fiscad.entities.user.Profile; @@ -632,6 +629,12 @@ public class EntityFromPayLoadService { eul.setCategorieBatiment(categorieBatiment); } + if (enqueteUniteLogementPayloadWeb.getUsageId() != null) { + Usage usage = new Usage(); + usage.setId(enqueteUniteLogementPayloadWeb.getUsageId()); + eul.setUsage(usage); + } + eul.setId(enqueteUniteLogementPayloadWeb.getId()); eul.setObservation(enqueteUniteLogementPayloadWeb.getObservation()); @@ -701,6 +704,12 @@ public class EntityFromPayLoadService { enqueteBatiment.setCategorieBatiment(categorieBatiment); } + if (enqueteBatimentPayloadWeb.getUsageId() != null) { + Usage usage = new Usage(); + usage.setId(enqueteBatimentPayloadWeb.getUsageId()); + enqueteBatiment.setUsage(usage); + } + // ====================== // Champs simples // ====================== diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 7a2dd25..17ab386 100755 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ -spring.profiles.active=${SPRING_PROFILES_ACTIVE} +#spring.profiles.active=${SPRING_PROFILES_ACTIVE} #spring.profiles.active=abomey -#spring.profiles.active=test +spring.profiles.active=test spring.jpa.properties.hibernate.id.new_generator_mappings=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true spring.jpa.open-in-view=false