diff --git a/pom.xml b/pom.xml index 54de53e..384780f 100755 --- a/pom.xml +++ b/pom.xml @@ -149,6 +149,12 @@ provided + + com.wildbit.java + postmark + 1.7.6 + + diff --git a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleController.java b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleController.java index ef1e0c2..648b2f5 100644 --- a/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleController.java +++ b/src/main/java/io/gmss/fiscad/controllers/infocad/metier/ParcelleController.java @@ -10,6 +10,8 @@ import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad; import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb; +import io.gmss.fiscad.security.CurrentUser; +import io.gmss.fiscad.security.UserPrincipal; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; @@ -118,12 +120,67 @@ public class ParcelleController { return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); } } - + // @GetMapping("/all/by-decoupage") +// public ResponseEntity getAllByDecoupage() { +// try { +// return new ResponseEntity<>( +// new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes 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 getParcelleById(@CurrentUser UserPrincipal currentUser, @PathVariable Long id) { + try { + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); + return new ResponseEntity<>( + new ApiResponse<>(true, parcelleService.getParcelleByIdToDto(userId,id), "enquete trouvé 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 getAllParcelle() { + public ResponseEntity getAllParcelle(@CurrentUser UserPrincipal currentUser) { try { + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); return new ResponseEntity<>( - new ApiResponse<>(true, parcelleService.getParcelleList(), "Liste des enquetes chargée avec succès."), + new ApiResponse<>(true, parcelleService.getParcelleListToDto(userId), "Liste des enquetes chargée avec succès."), HttpStatus.OK ); } catch (HttpClientErrorException.MethodNotAllowed e) { @@ -142,37 +199,19 @@ public class ParcelleController { } } - - @GetMapping("/all/by-decoupage") - public ResponseEntity getAllByDecoupage() { - try { - return new ResponseEntity<>( - new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes 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 getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) { + public ResponseEntity getAllParcellePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) { try { Pageable pageable = PageRequest.of(pageNo, pageSize); + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); + return new ResponseEntity<>( - new ApiResponse<>(true, parcelleService.getParcelleList(pageable), "Liste des enquetes chargée avec succès."), + new ApiResponse<>(true, parcelleService.getParcelleListPageableToDto(userId,pageable), "Liste des enquetes chargée avec succès."), HttpStatus.OK ); } catch (HttpClientErrorException.MethodNotAllowed e) { @@ -191,13 +230,17 @@ public class ParcelleController { } } - - - @GetMapping("/id/{id}") - public ResponseEntity getStructureById(@PathVariable Long id) { + @GetMapping("/all/by-quartier-id/{quartierId}") + public ResponseEntity getAllParcelleByQuartier(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId) { try { + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); return new ResponseEntity<>( - new ApiResponse<>(true, parcelleService.getParcelleById(id), "enquete trouvé avec succès."), + new ApiResponse<>(true, parcelleService.getParcelleListByQuartierToDto(userId,quartierId), "Liste des enquetes chargée avec succès."), HttpStatus.OK ); } catch (HttpClientErrorException.MethodNotAllowed e) { @@ -216,14 +259,19 @@ public class ParcelleController { } } - - - @GetMapping("/user-id/{userId}") - public ResponseEntity getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) { + @GetMapping("/all-paged/by-quartier-id/{quartierId}") + public ResponseEntity getAllParcelleByQuartierPaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) { try { Pageable pageable = PageRequest.of(pageNo, pageSize); + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); + return new ResponseEntity<>( - new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé avec succès."), + new ApiResponse<>(true, parcelleService.getParcelleListByQuartierPageableToDto(userId,quartierId,pageable), "Liste des enquetes chargée avec succès."), HttpStatus.OK ); } catch (HttpClientErrorException.MethodNotAllowed e) { @@ -243,6 +291,96 @@ public class ParcelleController { } + @GetMapping("/all/by-rue-id/{rueId}") + public ResponseEntity getAllParcelleByRue(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId) { + try { + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); + return new ResponseEntity<>( + new ApiResponse<>(true, parcelleService.getParcelleListByRueToDto(userId,rueId), "Liste des enquetes 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-rue-id/{rueId}") + public ResponseEntity getAllParcelleByRuePaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId, @RequestParam int pageNo, @RequestParam int pageSize) { + try { + Pageable pageable = PageRequest.of(pageNo, pageSize); + if(currentUser==null) + return new ResponseEntity<>( + new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"), + HttpStatus.OK + ); + Long userId = currentUser.getUser().getId(); + + return new ResponseEntity<>( + new ApiResponse<>(true, parcelleService.getParcelleListByRuePageableToDto(userId,rueId,pageable), "Liste des enquetes 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("/user-id/{userId}") +// public ResponseEntity getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) { +// try { +// Pageable pageable = PageRequest.of(pageNo, pageSize); +// return new ResponseEntity<>( +// new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé 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/controllers/user/UserController.java b/src/main/java/io/gmss/fiscad/controllers/user/UserController.java index 809eca0..f6a36d2 100755 --- a/src/main/java/io/gmss/fiscad/controllers/user/UserController.java +++ b/src/main/java/io/gmss/fiscad/controllers/user/UserController.java @@ -94,7 +94,7 @@ public class UserController { @PostMapping("/reset-password") public ResponseEntity resetUserPassword(@RequestBody @Valid @Validated Login login) { try { - UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername(), login.getPassword()); + UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername()); return new ResponseEntity<>( new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."), HttpStatus.OK @@ -163,31 +163,37 @@ public class UserController { } } - @GetMapping("/activate-or-not/{id}") - public ResponseEntity acitvateOrNotUser(@PathVariable Long id) { + @GetMapping("/activate/{id}") + public ResponseEntity acitvateUser(@PathVariable Long id) { try { - - User user = userService.getUserById(id); -// if(user.getAvoirFonctions().isEmpty()){ -// return new ResponseEntity<>( -// new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."), -// HttpStatus.OK -// ); -// } - - if(user.isResetPassword()){ - return new ResponseEntity<>( - new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."), - HttpStatus.OK - ); - } - user = userService.activateOrNotUser(id); - String message = "Utilisateur activé avec succès"; - if (!user.isActive()) { - message = "Utilisateur désactivé avec succès"; - } + User user = userService.activateUser(id); return new ResponseEntity<>( - new ApiResponse<>(true, user, message), + new ApiResponse<>(true, user, "Utilisateur activé 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("/desactivate/{id}") + public ResponseEntity disacitvateUser(@PathVariable Long id) { + try { + User user = userService.disactivateUser(id); + return new ResponseEntity<>( + new ApiResponse<>(true, user, "Utilisateur désactivé avec succès"), HttpStatus.OK ); } catch (HttpClientErrorException.MethodNotAllowed e) { @@ -330,14 +336,6 @@ public class UserController { } -// @GetMapping("/all-paged") -// public ResponseEntity getAllpaged(@RequestParam int pageNo, @RequestParam int pageSize) { -// Pageable pageable = PageRequest.of(pageNo, pageSize); -// return new ResponseEntity<>( -// new ApiResponse<>(true, userService.getUserList(pageable), "Liste des utilisateurs chargée avec succès."), -// HttpStatus.OK -// ); -// } @GetMapping("/id/{id}") public ResponseEntity getUserById(@PathVariable Long id) { diff --git a/src/main/java/io/gmss/fiscad/entities/Parameters.java b/src/main/java/io/gmss/fiscad/entities/Parameters.java new file mode 100755 index 0000000..4d0e3d8 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/entities/Parameters.java @@ -0,0 +1,28 @@ +package io.gmss.fiscad.entities; + +import io.gmss.fiscad.entities.audit.UserDateAudit; +import io.gmss.fiscad.enums.ParametersType; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +@Entity +@Getter +@Setter +public class Parameters extends UserDateAudit implements Serializable { + + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @Enumerated(EnumType.STRING) + private ParametersType name; + private String value; + + public Parameters() { + } + + +} diff --git a/src/main/java/io/gmss/fiscad/entities/audit/DateAudit.java b/src/main/java/io/gmss/fiscad/entities/audit/DateAudit.java new file mode 100755 index 0000000..ad95c1e --- /dev/null +++ b/src/main/java/io/gmss/fiscad/entities/audit/DateAudit.java @@ -0,0 +1,43 @@ +package io.gmss.fiscad.entities.audit; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import java.io.Serializable; +import java.time.Instant; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class DateAudit implements Serializable { + + @JsonIgnore + @CreatedDate + // @Column(updatable = false) + private Instant createdAt= Instant.now() ; + + @JsonIgnore + @LastModifiedDate + // @Column(nullable = false) + private Instant updatedAt=Instant.now(); + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/io/gmss/fiscad/entities/audit/UserDateAudit.java b/src/main/java/io/gmss/fiscad/entities/audit/UserDateAudit.java new file mode 100755 index 0000000..3ac05ce --- /dev/null +++ b/src/main/java/io/gmss/fiscad/entities/audit/UserDateAudit.java @@ -0,0 +1,37 @@ +package io.gmss.fiscad.entities.audit; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.LastModifiedBy; + +import java.io.Serializable; + +@MappedSuperclass +public abstract class UserDateAudit extends DateAudit implements Serializable { + @JsonIgnore + @CreatedBy + @Column(updatable = false) + private Long createdBy; + + @JsonIgnore + @LastModifiedBy + private Long updatedBy; + + public Long getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(Long createdBy) { + this.createdBy = createdBy; + } + + public Long getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(Long updatedBy) { + this.updatedBy = updatedBy; + } +} \ No newline at end of file diff --git a/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java b/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java index 120c90a..2336927 100644 --- a/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java +++ b/src/main/java/io/gmss/fiscad/entities/infocad/metier/Enquete.java @@ -181,16 +181,16 @@ public class Enquete extends BaseEntity implements Serializable { @JsonFormat(pattern = "dd-MM-yyyy") @JsonDeserialize(using = LocalDateDeserializer.class) private LocalDate dateFinExcemption; +// +// @JsonIgnore +// @OneToMany(mappedBy = "enquete") +// @JsonManagedReference +// private List enqueteUniteLogements; - @JsonIgnore - @OneToMany(mappedBy = "enquete") - @JsonManagedReference - private List enqueteUniteLogements; - - @JsonIgnore - @JsonManagedReference - @OneToMany(mappedBy = "enquete") - private List enqueteBatiments; +// @JsonIgnore +// @JsonManagedReference +// @OneToMany(mappedBy = "enquete") +// private List enqueteBatiments; @JsonIgnore @OneToMany(mappedBy = "enquete") 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 09486da..3d2da91 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 @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import io.gmss.fiscad.entities.BaseEntity; 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 jakarta.persistence.*; import lombok.*; @@ -38,9 +39,11 @@ public class Parcelle extends BaseEntity implements Serializable { private String altitude; private String situationGeographique; @ColumnDefault("0.0") - private float superficie; + private Float superficie; @ManyToOne private NatureDomaine natureDomaine; + @ManyToOne + private TypeDomaine typeDomaine; @JsonIgnore @ManyToOne private Quartier quartier; @@ -52,7 +55,6 @@ public class Parcelle extends BaseEntity implements Serializable { @ManyToOne private Tpe terminal; private String autreNumeroTitreFoncier; - private Long typeDomaineId; private Long numeroProvisoire; private Long blocId; @ColumnDefault("false") @@ -64,6 +66,7 @@ public class Parcelle extends BaseEntity implements Serializable { @ManyToOne private Rue rue ; private String numeroRue ; + // private String ncProprietaire ; // @JsonIgnore // @OneToMany(mappedBy = "parcelle") // private List batiments; 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 fec0788..23a0128 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 @@ -86,9 +86,9 @@ public class EnqueteBatiment extends BaseEntity implements Serializable { private Long nbreEtage; // @JsonIgnore - @ManyToOne(fetch = FetchType.LAZY) - @JsonBackReference - private Enquete enquete; +// @ManyToOne(fetch = FetchType.LAZY) +// @JsonBackReference +// private Enquete enquete; 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 bdbda48..288fbe2 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 @@ -63,10 +63,10 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable { @JsonDeserialize(using = LocalDateDeserializer.class) private LocalDate dateFinExcemption; - @JsonIgnore - @ManyToOne(fetch = FetchType.LAZY) - @JsonBackReference - private Enquete enquete; +// @JsonIgnore +// @ManyToOne(fetch = FetchType.LAZY) +// @JsonBackReference +// private Enquete enquete; @ManyToOne diff --git a/src/main/java/io/gmss/fiscad/entities/rfu/metier/SituationFiscaleParcelle.java b/src/main/java/io/gmss/fiscad/entities/rfu/metier/SituationFiscaleParcelle.java new file mode 100644 index 0000000..11f4ea7 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/entities/rfu/metier/SituationFiscaleParcelle.java @@ -0,0 +1,46 @@ +package io.gmss.fiscad.entities.rfu.metier; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import io.gmss.fiscad.deserializer.LocalDateDeserializer; +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.Exercice; +import io.gmss.fiscad.enums.StatutParcelle; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.Where; + +import java.io.Serializable; +import java.time.LocalDate; + +@EqualsAndHashCode(callSuper = true) +@Entity +@Data +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = " deleted = false") +public class SituationFiscaleParcelle extends BaseEntity implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @ManyToOne + private Parcelle parcelle ; + @JsonFormat(pattern = "yyyy-MM-dd") + @JsonDeserialize(using = LocalDateDeserializer.class) + private LocalDate dateDernierPaiement; + @ManyToOne + private Exercice exercice ; + private Long montantDu ; + private Long montantPaye ; + private Long resteAPayer ; + private StatutParcelle etatFiscalParcelle ; + @JsonFormat(pattern = "yyyy-MM-dd") + @JsonDeserialize(using = LocalDateDeserializer.class) + private LocalDate dateSync; +} diff --git a/src/main/java/io/gmss/fiscad/entities/user/Fonction.java b/src/main/java/io/gmss/fiscad/entities/user/Fonction.java index 5f70158..76a5324 100644 --- a/src/main/java/io/gmss/fiscad/entities/user/Fonction.java +++ b/src/main/java/io/gmss/fiscad/entities/user/Fonction.java @@ -32,10 +32,17 @@ import java.time.LocalDate; // "SET deleted = true " + // "WHERE id = ?") //@Where(clause = " deleted = false") +@Table( + name = "fonction", + uniqueConstraints = { + @UniqueConstraint(columnNames = {"code"}) + } +) public class Fonction extends BaseEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(nullable = false, unique = true) private String code ; private String nom ; diff --git a/src/main/java/io/gmss/fiscad/enums/ParametersType.java b/src/main/java/io/gmss/fiscad/enums/ParametersType.java new file mode 100755 index 0000000..5ae184a --- /dev/null +++ b/src/main/java/io/gmss/fiscad/enums/ParametersType.java @@ -0,0 +1,15 @@ +package io.gmss.fiscad.enums; + +public enum ParametersType { + EMAILS_TO, + EMAIL_FROM, + SMTP_PORT, + SMTP_HOST, + SMTP_USERNAME, + SMTP_PASSWORD, + MESSAGE_STATUT, + OBJET_RESET_PASSWORD, + CORPS_RESET_PASSWORD, + OBJET_CREATE_ACCOUNT, + CORPS_CREATE_ACCOUNT; +} diff --git a/src/main/java/io/gmss/fiscad/enums/StatutParcelle.java b/src/main/java/io/gmss/fiscad/enums/StatutParcelle.java index e0348e6..21a967b 100644 --- a/src/main/java/io/gmss/fiscad/enums/StatutParcelle.java +++ b/src/main/java/io/gmss/fiscad/enums/StatutParcelle.java @@ -1,9 +1,10 @@ package io.gmss.fiscad.enums; public enum StatutParcelle { - NON_ENQUETER, - ENQUETER_NON_BATIE, - ENQUETER_BATIE + ENQUETER_NON_BATIE_AJOUR, + ENQUETER_BATIE_AJOUR, + ENQUETER_NON_BATIE_NON_AJOUR, + ENQUETER_BATIE_NON_AJOUR } diff --git a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java index cfe883d..a077139 100644 --- a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/EnqueteServiceImpl.java @@ -117,7 +117,7 @@ public class EnqueteServiceImpl implements EnqueteService { } } - Optional optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId()); + //Optional optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId()); ///enregistrement de la pacelle try { @@ -144,7 +144,7 @@ public class EnqueteServiceImpl implements EnqueteService { enquete.setAutreAdresse(enquetePayLoadWeb.getAutreAdresse()); enquete.setAutreNumeroTitreFoncier(enquetePayLoadWeb.getAutreNumeroTitreFoncier()); enquete.setNumeroTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier()); - enquete.setEquipe(optionalEquipe.orElse(null)); + //enquete.setEquipe(optionalEquipe.orElse(null)); enquete.setDateDebutExcemption(enquetePayLoadWeb.getDateDebutExemption()); enquete.setDateFinExcemption(enquetePayLoadWeb.getDateFinExemption()); enquete.setNbreBatiment(enquetePayLoadWeb.getNbreBatiment()); @@ -232,7 +232,7 @@ public class EnqueteServiceImpl implements EnqueteService { enquetePayLoadWeb.getParcellePayLoadWeb().setRueId(rueId); } - Optional optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId()); + //Optional optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId()); ///enregistrement de la pacelle try { @@ -258,7 +258,7 @@ public class EnqueteServiceImpl implements EnqueteService { enquete.setAutreAdresse(enquetePayLoadWeb.getAutreAdresse()); enquete.setAutreNumeroTitreFoncier(enquetePayLoadWeb.getAutreNumeroTitreFoncier()); enquete.setNumeroTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier()); - enquete.setEquipe(optionalEquipe.orElse(null)); + // enquete.setEquipe(optionalEquipe.orElse(null)); enquete.setDateDebutExcemption(enquetePayLoadWeb.getDateDebutExemption()); enquete.setDateFinExcemption(enquetePayLoadWeb.getDateFinExemption()); enquete.setNbreBatiment(enquetePayLoadWeb.getNbreBatiment()); @@ -599,13 +599,13 @@ public class EnqueteServiceImpl implements EnqueteService { List caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId); - List enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId); + //List enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId); - List enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId); + // List enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId); ficheEnquetesResponse.setCaracteristiquesParcelles(caracteristiqueParcelles); - ficheEnquetesResponse.setEnquetesBatiments(enqueteBatiments); - ficheEnquetesResponse.setEnquetesUniteLogements(enqueteUniteLogements); + // ficheEnquetesResponse.setEnquetesBatiments(enqueteBatiments); + // ficheEnquetesResponse.setEnquetesUniteLogements(enqueteUniteLogements); ficheEnqueteResponse.setEnquete(ficheEnquetesResponse); ficheEnqueteResponse.setActeurConcernes(acteurConcernes); diff --git a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleServiceImpl.java index 3457216..6efa000 100644 --- a/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/infocad/metier/ParcelleServiceImpl.java @@ -117,6 +117,50 @@ public class ParcelleServiceImpl implements ParcelleService { return parcelleRepository.findAll(); } + @Override + public Optional getParcelleByIdToDto(Long userId, Long parcelleId) { + List secteurIds = getSecteurIdListForUser(userId); + return parcelleRepository.findParcelleToDtoById(secteurIds,parcelleId); + } + + @Override + public List getParcelleListToDto(Long userId) { + List secteurIds = getSecteurIdListForUser(userId); + return parcelleRepository.findAllParcelleToDto(secteurIds); + } + + @Override + public Page getParcelleListPageableToDto(Long userId, Pageable pageable) { + List secteurIds = getSecteurIdListForUser(userId); + return parcelleRepository.findAllParcelleToDtoPageable(secteurIds,pageable); + } + + @Override + public List getParcelleListByQuartierToDto(Long userId, Long quartierId) { + List secteurIds = getSecteurIdListForUser(userId); + return parcelleRepository.findAllParcelleByQuartierToDto(quartierId,secteurIds); + } + + @Override + public Page getParcelleListByQuartierPageableToDto(Long userId, Long quartierId, Pageable pageable) { + List secteurIds = getSecteurIdListForUser(userId); + return parcelleRepository.findAllParcelleByQuartierToDtoPageable(quartierId,secteurIds,pageable); + } + + @Override + public List getParcelleListByRueToDto(Long userId, Long rueId) { + List secteurIds = getSecteurIdListForUser(userId); + return parcelleRepository.findAllParcelleByRueToDto(rueId,secteurIds); + } + + @Override + public Page getParcelleListByRuePageableToDto(Long userId, Long rueId, Pageable pageable) { + List secteurIds = getSecteurIdListForUser(userId); + + return parcelleRepository.findAllParcelleByRueToDtoPageable(rueId,secteurIds,pageable); + } + + @Override public Optional getParcelleById(Long id) { if (parcelleRepository.existsById(id)) { @@ -128,22 +172,23 @@ public class ParcelleServiceImpl implements ParcelleService { @Override public Page getParcelleDataTableListByUserId(Long userId, Pageable pageable) { - - List secteurs = secteurService.getListSecteurUserId(userId); - List secteurIds = secteurs.stream() - .map(Secteur::getId) - .toList(); + List secteurIds = getSecteurIdListForUser(userId); Page parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable); return parcelleDataTableResponses ; } - @Override - public Page getParcelleDataTableListByMultiFiltre(Long userId, FiltreParcellePayLoad filtreParcellePayLoad, Pageable pageable) { + private List getSecteurIdListForUser(Long userId) { List secteurs = secteurService.getListSecteurUserId(userId); List secteurIds = secteurs.stream() .map(Secteur::getId) .toList(); + return secteurIds; + } + + @Override + public Page getParcelleDataTableListByMultiFiltre(Long userId, FiltreParcellePayLoad filtreParcellePayLoad, Pageable pageable) { + List secteurIds = getSecteurIdListForUser(userId); // // return parcelleRepository.findAll( // ParcelleSpecification.filtre(filtreParcellePayLoad, secteurIds), diff --git a/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteBatimentServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteBatimentServiceImpl.java index 7a8ce34..93d7bab 100644 --- a/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteBatimentServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteBatimentServiceImpl.java @@ -42,24 +42,24 @@ public class EnqueteBatimentServiceImpl implements EnqueteBatimentService { public EnqueteBatiment createEnqueteBatiment(EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) throws BadRequestException { EnqueteBatiment enqueteBatiment=new EnqueteBatiment(); Batiment batiment=new Batiment(); - Enquete enquete=new Enquete(); + //Enquete enquete=new Enquete(); if(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb().getId()==null){ batiment= batimentService.createBatiment(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb());//entityFromPayLoadService.getBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb())); }else{ batiment= batimentService.updateBatiment(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb().getId(),enqueteBatimentPayloadWeb.getBatimentPaylaodWeb());//entityFromPayLoadService.getBatimentFromPayLoadWeb(enqueteBatimentPayloadWeb.getBatimentPaylaodWeb())); } - if(enqueteBatimentPayloadWeb.getEnqueteId()==null){ - throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); - } +// if(enqueteBatimentPayloadWeb.getEnqueteId()==null){ +// throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); +// } Optional optionalPersonne=Optional.empty(); if(enqueteBatimentPayloadWeb.getPersonneId()!=null){ optionalPersonne=personneRepository.findById(enqueteBatimentPayloadWeb.getPersonneId()); } - Optional optionalEnquete = enqueteRepository.findById(enqueteBatimentPayloadWeb.getEnqueteId()); - enqueteBatiment.setEnquete(optionalEnquete.orElse(null)); + //Optional optionalEnquete = enqueteRepository.findById(enqueteBatimentPayloadWeb.getEnqueteId()); + //enqueteBatiment.setEnquete(optionalEnquete.orElse(null)); enqueteBatiment.setBatiment(batiment); enqueteBatiment.setPersonne(optionalPersonne.orElse(null)); enqueteBatiment.setAutreCaracteristiquePhysique(enqueteBatimentPayloadWeb.getAutreCaracteristiquePhysique()); @@ -95,7 +95,7 @@ public class EnqueteBatimentServiceImpl implements EnqueteBatimentService { EnqueteBatiment finalEnqueteBatiment = enqueteBatiment; enqueteBatimentPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> { - optionalEnquete.ifPresent(value -> uploadPayLoadWeb.setEnqueteId(value.getId())); + //optionalEnquete.ifPresent(value -> uploadPayLoadWeb.setEnqueteId(value.getId())); Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb); upload.setEnqueteBatiment(finalEnqueteBatiment); uploadRepository.save(upload); @@ -112,10 +112,10 @@ public class EnqueteBatimentServiceImpl implements EnqueteBatimentService { if (!enqueteBatimentRepository.existsById(enqueteBatimentPayloadWeb.getId())) { throw new NotFoundException("Impossible de trouver la nouvelle enquete de batiment spécifiée dans notre base de données."); } - if(enqueteBatimentPayloadWeb.getEnqueteId()==null){ - throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); - } - Optional optionalEnquete = enqueteRepository.findById(enqueteBatimentPayloadWeb.getEnqueteId()); +// if(enqueteBatimentPayloadWeb.getEnqueteId()==null){ +// throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); +// } + // Optional optionalEnquete = enqueteRepository.findById(enqueteBatimentPayloadWeb.getEnqueteId()); EnqueteBatiment enqueteBatiment=new EnqueteBatiment(); Batiment batiment=new Batiment(); @@ -131,7 +131,7 @@ public class EnqueteBatimentServiceImpl implements EnqueteBatimentService { if(enqueteBatimentPayloadWeb.getPersonneId()!=null){ optionalPersonne=personneRepository.findById(enqueteBatimentPayloadWeb.getPersonneId()); } - enqueteBatiment.setEnquete(optionalEnquete.orElse(null)); + //enqueteBatiment.setEnquete(optionalEnquete.orElse(null)); enqueteBatiment.setBatiment(batiment); enqueteBatiment.setPersonne(optionalPersonne.orElse(null)); enqueteBatiment.setAutreCaracteristiquePhysique(enqueteBatimentPayloadWeb.getAutreCaracteristiquePhysique()); diff --git a/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteUniteLogementServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteUniteLogementServiceImpl.java index 0d30470..4dc67c2 100644 --- a/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteUniteLogementServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/rfu/metier/EnqueteUniteLogementServiceImpl.java @@ -47,9 +47,9 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ uniteLogement = uniteLogementService.updateUniteLogement(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb().getId(),entityFromPayLoadService.getUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb())); } - if(enqueteUniteLogementPayloadWeb.getEnqueteId()==null){ - throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); - } +// if(enqueteUniteLogementPayloadWeb.getEnqueteId()==null){ +// throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); +// } Optional optionalPersonne=Optional.empty(); if(enqueteUniteLogementPayloadWeb.getPersonneId()!=null){ @@ -57,8 +57,8 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ } - Optional optionalEnquete = enqueteRepository.findById(enqueteUniteLogementPayloadWeb.getEnqueteId()); - enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null)); + //Optional optionalEnquete = enqueteRepository.findById(enqueteUniteLogementPayloadWeb.getEnqueteId()); + // enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null)); enqueteUniteLogement.setUniteLogement(uniteLogement); enqueteUniteLogement.setPersonne(optionalPersonne.orElse(null)); enqueteUniteLogement.setEnLocation(enqueteUniteLogementPayloadWeb.isEnLocation()); @@ -90,7 +90,7 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ ///////Enregistrement des pieces EnqueteUniteLogement finalEnqueteUniteLogement = enqueteUniteLogement; enqueteUniteLogementPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> { - optionalEnquete.ifPresent(value -> uploadPayLoadWeb.setEnqueteId(value.getId())); + //optionalEnquete.ifPresent(value -> uploadPayLoadWeb.setEnqueteId(value.getId())); Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb); upload.setEnqueteUniteLogement(finalEnqueteUniteLogement); uploadRepository.save(upload); @@ -117,17 +117,17 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ uniteLogement = uniteLogementService.updateUniteLogement(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb().getId(),entityFromPayLoadService.getUniteLogementFromPayLoadWeb(enqueteUniteLogementPayloadWeb.getUniteLogementPaylaodWeb())); } - if(enqueteUniteLogementPayloadWeb.getEnqueteId()==null){ - throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); - } +// if(enqueteUniteLogementPayloadWeb.getEnqueteId()==null){ +// throw new BadRequestException("Impossible de poursuivre l'enregistrement sans la précision de l'enquête"); +// } Optional optionalPersonne=Optional.empty(); if(enqueteUniteLogementPayloadWeb.getPersonneId()!=null){ optionalPersonne=personneRepository.findById(enqueteUniteLogementPayloadWeb.getPersonneId()); } - Optional optionalEnquete = enqueteRepository.findById(enqueteUniteLogementPayloadWeb.getEnqueteId()); + // Optional optionalEnquete = enqueteRepository.findById(enqueteUniteLogementPayloadWeb.getEnqueteId()); - enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null)); + // enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null)); enqueteUniteLogement.setUniteLogement(uniteLogement); enqueteUniteLogement.setPersonne(optionalPersonne.orElse(null)); enqueteUniteLogement.setEnLocation(enqueteUniteLogementPayloadWeb.isEnLocation()); diff --git a/src/main/java/io/gmss/fiscad/implementations/user/DemandeReinitialisationMPServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/user/DemandeReinitialisationMPServiceImpl.java index 559c355..f30d51e 100644 --- a/src/main/java/io/gmss/fiscad/implementations/user/DemandeReinitialisationMPServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/user/DemandeReinitialisationMPServiceImpl.java @@ -95,7 +95,7 @@ public class DemandeReinitialisationMPServiceImpl implements DemandeReinitialisa if (demandeReinitialisationMPOptional.isPresent()) { DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPOptional.get(); User user = demandeReinitialisationMP.getUser(); - userService.resetPassword(user.getUsername(), password); + userService.resetPassword(user.getUsername()); demandeReinitialisationMP.setEtatDemande(EtatDemande.TRAITE); return demandeReinitialisationMPRepository.save(demandeReinitialisationMP); } else { diff --git a/src/main/java/io/gmss/fiscad/implementations/user/UserServiceImpl.java b/src/main/java/io/gmss/fiscad/implementations/user/UserServiceImpl.java index 4418aed..0aa8ce9 100644 --- a/src/main/java/io/gmss/fiscad/implementations/user/UserServiceImpl.java +++ b/src/main/java/io/gmss/fiscad/implementations/user/UserServiceImpl.java @@ -16,6 +16,8 @@ import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb; import io.gmss.fiscad.persistence.repositories.user.UserRepository; import io.gmss.fiscad.security.TokenAuthentificationProvider; import io.gmss.fiscad.service.EntityFromPayLoadService; +import io.gmss.fiscad.service.MailService; +import io.gmss.fiscad.service.StringService; import lombok.AllArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -40,6 +42,8 @@ public class UserServiceImpl implements UserService { private final TokenAuthentificationProvider tokenAuthentificationProvider; private final StructureService structureService; private final EntityFromPayLoadService entityFromPayLoadService; + private final StringService stringService ; + private final MailService mailService ; @@ -195,27 +199,33 @@ public class UserServiceImpl implements UserService { } @Override - public User activateOrNotUser(Long id) { + public User activateUser(Long id) { User user = getUserById(id); - if (user.isActive()) { - user.setActive(false); - } - - if (!user.isActive()) { user.setActive(true); - } return userRepository.save(user); } @Override - public UserPaylaodWeb resetPassword(String username, String password) { + public User disactivateUser(Long id) { + User user = getUserById(id); + + user.setActive(false); + + + return userRepository.save(user); + } + + @Override + public UserPaylaodWeb resetPassword(String username) { User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException( String.format("L'utilisateur %s n'existe pas.", username) )); + String password = stringService.generatePassword(); user.setPassword(passwordEncoder.encode(password)); user.setResetPassword(true); - user= userRepository.save(user); - Optional optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId()); + user= userRepository.save(user); + mailService.sendAccountReinitMail(user,password); + Optional optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId()); return optionalUserPaylaodWeb.orElse(null); } diff --git a/src/main/java/io/gmss/fiscad/interfaces/ParametersRepository.java b/src/main/java/io/gmss/fiscad/interfaces/ParametersRepository.java new file mode 100755 index 0000000..a7b2fd4 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/interfaces/ParametersRepository.java @@ -0,0 +1,15 @@ +package io.gmss.fiscad.interfaces; + + +import io.gmss.fiscad.entities.Parameters; +import io.gmss.fiscad.enums.ParametersType; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; +import java.util.Optional; + +public interface ParametersRepository extends JpaRepository { + Optional findFirstByName(ParametersType param); + Optional findTopByName(ParametersType param); + List findAllByName(ParametersType param); +} diff --git a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleService.java b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleService.java index d2c413b..d518b81 100755 --- a/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleService.java +++ b/src/main/java/io/gmss/fiscad/interfaces/infocad/metier/ParcelleService.java @@ -21,12 +21,20 @@ public interface ParcelleService { Parcelle updateParcelle(Long id,ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException; void deleteParcelle(Long id) throws NotFoundException; - - Page getParcelleList(Pageable pageable); - - List getParcelleList(); - Optional getParcelleById(Long id); + Page getParcelleList(Pageable pageable); + List getParcelleList(); + Optional getParcelleByIdToDto(Long UserId,Long parcelleId); + List getParcelleListToDto(Long userId); + Page getParcelleListPageableToDto(Long userId,Pageable pageable); + List getParcelleListByQuartierToDto(Long userId,Long quartierId); + Page getParcelleListByQuartierPageableToDto(Long userId,Long quartierId,Pageable pageable); + + List getParcelleListByRueToDto(Long userId,Long rueId); + Page getParcelleListByRuePageableToDto(Long userId,Long rueId,Pageable pageable); + + + Page getParcelleDataTableListByUserId(Long userId, Pageable pageable); Page getParcelleDataTableListByMultiFiltre(Long userId, FiltreParcellePayLoad filtreParcellePayLoad, Pageable pageable); diff --git a/src/main/java/io/gmss/fiscad/interfaces/user/UserService.java b/src/main/java/io/gmss/fiscad/interfaces/user/UserService.java index d349091..a2d3c84 100755 --- a/src/main/java/io/gmss/fiscad/interfaces/user/UserService.java +++ b/src/main/java/io/gmss/fiscad/interfaces/user/UserService.java @@ -43,9 +43,9 @@ public interface UserService { User getUserByUsername(String username); - User activateOrNotUser(Long id); - - UserPaylaodWeb resetPassword(String username, String password); + User activateUser(Long id); + User disactivateUser(Long id); + UserPaylaodWeb resetPassword(String username); User validateUserAccount(String username); diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/AvoirFonctionPaylaodWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/AvoirFonctionPaylaodWeb.java index 314b58d..6cbb007 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/AvoirFonctionPaylaodWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/AvoirFonctionPaylaodWeb.java @@ -13,10 +13,10 @@ import java.time.LocalDate; @Data public class AvoirFonctionPaylaodWeb { private Long id; - @JsonFormat(pattern = "dd-MM-yyyy") + @JsonFormat(pattern = "yyyy-MM-dd") @JsonDeserialize(using = LocalDateDeserializer.class) private LocalDate dateDebut; - @JsonFormat(pattern = "dd-MM-yyyy") + @JsonFormat(pattern = "yyyy-MM-dd") @JsonDeserialize(using = LocalDateDeserializer.class) private LocalDate dateFin; private Long fonctionId; @@ -27,7 +27,7 @@ public class AvoirFonctionPaylaodWeb { private String userNom ; private String userPrenom ; private String email ; - //@Enumerated(EnumType.STRING) + @Enumerated(EnumType.STRING) private Titre titre; public AvoirFonctionPaylaodWeb( 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 9c6f39b..d8b96d4 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 @@ -28,14 +28,55 @@ public class EnqueteBatimentPayloadWeb { private Long montantMensuelLocation; private Long montantLocatifAnnuelDeclare; private Long nbreEtage; - private Long valeurBatimentEstime; private Long valeurBatimentReel; private int nbreMoisLocation; private String autreCaracteristiquePhysique; private LocalDate dateDebutExcemption; private LocalDate dateFinExcemption; - private Long enqueteId; + // private Long enqueteId; + private Long batimentId; + private Long batimentNub; private Long personneId; - private Long EnqueteurId; + private String personneNom; + private String personnePrenom; + private String personneRaisonSociale; + private Long enqueteurId; + private String enqueteurNom; + private String enqueteurPrenom; + + public EnqueteBatimentPayloadWeb(Long id, String observation, float surfaceAuSol, String autreMenuisierie, String autreMur, boolean sbee, String numCompteurSbee, boolean soneb, String numCompteurSoneb, int nbreLotUnite, int nbreUniteLocation, float surfaceLouee, int nbreMenage, int nbreHabitant, Long montantMensuelLocation, Long montantLocatifAnnuelDeclare, Long nbreEtage, Long valeurBatimentEstime, Long valeurBatimentReel, int nbreMoisLocation, String autreCaracteristiquePhysique, LocalDate dateDebutExcemption, LocalDate dateFinExcemption, Long batimentId, Long batimentNub, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom) { + this.id = id; + this.observation = observation; + this.surfaceAuSol = surfaceAuSol; + this.autreMenuisierie = autreMenuisierie; + this.autreMur = autreMur; + this.sbee = sbee; + this.numCompteurSbee = numCompteurSbee; + this.soneb = soneb; + this.numCompteurSoneb = numCompteurSoneb; + this.nbreLotUnite = nbreLotUnite; + this.nbreUniteLocation = nbreUniteLocation; + this.surfaceLouee = surfaceLouee; + this.nbreMenage = nbreMenage; + this.nbreHabitant = nbreHabitant; + this.montantMensuelLocation = montantMensuelLocation; + this.montantLocatifAnnuelDeclare = montantLocatifAnnuelDeclare; + this.nbreEtage = nbreEtage; + this.valeurBatimentEstime = valeurBatimentEstime; + this.valeurBatimentReel = valeurBatimentReel; + this.nbreMoisLocation = nbreMoisLocation; + this.autreCaracteristiquePhysique = autreCaracteristiquePhysique; + this.dateDebutExcemption = dateDebutExcemption; + this.dateFinExcemption = dateFinExcemption; + this.batimentId = batimentId; + this.batimentNub = batimentNub; + this.personneId = personneId; + this.personneNom = personneNom; + this.personnePrenom = personnePrenom; + this.personneRaisonSociale = personneRaisonSociale; + this.enqueteurId = enqueteurId; + this.enqueteurNom = enqueteurNom; + this.enqueteurPrenom = enqueteurPrenom; + } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java index be7258c..bd49531 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/EnquetePayLoadWeb.java @@ -37,12 +37,72 @@ public class EnquetePayLoadWeb { private LocalDate dateDebutExemption; private LocalDate dateFinExemption; private String autreNumeroTitreFoncier; - private Long EquipeId; - private Long zoneRfuId; - private Long proprietaireId; - private Long EnqueteurId; private Long montantMensuelleLocation; private Long montantAnnuelleLocation; private Long valeurParcelleEstime; private Long valeurParcelleReel; + // private Long equipeId; + private Long zoneRfuId; + private String zoneRfuNom; + private Long proprietaireId; + private String proprietaireNom; + private String proprietairePrenom; + private String proprietaireRaisonSociale; + private Long enqueteurId; + private String enqueteurNom; + private String enqueteurPrenom; + private Long secteurId; + private String secteurCode; + private String secteurNom; + private Long parcelleId; + private String parcelleNup; + private String parcelleQ; + private String parcelleI; + private String parcelleP; + + public EnquetePayLoadWeb(Long id, LocalDate dateEnquete, LocalDate dateFinalisation, boolean litige, StatutEnquete statutEnquete, String descriptionMotifRejet, String observation, String numeroTitreFoncier, LocalDate dateTitreFoncier, String numEntreeParcelle, String numRue, String nomRue, float precision, int nbreCoProprietaire, int nbreIndivisiaire, String autreAdresse, float superficie, int nbreBatiment, int nbrePiscine, LocalDate dateDebutExemption, LocalDate dateFinExemption, String autreNumeroTitreFoncier, Long montantMensuelleLocation, Long montantAnnuelleLocation, Long valeurParcelleEstime, Long valeurParcelleReel, Long zoneRfuId, String zoneRfuNom, Long proprietaireId, String proprietaireNom, String proprietairePrenom, String proprietaireRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom, Long secteurId, String secteurCode, String secteurNom + ,Long parcelleId,String parcelleNup,String parcelleQ,String parcelleI,String parcelleP) { + this.id = id; + this.dateEnquete = dateEnquete; + this.dateFinalisation = dateFinalisation; + this.litige = litige; + this.statutEnquete = statutEnquete; + this.descriptionMotifRejet = descriptionMotifRejet; + this.observation = observation; + this.numeroTitreFoncier = numeroTitreFoncier; + this.dateTitreFoncier = dateTitreFoncier; + this.numEntreeParcelle = numEntreeParcelle; + this.numRue = numRue; + this.nomRue = nomRue; + this.precision = precision; + this.nbreCoProprietaire = nbreCoProprietaire; + this.nbreIndivisiaire = nbreIndivisiaire; + this.autreAdresse = autreAdresse; + this.superficie = superficie; + this.nbreBatiment = nbreBatiment; + this.nbrePiscine = nbrePiscine; + this.dateDebutExemption = dateDebutExemption; + this.dateFinExemption = dateFinExemption; + this.autreNumeroTitreFoncier = autreNumeroTitreFoncier; + this.montantMensuelleLocation = montantMensuelleLocation; + this.montantAnnuelleLocation = montantAnnuelleLocation; + this.valeurParcelleEstime = valeurParcelleEstime; + this.valeurParcelleReel = valeurParcelleReel; + this.zoneRfuId = zoneRfuId; + this.zoneRfuNom = zoneRfuNom; + this.proprietaireId = proprietaireId; + this.proprietaireNom = proprietaireNom; + this.proprietairePrenom = proprietairePrenom; + this.proprietaireRaisonSociale = proprietaireRaisonSociale; + this.enqueteurId = enqueteurId; + this.enqueteurNom = enqueteurNom; + this.enqueteurPrenom = enqueteurPrenom; + this.secteurId = secteurId; + this.secteurCode = secteurCode; + this.parcelleId = parcelleId; + this.parcelleNup = parcelleNup; + this.parcelleQ = parcelleQ; + this.parcelleI = parcelleI; + this.parcelleP = parcelleP; + } } 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 9d77942..336c1da 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 @@ -31,8 +31,49 @@ public class EnqueteUniteLogementPayloadWeb { private String numCompteurSoneb; private LocalDate dateDebutExcemption; private LocalDate dateFinExcemption; - private Long enqueteId; + //private Long enqueteId; private Long uniteLogementId; + private String uniteLogementNumeroEtage; + private String uniteLogementNul; private Long personneId; + private String personneNom; + private String personnePrenom; + private String personneRaisonSociale; + private Long enqueteurId; + private String enqueteurNom; + private String enqueteurPrenom; + public EnqueteUniteLogementPayloadWeb(Long id, String observation, Long userId, float surface, int nbrePiece, int nbreHabitant, int nbreMenage, boolean enLocation, int nbreMoisLocation, Long montantMensuelLoyer, Long montantLocatifAnnuelDeclare, Long valeurUniteLogementEstime, Long valeurUniteLogementReel, float surfaceAuSol, float surfaceLouee, boolean sbee, boolean soneb, String numCompteurSbee, String numCompteurSoneb, LocalDate dateDebutExcemption, LocalDate dateFinExcemption, Long uniteLogementId, String uniteLogementNumeroEtage, String uniteLogementNul, Long personneId, String personneNom, String personnePrenom, String personneRaisonSociale, Long enqueteurId, String enqueteurNom, String enqueteurPrenom) { + this.id = id; + this.observation = observation; + this.userId = userId; + this.surface = surface; + this.nbrePiece = nbrePiece; + this.nbreHabitant = nbreHabitant; + this.nbreMenage = nbreMenage; + this.enLocation = enLocation; + this.nbreMoisLocation = nbreMoisLocation; + this.montantMensuelLoyer = montantMensuelLoyer; + this.montantLocatifAnnuelDeclare = montantLocatifAnnuelDeclare; + this.valeurUniteLogementEstime = valeurUniteLogementEstime; + this.valeurUniteLogementReel = valeurUniteLogementReel; + SurfaceAuSol = surfaceAuSol; + this.surfaceLouee = surfaceLouee; + this.sbee = sbee; + this.soneb = soneb; + this.numCompteurSbee = numCompteurSbee; + this.numCompteurSoneb = numCompteurSoneb; + this.dateDebutExcemption = dateDebutExcemption; + this.dateFinExcemption = dateFinExcemption; + this.uniteLogementId = uniteLogementId; + this.uniteLogementNumeroEtage = uniteLogementNumeroEtage; + this.uniteLogementNul = uniteLogementNul; + this.personneId = personneId; + this.personneNom = personneNom; + this.personnePrenom = personnePrenom; + this.personneRaisonSociale = personneRaisonSociale; + this.enqueteurId = enqueteurId; + this.enqueteurNom = enqueteurNom; + this.enqueteurPrenom = enqueteurPrenom; + } } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/ParcellePayLoadWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/ParcellePayLoadWeb.java index 6bf3ac7..f368763 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/ParcellePayLoadWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/ParcellePayLoadWeb.java @@ -14,14 +14,85 @@ public class ParcellePayLoadWeb { private String longitude; private String latitude; private String altitude; - private String emplacement; - private Long situationGeographiqueId; - private Long natureDomaineId; - private Long quartierId; private Float superficie; private String observation; - private Long typeDomaineId; private String situationGeographique; - private Long rueId; private String numEntreeParcelle; + private Long quartierId; + private String quartierCode; + private String quartierNom; + private Long natureDomaineId; + private String natureDomaineLibelle; + private Long typeDomaineId; + private String typeDomaineLibelle; + private Long rueId; + private String rueNumero; + private String rueNom; + private Long proprietaireId; + private String proprietaireIfu; + private String proprietaireNpi; + private String proprietaireNom; + private String proprietairePrenom; + private String proprietaireRaisonSociale; + + + public ParcellePayLoadWeb(Long id, String q, String i, String p, String nup, String nupProvisoire, String numTitreFoncier, String longitude, String latitude, String altitude, Float superficie, String observation, String situationGeographique, String numEntreeParcelle, Long quartierId, String quartierCode, String quartierNom, Long natureDomaineId, String natureDomaineLibelle, Long typeDomaineId, String typeDomaineLibelle, Long rueId, String rueNumero, String rueNom) { + this.id = id; + this.q = q; + this.i = i; + this.p = p; + this.nup = nup; + this.nupProvisoire = nupProvisoire; + this.numTitreFoncier = numTitreFoncier; + this.longitude = longitude; + this.latitude = latitude; + this.altitude = altitude; + this.superficie = superficie; + this.observation = observation; + this.situationGeographique = situationGeographique; + this.numEntreeParcelle = numEntreeParcelle; + this.quartierId = quartierId; + this.quartierCode = quartierCode; + this.quartierNom = quartierNom; + this.natureDomaineId = natureDomaineId; + this.natureDomaineLibelle = natureDomaineLibelle; + this.typeDomaineId = typeDomaineId; + this.typeDomaineLibelle = typeDomaineLibelle; + this.rueId = rueId; + this.rueNumero = rueNumero; + this.rueNom = rueNom; + } + + public ParcellePayLoadWeb(Long id, String q, String i, String p, String nup, String nupProvisoire, String numTitreFoncier, String longitude, String latitude, String altitude, Float superficie, String observation, String situationGeographique, String numEntreeParcelle, Long quartierId, String quartierCode, String quartierNom, Long natureDomaineId, String natureDomaineLibelle, Long typeDomaineId, String typeDomaineLibelle, Long rueId, String rueNumero, String rueNom, Long proprietaireId, String proprietaireIfu, String proprietaireNpi, String proprietaireNom, String proprietairePrenom, String proprietaireRaisonSociale) { + this.id = id; + this.q = q; + this.i = i; + this.p = p; + this.nup = nup; + this.nupProvisoire = nupProvisoire; + this.numTitreFoncier = numTitreFoncier; + this.longitude = longitude; + this.latitude = latitude; + this.altitude = altitude; + this.superficie = superficie; + this.observation = observation; + this.situationGeographique = situationGeographique; + this.numEntreeParcelle = numEntreeParcelle; + this.quartierId = quartierId; + this.quartierCode = quartierCode; + this.quartierNom = quartierNom; + this.natureDomaineId = natureDomaineId; + this.natureDomaineLibelle = natureDomaineLibelle; + this.typeDomaineId = typeDomaineId; + this.typeDomaineLibelle = typeDomaineLibelle; + this.rueId = rueId; + this.rueNumero = rueNumero; + this.rueNom = rueNom; + this.proprietaireId = proprietaireId; + this.proprietaireIfu = proprietaireIfu; + this.proprietaireNpi = proprietaireNpi; + this.proprietaireNom = proprietaireNom; + this.proprietairePrenom = proprietairePrenom; + this.proprietaireRaisonSociale = proprietaireRaisonSociale; + } } 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 89e7366..7670b97 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 @@ -11,6 +11,8 @@ public class UniteLogementPaylaodWeb { private String numeroEtage; private String code; private Long batimentId; + private String batimentNub; private String observation; private LocalDate dateConstruction; + } diff --git a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UserPaylaodWeb.java b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UserPaylaodWeb.java index f3f1d07..1893cd6 100644 --- a/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UserPaylaodWeb.java +++ b/src/main/java/io/gmss/fiscad/paylaods/request/crudweb/UserPaylaodWeb.java @@ -20,6 +20,8 @@ public class UserPaylaodWeb { private Long structureId; private String structureCode; private String structureNom; + private Boolean actif; + private Boolean resetPassword; public UserPaylaodWeb(Long id, String nom, @@ -29,7 +31,9 @@ public class UserPaylaodWeb { String email, Long structureId, String structureCode, - String structureNom) { + String structureNom, + Boolean actif, + Boolean resetPassword) { this.id = id; this.nom = nom; this.prenom = prenom; @@ -39,5 +43,7 @@ public class UserPaylaodWeb { this.structureId = structureId; this.structureCode = structureCode; this.structureNom = structureNom; + this.actif = actif; + this.resetPassword = resetPassword; } } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/ParcelleRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/ParcelleRepository.java index 1e0e47d..dffa8db 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/ParcelleRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/infocad/metier/ParcelleRepository.java @@ -1,6 +1,7 @@ package io.gmss.fiscad.persistence.repositories.infocad.metier; import io.gmss.fiscad.entities.infocad.metier.Parcelle; +import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb; import io.gmss.fiscad.paylaods.response.dataTableResponse.ParcelleDataTableResponse; import io.gmss.fiscad.paylaods.response.statistique.StatistiqueTypeNombreResponse; import io.gmss.fiscad.paylaods.response.restoration.ParcellePayLoadRestor; @@ -164,5 +165,408 @@ public interface ParcelleRepository extends JpaRepository, JpaSp Pageable pageable ); + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) + """) + List findAllParcelleToDto(@Param("secteurIds") List secteurIds); + + @Query(""" + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) and p.id = :parcelleId +""") + Optional findParcelleToDtoById( + @Param("secteurIds") List secteurIds, + @Param("parcelleId") Long parcelleId + ); + + + @Query( + value = """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) + """, + countQuery = """ + SELECT COUNT(DISTINCT p.id) + FROM Parcelle p + INNER JOIN SecteurDecoupage sd on sd.quartier=p.quartier + WHERE sd.secteur.id IN (:secteurIds) + """ + ) + Page findAllParcelleToDtoPageable(@Param("secteurIds") List secteurIds,Pageable pageable); + + + @Query( + """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) and q.id = :quartierId + """ + ) + List findAllParcelleByQuartierToDto( + @Param("quartierId") Long quartierId,@Param("secteurIds") List secteurIds + ); + + @Query( + value = """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) and q.id = :quartierId + """, + countQuery = """ + SELECT COUNT(DISTINCT p.id) + FROM Parcelle p + LEFT JOIN p.quartier q + INNER JOIN SecteurDecoupage sd on sd.quartier=p.quartier + WHERE sd.secteur.id IN (:secteurIds) and q.id = :quartierId + """ + ) + Page findAllParcelleByQuartierToDtoPageable( + @Param("quartierId") Long quartierId,@Param("secteurIds") List secteurIds, + Pageable pageable + ); + + + + @Query( + """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) and r.id = :rueId + """ + ) + List findAllParcelleByRueToDto( + @Param("rueId") Long rueId,@Param("secteurIds") List secteurIds + ); + + @Query( + value = """ + SELECT new io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb( + p.id, + p.q, + p.i, + p.p, + p.nup, + p.nupProvisoire, + p.numTitreFoncier, + 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 + ) + 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 sd.secteur.id IN (:secteurIds) and r.id = :rueId + """, + countQuery = """ + SELECT COUNT(DISTINCT p.id) + FROM Parcelle p + LEFT JOIN p.rue r + INNER JOIN SecteurDecoupage sd on sd.quartier=p.quartier + WHERE sd.secteur.id IN (:secteurIds) and r.id = :rueId + """ + ) + Page findAllParcelleByRueToDtoPageable( + @Param("rueId") Long rueId, @Param("secteurIds") List secteurIds, + Pageable pageable + ); } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueBatimentRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueBatimentRepository.java index d4da008..7953806 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueBatimentRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueBatimentRepository.java @@ -14,17 +14,17 @@ import java.util.Optional; public interface CaracteristiqueBatimentRepository extends JpaRepository { - @Transactional - @Modifying - void deleteAllByEnqueteBatiment(EnqueteBatiment enqueteBatiment); +// @Transactional +// @Modifying +// void deleteAllByEnqueteBatiment(EnqueteBatiment enqueteBatiment); Optional findByMobileDataId(Long id); - @Modifying - @Transactional - @Query(""" - DELETE FROM CaracteristiqueBatiment cb - WHERE cb.enqueteBatiment.enquete.id = :enqueteId - """) - void deleteByEnqueteId(@Param("enqueteId") Long enqueteId); +// @Modifying +// @Transactional +// @Query(""" +// DELETE FROM CaracteristiqueBatiment cb +// WHERE cb.enqueteBatiment.enquete.id = :enqueteId +// """) +// void deleteByEnqueteId(@Param("enqueteId") Long enqueteId); @Query( diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueUniteLogementRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueUniteLogementRepository.java index 4509957..cbb8bcc 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueUniteLogementRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/CaracteristiqueUniteLogementRepository.java @@ -14,17 +14,17 @@ import java.util.Optional; public interface CaracteristiqueUniteLogementRepository extends JpaRepository { - @Modifying - @Transactional - void deleteAllByEnqueteUniteLogement(EnqueteUniteLogement enqueteUniteLogement); +// @Modifying +// @Transactional +// void deleteAllByEnqueteUniteLogement(EnqueteUniteLogement enqueteUniteLogement); Optional findByMobileDataId(Long id); - @Modifying - @Transactional - @Query(""" - DELETE FROM CaracteristiqueUniteLogement ul - WHERE ul.enqueteUniteLogement.enquete.id = :enqueteId - """) - void deleteByEnqueteId(@Param("enqueteId") Long enqueteId); +// @Modifying +// @Transactional +// @Query(""" +// DELETE FROM CaracteristiqueUniteLogement ul +// WHERE ul.enqueteUniteLogement.enquete.id = :enqueteId +// """) +// void deleteByEnqueteId(@Param("enqueteId") Long enqueteId); @Query(nativeQuery = true, value = "select cul.id as idBackend, " + "cul.external_key as externalKey, " + 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 f9bbddd..49714aa 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 @@ -13,7 +13,7 @@ public interface EnqueteBatimentRepository extends JpaRepository findByMobileDataId(Long id); Optional findFirstByExternalKeyAndTerminal_Id(Long externalKey, Long TerminalId); - List findAllByEnquete_Id(Long enqueteId); + //List findAllByEnquete_Id(Long enqueteId); @Query( nativeQuery = true, @@ -38,17 +38,17 @@ public interface EnqueteBatimentRepository extends JpaRepository getEnqueteBatimentByTerminalId(Long terminalId); - void deleteAllByEnquete_Id(Long idEnquete); + // void deleteAllByEnquete_Id(Long idEnquete); } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteUniteLogementRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteUniteLogementRepository.java index 78009de..fa3b674 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteUniteLogementRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/rfu/metier/EnqueteUniteLogementRepository.java @@ -13,7 +13,7 @@ public interface EnqueteUniteLogementRepository extends JpaRepository findFirstByExternalKeyAndTerminal_Id(Long externalKey, Long TerminalId); Optional findByMobileDataId(Long id); - List findAllByEnquete_Id(Long id); + //List findAllByEnquete_Id(Long id); @Query(nativeQuery = true, value = "select eul.id as idBackend, " + @@ -36,14 +36,14 @@ public interface EnqueteUniteLogementRepository extends JpaRepository getEnqueteUniteLogementByTerminalId(Long terminalId); - void deleteAllByEnquete_id(Long id) ; + // void deleteAllByEnquete_id(Long id) ; } diff --git a/src/main/java/io/gmss/fiscad/persistence/repositories/user/UserRepository.java b/src/main/java/io/gmss/fiscad/persistence/repositories/user/UserRepository.java index 5512982..5045494 100755 --- a/src/main/java/io/gmss/fiscad/persistence/repositories/user/UserRepository.java +++ b/src/main/java/io/gmss/fiscad/persistence/repositories/user/UserRepository.java @@ -36,7 +36,9 @@ public interface UserRepository extends JpaRepository { u.email, st.id, st.code, - st.nom + st.nom, + u.active, + u.resetPassword ) FROM User u LEFT JOIN u.structure st @@ -54,7 +56,9 @@ public interface UserRepository extends JpaRepository { u.email, st.id, st.code, - st.nom + st.nom, + u.active, + u.resetPassword ) FROM User u LEFT JOIN u.structure st @@ -72,7 +76,9 @@ public interface UserRepository extends JpaRepository { u.email, st.id, st.code, - st.nom + st.nom, + u.active, + u.resetPassword ) FROM User u LEFT JOIN u.structure st @@ -91,7 +97,9 @@ public interface UserRepository extends JpaRepository { u.email, st.id, st.code, - st.nom + st.nom, + u.active, + u.resetPassword ) FROM User u LEFT JOIN u.structure st @@ -114,7 +122,9 @@ public interface UserRepository extends JpaRepository { u.email, st.id, st.code, - st.nom + st.nom, + u.active, + u.resetPassword ) FROM User u LEFT JOIN u.structure st @@ -133,7 +143,9 @@ public interface UserRepository extends JpaRepository { u.email, st.id, st.code, - st.nom + st.nom, + u.active, + u.resetPassword ) FROM User u LEFT JOIN u.structure st diff --git a/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java b/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java index 0d45302..36acc14 100644 --- a/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java +++ b/src/main/java/io/gmss/fiscad/service/EntityFromPayLoadService.java @@ -550,7 +550,7 @@ public class EntityFromPayLoadService { user.setNom(userPaylaodWeb.getNom()); user.setPrenom(userPaylaodWeb.getPrenom()); user.setTel(userPaylaodWeb.getTelephone()); - user.setActive(false); + user.setActive(true); user.setResetPassword(true); return user ; } diff --git a/src/main/java/io/gmss/fiscad/service/MailService.java b/src/main/java/io/gmss/fiscad/service/MailService.java new file mode 100755 index 0000000..253cfdc --- /dev/null +++ b/src/main/java/io/gmss/fiscad/service/MailService.java @@ -0,0 +1,435 @@ +package io.gmss.fiscad.service; + + +import io.gmss.fiscad.entities.user.User; +import io.gmss.fiscad.enums.ParametersType; +import io.gmss.fiscad.interfaces.ParametersRepository; +import io.gmss.fiscad.utils.Mail; +import io.gmss.fiscad.utils.MailPostmark; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.io.IOException; + +@Service +public class MailService { + + private static String to; + private static String from; + + @Autowired + Mail mail; + + @Autowired + MailPostmark mailPostmark; + + @Autowired + ParametersRepository parametersRepository; + + // @Value("${}") + // String defaultPassWord; + + @Async + public void sendMail(String to, String subject, String messageContent, String helloName) { + if(to!=null ) { + if (!to.trim().equals("")){ + messageContent = gethtmlMailFormat(subject, messageContent, helloName); + mail.sendMessage(to, subject, messageContent); + } + } + } + + @Async + public void sendMailToKnownRecipients(String subject, String messageContent, String helloName) { + + if(parametersRepository.findFirstByName(ParametersType.EMAILS_TO).isPresent()){ + to = parametersRepository.findFirstByName(ParametersType.EMAILS_TO).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.EMAIL_FROM).isPresent()){ + from = parametersRepository.findFirstByName(ParametersType.EMAIL_FROM).get().getValue(); + } + messageContent = gethtmlMailFormat(subject,messageContent,helloName); + String[] emails = to.trim().split(","); + for(int i=0; i< emails.length; i++){ + // mail.sendMessage(from, emails[i].trim(), subject, messageContent); + } + } + + + /** + * + * @param subject + * @param content + * @param helloName + * @return + */ + private String gethtmlMailFormat( String subject, String content, String helloName){ + + String messageContent= "\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\tPrésidence de la République du Bénin\n" + + "\t\t\n" + + "\t\t\n" + + "\n" + + "\t\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\t mail de la DGI BENIN \n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\n" + + "\t\t
\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t\t\t

"+subject+"

\n" + + "\t\t\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t\t\t"+helloName+"
\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\t\t

"+content+".\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\t\t

\n" + + "\t\t\t\t\t\t\t\t\t\t
\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\t\tPlease remember to protect the environment. Print only if necessary. Recycle the paper. \n N'oubliez pas de protéger la nature. Imprimez cet email seulement si c'est nécessaire et pensez à recycler votre papier.\n" + + "\t\t\t\t\t\t\t\t\t\t\tTelephone : +229 90 19 00 00
\n" + + "\t\t\t\t\t\t\t\t\t\t\tEmail : cdgi@finances.bj\n" + + "\t\t\t\t\t\t\t\t\t\t
\n" + + "\n" + + "\n" + + "\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"Logo\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t
DGI-\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDGI
\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t
Copyright\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t© 2021 -\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDGI.\n" + + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t
Tout droit reserves
\n" + + "\t\t\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\n" + + "\n" + + "\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t\t
    \n" + + "\t\t\t\t\t\t\t\t\t\t
  • \n" + + "\t\t\t\t\t\t\t\t\t\t
  • \n" + + "\t\t\t\t\t\t\t\t\t\t
  • \n" + + "\t\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t
\n" + + "\n" + + "\t\t\t\t
\n" + + "\n" + + "\n" + + "\t\n" + + "\n" + + "\t"; + return messageContent; + + } + + public void sendAccountCreatedMail(User user, String defaultPassWord) { + String subject = "Notification de creation de compte."; + String helloName = "Monsieur / Madame " + user.getNom() + " " + user.getPrenom(); + StringBuilder message = new StringBuilder(); + message.append(".
"); + message.append("Votre login : " + user.getUsername() + "
"); + message.append("Des votre premiere connexion, pensez a modifier votre mot de passe par defaut qui est genere par le systeme.

"); + message.append("Votre mot de passe : " + defaultPassWord + "
"); + + try{ + sendMail(user.getEmail(), subject, message.toString(), helloName); + }catch (Exception e){ + // e.printStackTrace(); + } + + } + + public void sendAccountReinitMail(User user, String passWord) { + String subject = "Notification de réinitialisation de compte."; + String helloName = "Monsieur / Madame " + user.getNom() + " " + user.getPrenom(); + StringBuilder message = new StringBuilder(); + message.append(".
"); + message.append("Votre login : " + user.getUsername() + "
"); + + message.append("Dès votre première connexion, pensez à modifier votre mot de passe par défaut qui est généré par le système.

"); + message.append("Votre mot de passe : " + passWord + "
"); + + try{ + //sendMail(user.getEmail(), subject, message.toString(), helloName); + sendPostmarkMail(user.getEmail(),subject, message.toString(),helloName,null) ; + }catch (Exception e){ + // e.printStackTrace(); + } + + } + + @Async + public Boolean sendPostmarkMail(String to, String subject, String messageContent, String helloName, String fileName) throws IOException { + String from ; + if(parametersRepository.findFirstByName(ParametersType.EMAIL_FROM).isPresent()){ + from = parametersRepository.findFirstByName(ParametersType.EMAIL_FROM).get().getValue(); + messageContent = gethtmlMailFormat(subject,messageContent,helloName); + return mailPostmark.sendMessage(to, subject, messageContent, fileName, from); + } + return false ; + } + +} diff --git a/src/main/java/io/gmss/fiscad/service/StringService.java b/src/main/java/io/gmss/fiscad/service/StringService.java index bb03ff8..10c56a4 100644 --- a/src/main/java/io/gmss/fiscad/service/StringService.java +++ b/src/main/java/io/gmss/fiscad/service/StringService.java @@ -1,5 +1,6 @@ package io.gmss.fiscad.service; +import io.gmss.fiscad.utils.FileNameGenerator; import org.springframework.stereotype.Service; import java.text.DecimalFormat; @@ -30,4 +31,39 @@ public class StringService { NumberFormat formatter = new DecimalFormat("000"); return formatter.format(input); } + public String getAlphaNumericString(int n) + { + // chose a Character random from this String + String AlphaNumericString = "0123456789"; + // create StringBuffer size of AlphaNumericString + StringBuilder sb = new StringBuilder(n); + + for (int i = 0; i < n; i++) { + + // generate a random number between + // 0 to AlphaNumericString variable length + int index + = (int)(AlphaNumericString.length() + * Math.random()); + + // add Character one by one in end of sb + sb.append(AlphaNumericString + .charAt(index)); + } + + return sb.toString(); + } + + + + public String generatePassword() { + String numero = null; + try { + numero = FileNameGenerator.generateString().toUpperCase().substring(0, 6); + return numero; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } diff --git a/src/main/java/io/gmss/fiscad/service/worker/EnqueteAsyncWorker.java b/src/main/java/io/gmss/fiscad/service/worker/EnqueteAsyncWorker.java index 4d92845..a449858 100644 --- a/src/main/java/io/gmss/fiscad/service/worker/EnqueteAsyncWorker.java +++ b/src/main/java/io/gmss/fiscad/service/worker/EnqueteAsyncWorker.java @@ -228,30 +228,30 @@ public class EnqueteAsyncWorker { } catch (Exception e) { } +// +// try { +// caracteristiqueBatimentRepository.deleteByEnqueteId(idEnquete); +// } catch (Exception e) { +// +// } - try { - caracteristiqueBatimentRepository.deleteByEnqueteId(idEnquete); - } catch (Exception e) { +// try { +// caracteristiqueUniteLogementRepository.deleteByEnqueteId(idEnquete); +// } catch (Exception e) { +// +// } - } +// try { +// enqueteBatimentRepository.deleteAllByEnquete_Id(idEnquete); +// } catch (Exception e) { +// +// } - try { - caracteristiqueUniteLogementRepository.deleteByEnqueteId(idEnquete); - } catch (Exception e) { - - } - - try { - enqueteBatimentRepository.deleteAllByEnquete_Id(idEnquete); - } catch (Exception e) { - - } - - try { - enqueteUniteLogementRepository.deleteAllByEnquete_id(idEnquete); - } catch (Exception e) { - - } +// try { +// enqueteUniteLogementRepository.deleteAllByEnquete_id(idEnquete); +// } catch (Exception e) { +// +// } try { uniteLogementRepository.deleteByEnqueteId(idEnquete); diff --git a/src/main/java/io/gmss/fiscad/service/worker/EnqueteBatimentAsyncWorker.java b/src/main/java/io/gmss/fiscad/service/worker/EnqueteBatimentAsyncWorker.java index 6678ab8..e35ec7f 100644 --- a/src/main/java/io/gmss/fiscad/service/worker/EnqueteBatimentAsyncWorker.java +++ b/src/main/java/io/gmss/fiscad/service/worker/EnqueteBatimentAsyncWorker.java @@ -127,10 +127,10 @@ public class EnqueteBatimentAsyncWorker { enqueteBatiment.setBatiment(optionalBatiment.orElse(null)); } - if (enqueteBatimentPayload.getEnqueteId() != null) { - Optional optionalEnquete = enqueteRepository.findFirstByExternalKeyAndTerminal_Id(enqueteBatimentPayload.getEnqueteId(), enqueteBatimentPayload.getTerminalId()); - enqueteBatiment.setEnquete(optionalEnquete.orElse(null)); - } +// if (enqueteBatimentPayload.getEnqueteId() != null) { +// Optional optionalEnquete = enqueteRepository.findFirstByExternalKeyAndTerminal_Id(enqueteBatimentPayload.getEnqueteId(), enqueteBatimentPayload.getTerminalId()); +// enqueteBatiment.setEnquete(optionalEnquete.orElse(null)); +// } if (enqueteBatimentPayload.getTerminalId() != null) { Optional optionalTpe = tpeRepository.findById(enqueteBatimentPayload.getTerminalId()); enqueteBatiment.setTerminal(optionalTpe.orElse(null)); diff --git a/src/main/java/io/gmss/fiscad/service/worker/EnqueteUniteLogementAsyncWorker.java b/src/main/java/io/gmss/fiscad/service/worker/EnqueteUniteLogementAsyncWorker.java index b4cd5b6..699f0cb 100644 --- a/src/main/java/io/gmss/fiscad/service/worker/EnqueteUniteLogementAsyncWorker.java +++ b/src/main/java/io/gmss/fiscad/service/worker/EnqueteUniteLogementAsyncWorker.java @@ -106,10 +106,10 @@ public class EnqueteUniteLogementAsyncWorker { enqueteUniteLogement.setUniteLogement(optionalUniteLogement.orElse(null)); } - if (enqueteUniteLogementPayload.getEnqueteId() != null) { - Optional optionalEnquete = enqueteRepository.findFirstByExternalKeyAndTerminal_Id(enqueteUniteLogementPayload.getEnqueteId(), enqueteUniteLogementPayload.getTerminalId()); - enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null)); - } +// if (enqueteUniteLogementPayload.getEnqueteId() != null) { +// Optional optionalEnquete = enqueteRepository.findFirstByExternalKeyAndTerminal_Id(enqueteUniteLogementPayload.getEnqueteId(), enqueteUniteLogementPayload.getTerminalId()); +// enqueteUniteLogement.setEnquete(optionalEnquete.orElse(null)); +// } if (enqueteUniteLogementPayload.getTerminalId() != null) { Optional optionalTpe = tpeRepository.findById(enqueteUniteLogementPayload.getTerminalId()); enqueteUniteLogement.setTerminal(optionalTpe.orElse(null)); diff --git a/src/main/java/io/gmss/fiscad/service/worker/ParcelleAsyncWorker.java b/src/main/java/io/gmss/fiscad/service/worker/ParcelleAsyncWorker.java index 109b5d3..3cc64b4 100644 --- a/src/main/java/io/gmss/fiscad/service/worker/ParcelleAsyncWorker.java +++ b/src/main/java/io/gmss/fiscad/service/worker/ParcelleAsyncWorker.java @@ -4,6 +4,7 @@ import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; +import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine; import io.gmss.fiscad.entities.metadata.MobileDataParcelle; import io.gmss.fiscad.enums.TypeObjet; import io.gmss.fiscad.paylaods.request.synchronisation.ParcellePayLoad; @@ -11,6 +12,7 @@ import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.TpeRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.NatureDomaineRepository; +import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypeDomaineRepository; import io.gmss.fiscad.persistence.repositories.metadata.MobileDataParcelleRepository; import io.gmss.fiscad.service.LogService; import lombok.RequiredArgsConstructor; @@ -27,6 +29,7 @@ public class ParcelleAsyncWorker { private final NatureDomaineRepository natureDomaineRepository; private final QuartierRepository quartierRepository; private final LogService logService; + private final TypeDomaineRepository typeDomaineRepository; //@Async("parcelleExecutor") public void traitementAsyncParcelle(MobileDataParcelle mobileDataParcelle) { ParcellePayLoad parcellePayLoad = mobileDataParcelle.getParcellePayLoad(); @@ -78,6 +81,12 @@ public class ParcelleAsyncWorker { Optional optionalTpe = tpeRepository.findById(parcellePayLoad.getTerminalId()); parcelle.setTerminal(optionalTpe.orElse(null)); } + + if (parcellePayLoad.getTypeDomaineId() != null) { + Optional optionalTypeDomaine = typeDomaineRepository.findById(parcellePayLoad.getTypeDomaineId()); + parcelle.setTypeDomaine(optionalTypeDomaine.orElse(null)); + } + parcelle.setExternalKey(parcellePayLoad.getExternalKey()); parcelle.setNupProvisoire(parcellePayLoad.getNupProvisoire()); parcelle.setQ(parcellePayLoad.getQ()); @@ -87,7 +96,7 @@ public class ParcelleAsyncWorker { parcelle.setLongitude(parcellePayLoad.getLongitude()); parcelle.setLatitude(parcellePayLoad.getLatitude()); parcelle.setNumTitreFoncier(parcellePayLoad.getNumTitreFoncier()); - parcelle.setTypeDomaineId(parcellePayLoad.getTypeDomaineId()); + // parcelle.setTypeDomaineId(parcellePayLoad.getTypeDomaineId()); parcelle.setNumeroProvisoire(parcellePayLoad.getNumeroProvisoire()); parcelle.setBlocId(parcellePayLoad.getBlocId()); parcelle.setObservation(parcellePayLoad.getObservation()); diff --git a/src/main/java/io/gmss/fiscad/utils/Mail.java b/src/main/java/io/gmss/fiscad/utils/Mail.java new file mode 100755 index 0000000..310ef81 --- /dev/null +++ b/src/main/java/io/gmss/fiscad/utils/Mail.java @@ -0,0 +1,88 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package io.gmss.fiscad.utils; + + +import io.gmss.fiscad.enums.ParametersType; +import io.gmss.fiscad.interfaces.ParametersRepository; +import jakarta.annotation.PostConstruct; +import jakarta.mail.*; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Properties; + +/** + * + * @author AKPONA Christian + */ +@Service +public class Mail { + + private static String port; + private static String host; + private static String username; + private static String password; + + @Autowired + ParametersRepository parametersRepository; + + public boolean sendMessage(String to, String subject, String messageContent) { + boolean retour; + System.out.println(username+" "+password+" "+port+" "+host); + Properties props = new Properties(); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.starttls.enable", "true"); + props.put("mail.smtp.host", host); + props.put("mail.smtp.port", port); + Session session = Session.getInstance(props, + new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + try { + Message message = new MimeMessage(session); + message.setFrom(new InternetAddress(username)); + message.setRecipients(Message.RecipientType.TO, + InternetAddress.parse(to)); + message.setSubject(subject); + message.setContent(messageContent, "text/html"); + + Transport.send(message); + + retour = true; + + } catch (MessagingException e) { + throw new RuntimeException(e); + } + return retour; + } + + + @PostConstruct + public void init(){ + if(parametersRepository.findFirstByName(ParametersType.SMTP_HOST).isPresent()){ + host = parametersRepository.findFirstByName(ParametersType.SMTP_HOST).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.SMTP_PORT).isPresent()){ + port = parametersRepository.findFirstByName(ParametersType.SMTP_PORT).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.SMTP_USERNAME).isPresent()){ + username = parametersRepository.findFirstByName(ParametersType.SMTP_USERNAME).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.SMTP_PASSWORD).isPresent()){ + password = parametersRepository.findFirstByName(ParametersType.SMTP_PASSWORD).get().getValue(); + } + } + + +} diff --git a/src/main/java/io/gmss/fiscad/utils/MailPostmark.java b/src/main/java/io/gmss/fiscad/utils/MailPostmark.java new file mode 100755 index 0000000..248a53a --- /dev/null +++ b/src/main/java/io/gmss/fiscad/utils/MailPostmark.java @@ -0,0 +1,72 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package io.gmss.fiscad.utils; + + +import com.wildbit.java.postmark.Postmark; +import com.wildbit.java.postmark.client.ApiClient; +import com.wildbit.java.postmark.client.data.model.message.Message; +import com.wildbit.java.postmark.client.exception.PostmarkException; +import io.gmss.fiscad.enums.ParametersType; +import io.gmss.fiscad.interfaces.ParametersRepository; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.IOException; +//import java.util.Properties; + +/** + * + * @author AKPONA Christian + */ +@Service +public class MailPostmark { + + private static String port; + private static String host; + private static String username; + private static String password; + + @Autowired + ParametersRepository parametersRepository; + + + + @PostConstruct + public void init(){ + if(parametersRepository.findFirstByName(ParametersType.SMTP_HOST).isPresent()){ + host = parametersRepository.findFirstByName(ParametersType.SMTP_HOST).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.SMTP_PORT).isPresent()){ + port = parametersRepository.findFirstByName(ParametersType.SMTP_PORT).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.SMTP_USERNAME).isPresent()){ + username = parametersRepository.findFirstByName(ParametersType.SMTP_USERNAME).get().getValue(); + } + + if(parametersRepository.findFirstByName(ParametersType.SMTP_PASSWORD).isPresent()){ + password = parametersRepository.findFirstByName(ParametersType.SMTP_PASSWORD).get().getValue(); + } + } + + public boolean sendMessage(String to, String subject, String body, String fileToAttach, String from) throws IOException { + try { + ApiClient client = Postmark.getApiClient("7e04713f-d019-41b0-b91b-90bfb52bb41c"); + Message message = new Message(from, to, subject, body); + message.setMessageStream("outbound"); + // message.addAttachment(fileToAttach); + client.deliverMessage(message); + } catch (PostmarkException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return false; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e06de1e..e9d673d 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=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