Sync: code local unifié

Synchronisation du code source local (fait foi).

Signed-off-by: lions dev Team
This commit is contained in:
dahoud
2026-03-15 16:25:40 +00:00
parent e82dc356f3
commit 75a19988b0
730 changed files with 53599 additions and 13145 deletions

View File

@@ -1,29 +1,32 @@
package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.*;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.*;
/** Entité Membre avec UUID */
/**
* Identité globale unique d'un utilisateur UnionFlow.
*
* <p>
* Un utilisateur possède un seul compte sur toute la plateforme.
* Ses adhésions aux organisations sont gérées dans {@link MembreOrganisation}.
*
* <p>
* Table : {@code utilisateurs}
*/
@Entity
@Table(
name = "membres",
indexes = {
@Index(name = "idx_membre_email", columnList = "email", unique = true),
@Index(name = "idx_membre_numero", columnList = "numero_membre", unique = true),
@Index(name = "idx_membre_actif", columnList = "actif")
})
@Table(name = "utilisateurs", indexes = {
@Index(name = "idx_utilisateur_email", columnList = "email", unique = true),
@Index(name = "idx_utilisateur_numero", columnList = "numero_membre", unique = true),
@Index(name = "idx_utilisateur_keycloak", columnList = "keycloak_id", unique = true),
@Index(name = "idx_utilisateur_actif", columnList = "actif"),
@Index(name = "idx_utilisateur_statut", columnList = "statut_compte")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@@ -31,6 +34,11 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
public class Membre extends BaseEntity {
/** Identifiant Keycloak (UUID du compte OIDC) */
@Column(name = "keycloak_id", unique = true)
private UUID keycloakId;
/** Numéro de membre — unique globalement sur toute la plateforme */
@NotBlank
@Column(name = "numero_membre", unique = true, nullable = false, length = 20)
private String numeroMembre;
@@ -48,15 +56,10 @@ public class Membre extends BaseEntity {
@Column(name = "email", unique = true, nullable = false, length = 255)
private String email;
@Column(name = "mot_de_passe", length = 255)
private String motDePasse;
@Column(name = "telephone", length = 20)
private String telephone;
@Pattern(
regexp = "^\\+225[0-9]{8}$",
message = "Le numéro de téléphone Wave doit être au format +225XXXXXXXX")
@Pattern(regexp = "^\\+225[0-9]{8}$", message = "Le numéro Wave doit être au format +225XXXXXXXX")
@Column(name = "telephone_wave", length = 13)
private String telephoneWave;
@@ -64,43 +67,94 @@ public class Membre extends BaseEntity {
@Column(name = "date_naissance", nullable = false)
private LocalDate dateNaissance;
@NotNull
@Column(name = "date_adhesion", nullable = false)
private LocalDate dateAdhesion;
@Column(name = "profession", length = 100)
private String profession;
// Relations
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
@Column(name = "photo_url", length = 500)
private String photoUrl;
@Builder.Default
@Column(name = "statut_compte", nullable = false, length = 30)
private String statutCompte = "EN_ATTENTE_VALIDATION";
/**
* Statut matrimonial (domaine
* {@code STATUT_MATRIMONIAL} dans
* {@code types_reference}).
*/
@Column(name = "statut_matrimonial", length = 50)
private String statutMatrimonial;
/** Nationalité. */
@Column(name = "nationalite", length = 100)
private String nationalite;
/**
* Type de pièce d'identité (domaine
* {@code TYPE_IDENTITE} dans
* {@code types_reference}).
*/
@Column(name = "type_identite", length = 50)
private String typeIdentite;
/** Numéro de la pièce d'identité. */
@Column(name = "numero_identite", length = 100)
private String numeroIdentite;
/** Niveau de vigilance KYC LCB-FT (SIMPLIFIE, RENFORCE). */
@Column(name = "niveau_vigilance_kyc", length = 20)
private String niveauVigilanceKyc;
/** Statut de vérification d'identité (NON_VERIFIE, EN_COURS, VERIFIE, REFUSE). */
@Column(name = "statut_kyc", length = 20)
private String statutKyc;
/** Date de dernière vérification d'identité. */
@Column(name = "date_verification_identite")
private LocalDate dateVerificationIdentite;
// ── Relations ────────────────────────────────────────────────────────────
/** Adhésions à des organisations */
@JsonIgnore
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<MembreOrganisation> membresOrganisations = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<Adresse> adresses = new ArrayList<>();
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<MembreRole> roles = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<CompteWave> comptesWave = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<Paiement> paiements = new ArrayList<>();
/** Méthode métier pour obtenir le nom complet */
// ── Méthodes métier ───────────────────────────────────────────────────────
public String getNomComplet() {
return prenom + " " + nom;
}
/** Méthode métier pour vérifier si le membre est majeur */
public boolean isMajeur() {
return dateNaissance.isBefore(LocalDate.now().minusYears(18));
return dateNaissance != null && dateNaissance.isBefore(LocalDate.now().minusYears(18));
}
/** Méthode métier pour calculer l'âge */
public int getAge() {
return LocalDate.now().getYear() - dateNaissance.getYear();
return dateNaissance != null ? LocalDate.now().getYear() - dateNaissance.getYear() : 0;
}
@PrePersist
protected void onCreate() {
super.onCreate();
if (statutCompte == null) {
statutCompte = "EN_ATTENTE_VALIDATION";
}
}
}