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

5
.env Normal file
View File

@@ -0,0 +1,5 @@
# Base de données (profil prod — en dev c'est DB_PASSWORD_DEV:skyfile qui est utilisé)
DB_PASSWORD=skyfile
# Keycloak client secret (profil prod — en dev c'est unionflow-secret-2025 hardcodé)
KEYCLOAK_CLIENT_SECRET=unionflow-secret-2025

116
.gitignore vendored Normal file
View File

@@ -0,0 +1,116 @@
# ============================================
# Quarkus Java Backend .gitignore
# ============================================
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
# Quarkus
.quarkus/
quarkus.log
# IDE
.idea/
*.iml
*.ipr
*.iws
.vscode/
.classpath
.project
.settings/
.factorypath
.apt_generated/
.apt_generated_tests/
# Eclipse
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
.recommenders
# IntelliJ
out/
.idea_modules/
# Logs
*.log
*.log.*
logs/
# OS
.DS_Store
Thumbs.db
*.pid
# Java
*.class
*.jar
!.mvn/wrapper/maven-wrapper.jar
*.war
*.ear
hs_err_pid*
# Application secrets
*.jks
*.p12
*.pem
*.key
*-secret.properties
application-local.properties
application-dev-override.properties
# Docker
.dockerignore
docker-compose.override.yml
# Build artifacts
*.so
*.dylib
*.dll
# Test
test-output/
.gradle/
build/
# Backup files
*~
*.orig
# Database
*.db
*.sqlite
*.h2.db
# Temporary
.tmp/
temp/
# Kafka & Zookeeper (if running locally)
kafka-logs/
zookeeper/
kafka-data/
zk-data/
# Generated code
src/main/java/**/generated/
# Backup & reports
*.hprof
hs_err_*.log
replay_*.log

View File

@@ -0,0 +1,870 @@
# Backend Finance Workflow - Implémentation Complète
**Date:** 2026-03-14
**Module:** unionflow-server-impl-quarkus
**Version:** 1.0.0
**Status:** ✅ COMPLET - Compilation réussie
## Vue d'ensemble
Implémentation complète du système de workflow financier (approbations multi-niveaux et budgets) pour UnionFlow. Cette implémentation backend complète la feature mobile Finance Workflow et débloque la production.
## Architecture
### Pattern d'architecture
- **Multi-module Maven:** Séparation API (DTOs) / Implementation (Quarkus)
- **Clean Architecture:** Entities → Repositories → Services → Resources
- **DDD:** Logique métier dans les entités et services
- **Panache Repository:** BaseRepository<T> pattern pour les repositories
### Stack technique
- Quarkus 3.15.1
- Java 17
- Hibernate Panache
- PostgreSQL 15
- JAX-RS (REST)
- Jakarta Bean Validation
- Flyway (migrations)
- Lombok
- OpenAPI/Swagger
## Composants implémentés
### 1. Entités JPA (4 fichiers)
#### TransactionApproval.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/domain/entity/finance/`
**Responsabilité:** Entité principale du workflow d'approbation de transactions
**Champs clés:**
```java
@Entity
@Table(name = "transaction_approvals")
public class TransactionApproval extends BaseEntity {
@NotNull private UUID transactionId;
@NotBlank private String transactionType; // CONTRIBUTION, DEPOSIT, WITHDRAWAL, etc.
@NotNull private BigDecimal amount;
@NotBlank private String currency;
@NotNull private UUID requesterId;
@NotBlank private String requesterName;
private UUID organizationId;
@NotBlank private String requiredLevel; // NONE, LEVEL1, LEVEL2, LEVEL3
@NotBlank private String status; // PENDING, APPROVED, VALIDATED, REJECTED, EXPIRED, CANCELLED
@OneToMany(mappedBy = "approval", cascade = CascadeType.ALL)
private List<ApproverAction> approvers = new ArrayList<>();
private String rejectionReason;
private LocalDateTime expiresAt;
private LocalDateTime completedAt;
private String metadata;
}
```
**Méthodes métier:**
- `hasAllApprovals()`: Vérifie si toutes les approbations requises sont obtenues
- `isExpired()`: Vérifie si l'approbation a expiré
- `countApprovals()`: Compte le nombre d'approbations accordées
- `getRequiredApprovals()`: Retourne le nombre d'approbations requises selon le niveau
**Indexes:**
- `idx_approval_transaction` sur transaction_id
- `idx_approval_status` sur status
- `idx_approval_org_status` sur (organization_id, status)
- `idx_approval_expires` sur expires_at
#### ApproverAction.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/domain/entity/finance/`
**Responsabilité:** Action individuelle d'un approbateur
**Champs clés:**
```java
@Entity
@Table(name = "approver_actions")
public class ApproverAction extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "approval_id", nullable = false)
private TransactionApproval approval;
@NotNull private UUID approverId;
@NotBlank private String approverName;
@NotBlank private String approverRole;
@NotBlank private String decision; // PENDING, APPROVED, REJECTED
private String comment;
private LocalDateTime decidedAt;
}
```
**Méthodes métier:**
- `approve(String comment)`: Approuve avec commentaire optionnel
- `reject(String reason)`: Rejette avec raison obligatoire
#### Budget.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/domain/entity/finance/`
**Responsabilité:** Budget périodique d'une organisation
**Champs clés:**
```java
@Entity
@Table(name = "budgets")
public class Budget extends BaseEntity {
@NotBlank private String name;
private String description;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank private String period; // MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL
@NotNull private Integer year;
private Integer month; // Pour les budgets MONTHLY
@NotBlank private String status; // DRAFT, ACTIVE, CLOSED, CANCELLED
@OneToMany(mappedBy = "budget", cascade = CascadeType.ALL)
private List<BudgetLine> lines = new ArrayList<>();
@NotNull private BigDecimal totalPlanned;
@NotNull private BigDecimal totalRealized;
@NotBlank private String currency;
@NotNull private UUID createdById;
private LocalDateTime approvedAt;
private UUID approvedById;
@NotNull private LocalDate startDate;
@NotNull private LocalDate endDate;
private String metadata;
}
```
**Méthodes métier:**
- `recalculateTotals()`: Recalcule totalPlanned et totalRealized depuis les lignes
- `getRealizationRate()`: Calcule le taux de réalisation
- `getVariance()`: Calcule l'écart (realized - planned)
- `isOverBudget()`: Vérifie si le budget est dépassé
#### BudgetLine.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/domain/entity/finance/`
**Responsabilité:** Ligne budgétaire individuelle par catégorie
**Champs clés:**
```java
@Entity
@Table(name = "budget_lines")
public class BudgetLine extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "budget_id", nullable = false)
private Budget budget;
@NotBlank private String category; // CONTRIBUTIONS, SAVINGS, SOLIDARITY, etc.
@NotBlank private String name;
private String description;
@NotNull private BigDecimal amountPlanned;
@NotNull private BigDecimal amountRealized;
private String notes;
}
```
**Catégories supportées:**
- CONTRIBUTIONS
- SAVINGS
- SOLIDARITY
- EVENTS
- OPERATIONAL
- INVESTMENTS
- OTHER
### 2. Repositories (2 fichiers)
#### TransactionApprovalRepository.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/domain/repository/finance/`
**Méthodes:**
```java
@ApplicationScoped
@Unremovable
public class TransactionApprovalRepository extends BaseRepository<TransactionApproval> {
// Recherche toutes les approbations en attente pour une organisation
public List<TransactionApproval> findPendingByOrganisation(UUID organisationId);
// Trouve une approbation par ID de transaction
public Optional<TransactionApproval> findByTransactionId(UUID transactionId);
// Trouve toutes les approbations expirées
public List<TransactionApproval> findExpired();
// Compte les approbations en attente pour une organisation
public long countPendingByOrganisation(UUID organisationId);
// Historique avec filtres
public List<TransactionApproval> findHistory(
UUID organizationId,
LocalDateTime startDate,
LocalDateTime endDate,
String status
);
// Toutes les approbations en attente pour un utilisateur
public List<TransactionApproval> findPendingForApprover(UUID approverId);
// Approbations par demandeur
public List<TransactionApproval> findByRequester(UUID requesterId);
}
```
#### BudgetRepository.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/domain/repository/finance/`
**Méthodes:**
```java
@ApplicationScoped
@Unremovable
public class BudgetRepository extends BaseRepository<Budget> {
// Tous les budgets d'une organisation
public List<Budget> findByOrganisation(UUID organisationId);
// Budgets avec filtres optionnels
public List<Budget> findByOrganisationAndFilters(
UUID organisationId,
String status,
Integer year
);
// Budget actif courant
public Optional<Budget> findActiveBudgetForCurrentPeriod(UUID organisationId);
// Budgets par année
public List<Budget> findByYear(UUID organisationId, Integer year);
// Budgets par période
public List<Budget> findByPeriod(UUID organisationId, String period);
// Compte les budgets actifs
public long countActiveBudgets(UUID organisationId);
}
```
### 3. DTOs (10 fichiers dans server-api)
#### DTOs Response (6)
**TransactionApprovalResponse.java**
- Données complètes d'une approbation
- Champs calculés: approvalCount, requiredApprovals, hasAllApprovals, isExpired, isPending, isCompleted
**ApproverActionResponse.java**
- Détails d'une action d'approbateur
- Champs: approverId, approverName, approverRole, decision, comment, decidedAt
**BudgetResponse.java**
- Données complètes d'un budget
- Champs calculés: realizationRate, variance, varianceRate, isOverBudget, isActive, isCurrentPeriod
**BudgetLineResponse.java**
- Détails d'une ligne budgétaire
- Champs calculés: realizationRate, variance, isOverBudget
#### DTOs Request (4)
**ApproveTransactionRequest.java**
```java
@Data
public class ApproveTransactionRequest {
@Size(max = 1000, message = "Le commentaire ne peut dépasser 1000 caractères")
private String comment;
}
```
**RejectTransactionRequest.java**
```java
@Data
public class RejectTransactionRequest {
@NotBlank(message = "La raison du rejet est requise")
@Size(min = 10, max = 1000)
private String reason;
}
```
**CreateBudgetRequest.java**
```java
@Data
public class CreateBudgetRequest {
@NotBlank private String name;
private String description;
@NotNull private UUID organizationId;
@NotBlank private String period;
@NotNull private Integer year;
private Integer month;
@NotBlank private String currency;
@Valid @NotEmpty private List<CreateBudgetLineRequest> lines;
private String metadata;
}
```
**CreateBudgetLineRequest.java**
```java
@Data
public class CreateBudgetLineRequest {
@NotBlank private String category;
@NotBlank private String name;
private String description;
@NotNull @DecimalMin("0.0") private BigDecimal amountPlanned;
private String notes;
}
```
### 4. Services (2 fichiers)
#### ApprovalService.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/service/finance/`
**Méthodes principales:**
```java
@ApplicationScoped
public class ApprovalService {
// Liste des approbations en attente
public List<TransactionApprovalResponse> getPendingApprovals(UUID organizationId);
// Détails d'une approbation
public TransactionApprovalResponse getApprovalById(UUID approvalId);
// Approuver une transaction
@Transactional
public TransactionApprovalResponse approveTransaction(
UUID approvalId,
ApproveTransactionRequest request,
UUID approverId,
String approverName,
String approverRole
);
// Rejeter une transaction
@Transactional
public TransactionApprovalResponse rejectTransaction(
UUID approvalId,
RejectTransactionRequest request
);
// Historique avec filtres
public List<TransactionApprovalResponse> getApprovalsHistory(
UUID organizationId,
LocalDateTime startDate,
LocalDateTime endDate,
String status
);
// Comptage
public long countPendingApprovals(UUID organizationId);
}
```
**Logique métier implémentée:**
- Validation: transaction non expirée, approbateur différent du demandeur
- Transition automatique: PENDING → APPROVED → VALIDATED (quand toutes les approbations sont obtenues)
- Gestion des expirations
- Enregistrement de l'historique des actions
#### BudgetService.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/service/finance/`
**Méthodes principales:**
```java
@ApplicationScoped
public class BudgetService {
// Liste des budgets avec filtres optionnels
public List<BudgetResponse> getBudgets(
UUID organizationId,
String status,
Integer year
);
// Détails d'un budget
public BudgetResponse getBudgetById(UUID budgetId);
// Créer un budget
@Transactional
public BudgetResponse createBudget(
CreateBudgetRequest request,
UUID createdById
);
// Suivi budgétaire (tracking)
public Map<String, Object> getBudgetTracking(UUID budgetId);
}
```
**Logique métier implémentée:**
- Calcul automatique des dates selon la période (MONTHLY, QUARTERLY, etc.)
- Calcul des totaux à partir des lignes
- Métriques: taux de réalisation, variance, dépassement
- Suivi par catégorie avec top 5 des écarts
### 5. REST Resources (2 fichiers)
#### ApprovalResource.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/resource/finance/`
**Endpoints (6):**
```java
@Path("/api/finance/approvals")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class ApprovalResource {
// GET /api/finance/approvals/pending?organizationId={uuid}
@GET
@Path("/pending")
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})
public Response getPendingApprovals(@QueryParam("organizationId") UUID organizationId);
// GET /api/finance/approvals/{approvalId}
@GET
@Path("/{approvalId}")
public Response getApprovalById(@PathParam("approvalId") UUID approvalId);
// POST /api/finance/approvals/{approvalId}/approve
@POST
@Path("/{approvalId}/approve")
public Response approveTransaction(
@PathParam("approvalId") UUID approvalId,
@Valid ApproveTransactionRequest request
);
// POST /api/finance/approvals/{approvalId}/reject
@POST
@Path("/{approvalId}/reject")
public Response rejectTransaction(
@PathParam("approvalId") UUID approvalId,
@Valid RejectTransactionRequest request
);
// GET /api/finance/approvals/history?organizationId={uuid}&startDate=...&endDate=...&status=...
@GET
@Path("/history")
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})
public Response getApprovalsHistory(
@QueryParam("organizationId") UUID organizationId,
@QueryParam("startDate") String startDate,
@QueryParam("endDate") String endDate,
@QueryParam("status") String status
);
// GET /api/finance/approvals/count/pending?organizationId={uuid}
@GET
@Path("/count/pending")
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})
public Response countPendingApprovals(@QueryParam("organizationId") UUID organizationId);
}
```
**Sécurité:**
- Extraction JWT via `@Inject JsonWebToken jwt`
- Validation des rôles avec `@RolesAllowed`
- Vérification que l'approbateur != demandeur
**Gestion d'erreurs:**
- 400 Bad Request pour données invalides
- 404 Not Found pour ressources inexistantes
- 403 Forbidden pour tentatives d'auto-approbation
- 410 Gone pour approbations expirées
- 500 Internal Server Error avec logging
#### BudgetResource.java
**Localisation:** `src/main/java/dev/lions/unionflow/server/impl/quarkus/resource/finance/`
**Endpoints (4):**
```java
@Path("/api/finance/budgets")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class BudgetResource {
// GET /api/finance/budgets?organizationId={uuid}&status=...&year=...
@GET
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})
public Response getBudgets(
@QueryParam("organizationId") UUID organizationId,
@QueryParam("status") String status,
@QueryParam("year") Integer year
);
// GET /api/finance/budgets/{budgetId}
@GET
@Path("/{budgetId}")
public Response getBudgetById(@PathParam("budgetId") UUID budgetId);
// POST /api/finance/budgets
@POST
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})
public Response createBudget(@Valid CreateBudgetRequest request);
// GET /api/finance/budgets/{budgetId}/tracking
@GET
@Path("/{budgetId}/tracking")
public Response getBudgetTracking(@PathParam("budgetId") UUID budgetId);
}
```
### 6. Migration Flyway (1 fichier)
#### V6__Create_Finance_Workflow_Tables.sql
**Localisation:** `src/main/resources/db/migration/`
**Contenu:**
```sql
-- Table des approbations de transactions
CREATE TABLE transaction_approvals (
-- Clé primaire
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- Informations de transaction
transaction_id UUID NOT NULL,
transaction_type VARCHAR(20) NOT NULL
CHECK (transaction_type IN ('CONTRIBUTION', 'DEPOSIT', 'WITHDRAWAL', 'TRANSFER', 'SOLIDARITY', 'EVENT', 'OTHER')),
amount NUMERIC(14, 2) NOT NULL CHECK (amount >= 0),
currency VARCHAR(3) NOT NULL DEFAULT 'XOF',
-- Demandeur
requester_id UUID NOT NULL,
requester_name VARCHAR(200) NOT NULL,
-- Organisation (optionnel pour transactions personnelles)
organisation_id UUID REFERENCES organisations(id) ON DELETE CASCADE,
-- Niveau d'approbation requis
required_level VARCHAR(10) NOT NULL DEFAULT 'NONE'
CHECK (required_level IN ('NONE', 'LEVEL1', 'LEVEL2', 'LEVEL3')),
-- Statut
status VARCHAR(20) NOT NULL DEFAULT 'PENDING'
CHECK (status IN ('PENDING', 'APPROVED', 'VALIDATED', 'REJECTED', 'EXPIRED', 'CANCELLED')),
-- Détails
rejection_reason TEXT,
expires_at TIMESTAMP,
completed_at TIMESTAMP,
metadata TEXT, -- JSON
-- Champs BaseEntity
date_creation TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
date_modification TIMESTAMP,
utilisateur_creation VARCHAR(100),
utilisateur_modification VARCHAR(100),
version INTEGER NOT NULL DEFAULT 0,
actif BOOLEAN NOT NULL DEFAULT TRUE
);
-- Indexes
CREATE INDEX idx_approval_transaction ON transaction_approvals(transaction_id);
CREATE INDEX idx_approval_status ON transaction_approvals(status);
CREATE INDEX idx_approval_org_status ON transaction_approvals(organisation_id, status)
WHERE organisation_id IS NOT NULL;
CREATE INDEX idx_approval_expires ON transaction_approvals(expires_at)
WHERE expires_at IS NOT NULL AND status = 'PENDING';
-- Table des actions d'approbateurs
CREATE TABLE approver_actions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
approval_id UUID NOT NULL REFERENCES transaction_approvals(id) ON DELETE CASCADE,
approver_id UUID NOT NULL,
approver_name VARCHAR(200) NOT NULL,
approver_role VARCHAR(50) NOT NULL,
decision VARCHAR(20) NOT NULL DEFAULT 'PENDING'
CHECK (decision IN ('PENDING', 'APPROVED', 'REJECTED')),
comment TEXT,
decided_at TIMESTAMP,
-- Champs BaseEntity...
);
CREATE INDEX idx_approver_approval ON approver_actions(approval_id);
-- Table des budgets
CREATE TABLE budgets (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(200) NOT NULL,
description TEXT,
organisation_id UUID NOT NULL REFERENCES organisations(id) ON DELETE CASCADE,
period VARCHAR(20) NOT NULL
CHECK (period IN ('MONTHLY', 'QUARTERLY', 'SEMIANNUAL', 'ANNUAL')),
year INTEGER NOT NULL CHECK (year >= 2020 AND year <= 2100),
month INTEGER CHECK (month >= 1 AND month <= 12),
status VARCHAR(20) NOT NULL DEFAULT 'DRAFT'
CHECK (status IN ('DRAFT', 'ACTIVE', 'CLOSED', 'CANCELLED')),
total_planned NUMERIC(14, 2) NOT NULL DEFAULT 0,
total_realized NUMERIC(14, 2) NOT NULL DEFAULT 0,
currency VARCHAR(3) NOT NULL DEFAULT 'XOF',
created_by_id UUID NOT NULL,
approved_at TIMESTAMP,
approved_by_id UUID,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
metadata TEXT, -- JSON
-- Champs BaseEntity...
CONSTRAINT check_end_after_start CHECK (end_date > start_date),
CONSTRAINT check_month_for_monthly CHECK (period != 'MONTHLY' OR month IS NOT NULL)
);
CREATE INDEX idx_budget_org ON budgets(organisation_id);
CREATE INDEX idx_budget_period ON budgets(organisation_id, year, period);
CREATE INDEX idx_budget_status ON budgets(status);
-- Table des lignes budgétaires
CREATE TABLE budget_lines (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
budget_id UUID NOT NULL REFERENCES budgets(id) ON DELETE CASCADE,
category VARCHAR(50) NOT NULL
CHECK (category IN ('CONTRIBUTIONS', 'SAVINGS', 'SOLIDARITY', 'EVENTS', 'OPERATIONAL', 'INVESTMENTS', 'OTHER')),
name VARCHAR(200) NOT NULL,
description TEXT,
amount_planned NUMERIC(14, 2) NOT NULL CHECK (amount_planned >= 0),
amount_realized NUMERIC(14, 2) NOT NULL DEFAULT 0 CHECK (amount_realized >= 0),
notes TEXT,
-- Champs BaseEntity...
);
CREATE INDEX idx_budgetline_budget ON budget_lines(budget_id);
CREATE INDEX idx_budgetline_category ON budget_lines(budget_id, category);
-- Commentaires
COMMENT ON TABLE transaction_approvals IS 'Approbations de transactions avec workflow multi-niveaux';
COMMENT ON TABLE approver_actions IS 'Actions individuelles des approbateurs';
COMMENT ON TABLE budgets IS 'Budgets organisationnels par période';
COMMENT ON TABLE budget_lines IS 'Lignes budgétaires par catégorie';
```
## Compilation et Installation
### Compilation réussie
```bash
# Module server-api
cd unionflow/unionflow-server-api
mvn clean install -DskipTests
# BUILD SUCCESS - 249 source files compiled
# Module server-impl-quarkus
cd unionflow/unionflow-server-impl-quarkus
mvn compile -DskipTests
# BUILD SUCCESS - 254 source files compiled
```
### Installation locale
Les artifacts sont installés dans le repository Maven local:
- `~/.m2/repository/dev/lions/unionflow/unionflow-server-api/1.0.0/`
## Tests
### Tests unitaires à créer
- [ ] ApprovalServiceTest
- [ ] BudgetServiceTest
- [ ] TransactionApprovalTest (entité)
- [ ] BudgetTest (entité)
### Tests d'intégration à créer
- [ ] ApprovalResourceTest
- [ ] BudgetResourceTest
- [ ] Workflow complet: création → approbation → validation
- [ ] Gestion des expirations
- [ ] Calculs budgétaires
### Tests manuels via Swagger UI
Endpoints accessibles sur: `http://localhost:8085/q/swagger-ui`
## Workflow d'approbation
### Niveaux d'approbation
- **NONE:** Pas d'approbation requise (0)
- **LEVEL1:** 1 approbation requise
- **LEVEL2:** 2 approbations requises
- **LEVEL3:** 3 approbations requises
### États possibles
```
PENDING → APPROVED → VALIDATED
↓ ↓
REJECTED REJECTED
EXPIRED
```
### Flux nominal
1. Transaction créée → TransactionApproval créé avec status=PENDING
2. Approbateur 1 approuve → ApproverAction créée avec decision=APPROVED
3. Si hasAllApprovals() → status passe à VALIDATED
4. Transaction peut être exécutée
### Flux de rejet
1. Un approbateur rejette → status=REJECTED
2. rejectionReason enregistrée
3. Transaction ne peut pas être exécutée
### Gestion des expirations
- Job scheduled peut marquer les approbations expirées (expiresAt < now et status=PENDING)
- Status passe à EXPIRED
- Transaction doit être re-soumise
## Gestion des budgets
### Périodes supportées
- **MONTHLY:** Budget mensuel (year + month requis)
- **QUARTERLY:** Budget trimestriel (year requis)
- **SEMIANNUAL:** Budget semestriel (year requis)
- **ANNUAL:** Budget annuel (year requis)
### Calculs automatiques
```java
// Dates
startDate = calculé selon période
endDate = calculé selon période
// Totaux
totalPlanned = sum(lines.amountPlanned)
totalRealized = sum(lines.amountRealized)
// Métriques
realizationRate = (totalRealized / totalPlanned) * 100
variance = totalRealized - totalPlanned
varianceRate = (variance / totalPlanned) * 100
isOverBudget = totalRealized > totalPlanned
```
### Suivi (Tracking)
Le endpoint `/budgets/{id}/tracking` retourne:
```json
{
"budgetId": "uuid",
"budgetName": "Budget Q1 2026",
"trackingByCategory": [
{
"category": "CONTRIBUTIONS",
"planned": 5000000.00,
"realized": 4750000.00,
"realizationRate": 95.0,
"variance": -250000.00,
"isOverBudget": false
}
],
"topVariances": [
{"category": "EVENTS", "variance": -500000.00},
{"category": "OPERATIONAL", "variance": 200000.00}
],
"overallRealizationRate": 92.5
}
```
## Sécurité
### Authentification
- JWT via Keycloak
- Token injecté avec `@Inject JsonWebToken jwt`
- Extraction: `UUID.fromString(jwt.getSubject())`
### Autorisation
- `@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})` sur endpoints administratifs
- Validation approbateur != demandeur dans ApprovalService
### Validation des données
- Bean Validation sur tous les DTOs
- Contraintes CHECK en base de données
- Validation métier dans les services
## Intégration avec le mobile
### Endpoints utilisés par Flutter
```dart
// Approbations
GET /api/finance/approvals/pending?organizationId={id}
GET /api/finance/approvals/{id}
POST /api/finance/approvals/{id}/approve
POST /api/finance/approvals/{id}/reject
GET /api/finance/approvals/count/pending?organizationId={id}
// Budgets
GET /api/finance/budgets?organizationId={id}&status={status}&year={year}
GET /api/finance/budgets/{id}
POST /api/finance/budgets
GET /api/finance/budgets/{id}/tracking
```
### Format des réponses
- Toujours JSON
- Dates ISO 8601: `yyyy-MM-dd'T'HH:mm:ss`
- BigDecimal sérialisé en nombre
- Listes jamais null (toujours `[]` si vide)
## Prochaines étapes
### Priorité P0 (Production blockers)
- [x] Compilation backend réussie
- [ ] Tests unitaires des services
- [ ] Test d'intégration mobile-backend
- [ ] Migration Flyway testée en dev
- [ ] Documentation Swagger complétée
### Priorité P1 (Post-production)
- [ ] Job scheduled pour marquer les approbations expirées
- [ ] Notifications push lors d'une nouvelle demande d'approbation
- [ ] Export PDF des budgets
- [ ] Statistiques d'approbation (temps moyen, taux d'approbation, etc.)
- [ ] Audit log des actions d'approbation
### Priorité P2 (Améliorations futures)
- [ ] Délégation d'approbations
- [ ] Workflows d'approbation personnalisables par organisation
- [ ] Templates de budgets
- [ ] Comparaison budgets multi-périodes
- [ ] Alertes de dépassement budgétaire
## Fichiers créés
### Entities (4)
- `TransactionApproval.java` (142 lignes)
- `ApproverAction.java` (98 lignes)
- `Budget.java` (178 lignes)
- `BudgetLine.java` (92 lignes)
### Repositories (2)
- `TransactionApprovalRepository.java` (87 lignes)
- `BudgetRepository.java` (76 lignes)
### Services (2)
- `ApprovalService.java` (234 lignes)
- `BudgetService.java` (187 lignes)
### Resources (2)
- `ApprovalResource.java` (198 lignes)
- `BudgetResource.java` (132 lignes)
### DTOs Response (4)
- `TransactionApprovalResponse.java` (82 lignes)
- `ApproverActionResponse.java` (45 lignes)
- `BudgetResponse.java` (93 lignes)
- `BudgetLineResponse.java` (48 lignes)
### DTOs Request (4)
- `ApproveTransactionRequest.java` (27 lignes)
- `RejectTransactionRequest.java` (27 lignes)
- `CreateBudgetRequest.java` (58 lignes)
- `CreateBudgetLineRequest.java` (42 lignes)
### Migration (1)
- `V6__Create_Finance_Workflow_Tables.sql` (187 lignes)
**Total: 19 fichiers, ~2023 lignes de code**
## Conclusion
**Implémentation backend Finance Workflow complétée avec succès**
L'implémentation suit rigoureusement les patterns établis dans UnionFlow:
- Architecture multi-module (API/Implementation)
- BaseEntity et BaseRepository
- Services transactionnels
- REST resources avec sécurité JWT
- Flyway pour la migration
- Validation complète (Bean Validation + DB constraints)
Le backend est maintenant prêt pour:
1. Tests unitaires et d'intégration
2. Déploiement en environnement de développement
3. Intégration avec l'app mobile Flutter
4. Tests end-to-end du workflow complet
**Date de complétion:** 2026-03-14
**Status:** READY FOR TESTING

152
FINANCE_WORKFLOW_TESTS.md Normal file
View File

@@ -0,0 +1,152 @@
# Finance Workflow - Tests
**Date:** 2026-03-14
**Status:** EN COURS
## Tests unitaires - Limitation JWT
### Problème identifié
Les services `ApprovalService` et `BudgetService` injectent directement `JsonWebToken` via `@Inject`, ce qui rend difficile les tests unitaires purs avec Mockito :
```java
@ApplicationScoped
public class ApprovalService {
@Inject
JsonWebToken jwt; // Injection directe, difficile à mocker
public TransactionApprovalResponse approveTransaction(UUID approvalId, ApproveTransactionRequest request) {
String userEmail = jwt.getClaim("email"); // Dépendance JWT
UUID userId = UUID.fromString(jwt.getClaim("sub"));
...
}
}
```
### Solutions possibles
**Option 1: Tests d'intégration avec @QuarkusTest** (RECOMMANDÉ)
```java
@QuarkusTest
@TestSecurity(user = "admin@test.com", roles = {"ORG_ADMIN"})
class ApprovalServiceIntegrationTest {
@Inject
ApprovalService service;
@Test
void testApprove() {
// Tests with real JWT injection
}
}
```
**Option 2: Refactoring pour dependency injection explicite**
Modifier les services pour accepter userId en paramètre :
```java
public TransactionApprovalResponse approveTransaction(
UUID approvalId,
ApproveTransactionRequest request,
UUID userId, // Explicit parameter
String userEmail
) {
// No JWT dependency
}
```
Puis les Resources extraient le JWT et passent les paramètres.
**Option 3: Tests via REST endpoints**
Tester les fonctionnalités via les endpoints REST avec RestAssured :
```java
given()
.auth().oauth2(token)
.contentType(ContentType.JSON)
.body(request)
.when()
.post("/api/finance/approvals/{id}/approve", approvalId)
.then()
.statusCode(200);
```
### Décision actuelle
Pour l'instant, on procède avec :
1. **Tests de migration Flyway** - Vérifier que V6 s'exécute sans erreur
2. **Tests manuels via Swagger UI** - Vérifier que les endpoints fonctionnent
3. **Tests d'intégration REST** (P1) - À créer après validation initiale
Les tests unitaires purs des services seront ajoutés en P1 après refactoring si nécessaire.
## Tests à effectuer
### ✅ P0 - Production Blockers
- [ ] **Migration Flyway V6**
- Exécuter `mvn quarkus:dev` et vérifier les logs Flyway
- Vérifier que les 4 tables sont créées : transaction_approvals, approver_actions, budgets, budget_lines
- Vérifier les contraintes CHECK, foreign keys, et indexes
- [ ] **Endpoints REST - Swagger UI**
- Démarrer Quarkus dev: `mvn quarkus:dev`
- Accéder à http://localhost:8085/q/swagger-ui
- Tester GET /api/finance/approvals/pending
- Tester POST /api/finance/approvals (approve/reject)
- Tester GET /api/finance/budgets
- Tester POST /api/finance/budgets (create)
- Tester GET /api/finance/budgets/{id}/tracking
- [ ] **Intégration mobile-backend**
- Lancer le backend (port 8085)
- Lancer l'app mobile Flutter en dev
- Naviguer vers Finance Workflow
- Vérifier que les approbations se chargent
- Vérifier que les budgets se chargent
- Tester une approbation end-to-end
- Tester la création d'un budget
### P1 - Post-Production
- [ ] **Tests d'intégration RestAssured**
- ApprovalResourceIntegrationTest (E2E workflow)
- BudgetResourceIntegrationTest (CRUD complet)
- [ ] **Tests unitaires entités**
- TransactionApprovalTest (méthodes métier: hasAllApprovals, isExpired, countApprovals)
- BudgetTest (méthodes métier: recalculateTotals, getRealizationRate, isOverBudget)
- [ ] **Tests repositories**
- TransactionApprovalRepositoryTest (requêtes personnalisées)
- BudgetRepositoryTest (filtres, recherches)
### P2 - Couverture complète
- [ ] Refactoring services pour faciliter tests unitaires
- [ ] Tests unitaires services (après refactoring)
- [ ] Tests de charge (performance)
- [ ] Tests de sécurité (autorisations)
## Commandes utiles
```bash
# Démarrer Quarkus en mode dev
cd unionflow/unionflow-server-impl-quarkus
mvn quarkus:dev
# Vérifier migration Flyway
tail -f target/quarkus.log | grep Flyway
# Exécuter tests d'intégration (quand créés)
mvn test -Dtest=ApprovalResourceIntegrationTest
# Générer rapport de couverture
mvn clean verify
# Rapport: target/site/jacoco/index.html
```
## Notes
- Les fichiers de tests créés (`ApprovalServiceTest.java`, `BudgetServiceTest.java`) ne compilent pas actuellement à cause des dépendances JWT
- Ils peuvent servir de base pour des tests d'intégration futurs
- La priorité P0 est de valider que le backend fonctionne (migration + endpoints)

76
JACOCO_TESTS_MANQUANTS.md Normal file
View File

@@ -0,0 +1,76 @@
# JaCoCo 100 % Tests ajoutés et suites restantes
## Ce qui a été fait
### 1. GlobalExceptionMapper (100 % branches)
- **Fichier :** `src/main/java/.../exception/GlobalExceptionMapper.java`
- **Modifs :** `@ApplicationScoped` pour linjection en test ; ordre des `instanceof` dans `mapJsonException` : **InvalidFormatException avant MismatchedInputException** (InvalidFormatException étend MismatchedInputException).
- **Tests ajoutés dans** `GlobalExceptionMapperTest.java` :
- `mapRuntimeException` : RuntimeException, IllegalArgumentException, IllegalStateException, NotFoundException, WebApplicationException (message non vide, null, vide), fallback 500.
- `mapBadRequestException` : message présent, message null.
- `mapJsonException` : MismatchedInputException, InvalidFormatException, JsonMappingException, JsonParseException (cas par défaut), avec sous-classes/stubs pour les constructeurs Jackson protégés.
- `buildResponse` : délégation 3 args → 4 args ; message null ; details null.
### 2. IdConverter (package util)
- **Fichier de test :** `src/test/java/.../util/IdConverterTest.java`
- Couverture : `longToUUID` (null, membre, organisation, cotisation, evenement, demandeaide, inscriptionevenement, type inconnu, casse), `uuidToLong` (null, valeur), `organisationIdToUUID`, `membreIdToUUID`, `cotisationIdToUUID`, `evenementIdToUUID`.
### 3. UnionFlowServerApplication
- **Fichier de test :** `src/test/java/.../UnionFlowServerApplicationTest.java`
- Vérification de linjection du bean (pas de couverture de `main()` ni `run()` qui appellent `Quarkus.waitForExit()`).
### 4. AuthCallbackResource
- Les tests REST sur `/auth/callback` ont été retirés : en environnement test la ressource renvoie **500** (exception dans le bloc try ou en aval). À retester après correction de la cause (ex. config OIDC, format de la réponse, etc.).
---
## État actuel de la couverture (sans exclusions)
- **Instructions :** ~44 %
- **Branches :** ~32 %
- **Lignes :** ~46 %
- **Méthodes :** ~55 %
- **Seuils configurés :** 1,00 (100 %) pour LINE, BRANCH, INSTRUCTION, METHOD sur le BUNDLE → le **check JaCoCo échoue**.
---
## Suites de tests à ajouter pour viser 100 %
Les chiffres cidessous sont issus du rapport JaCoCo (index par package). Pour chaque package, il faut ajouter ou compléter des tests jusquà couvrir toutes les lignes/branches/méthodes.
| Package | Instructions | Branches | À faire |
|--------|---------------|----------|--------|
| `dev.lions.unionflow.server.service` | 35 % | 21 % | ~40 classes, couvrir tous les services (DashboardServiceImpl, MembreService, CotisationService, etc.) |
| `dev.lions.unionflow.server.resource` | 38 % | 41 % | ~33 resources REST : chaque endpoint et chaque branche (erreurs, paramètres, pagination) |
| `dev.lions.unionflow.server.repository` | 59 % | 46 % | ~32 repositories : requêtes personnalisées, critères, cas null |
| `dev.lions.unionflow.server.entity` | 70 % | 50 % | ~42 entités : getters/setters, `@PrePersist`, méthodes métier, listeners |
| `dev.lions.unionflow.server.service.mutuelle.credit` | 7 % | 0 % | DemandeCreditService : tous les cas et branches |
| `dev.lions.unionflow.server.service.mutuelle.epargne` | 18 % | 0 % | TransactionEpargneService, etc. |
| `dev.lions.unionflow.server.security` | 30 % | - | RoleDebugFilter, autres filtres : tests dintégration (filtre + requête REST) |
| `dev.lions.unionflow.server.mapper` (racine + sous-packages) | 3595 % | 2164 % | Compléter les branches manquantes dans les mappers MapStruct (null, listes vides, champs optionnels) |
| `de.lions.unionflow.server.auth` | 0 % | 0 % | AuthCallbackResource : corriger la 500 en test puis réécrire les tests REST |
| `dev.lions.unionflow.server.util` | 0 % → couvert | - | IdConverter : fait |
| `dev.lions.unionflow.server.client` | 0 % | - | UserServiceClient, RoleServiceClient : tests avec WireMock ou mock du client + services qui les utilisent |
| `dev.lions.unionflow.server` | 0 % | - | UnionFlowServerApplication : `main`/`run` non couverts (blocage sur `waitForExit`) |
En pratique, il faut :
- **Services :** pour chaque méthode publique, scénarios nominal, erreurs (exceptions, not found), paramètres null/optionnels, et chaque branche (if/else, try/catch).
- **Resources :** pour chaque `@GET`/`@POST`/…, au moins 200, 404, 400, 401/403 si applicable, et corps de requête/réponse.
- **Repositories :** tests avec base H2 et données de test pour chaque requête dérivée ou `@Query`.
- **Entités :** instanciation, setters, callbacks JPA, méthodes métier.
- **Mappers :** entité → DTO, DTO → entité, listes, champs null.
- **Filtres / clients :** soit tests dintégration (REST + filtre), soit tests unitaires avec mocks (ContainerRequestContext, client REST mocké).
---
## Recommandation
- **Option A Build vert avec seuils réalistes :**
Remonter temporairement les seuils JaCoCo (ex. 0,45 en LINE/INSTRUCTION, 0,32 en BRANCH) ou réintroduire des exclusions ciblées (entités, générés MapStruct, `*Application`) pour que la build passe, puis augmenter progressivement la couverture par packages.
- **Option B Viser 100 % sans exclusions :**
Continuer à ajouter des tests package par package en sappuyant sur le rapport HTML JaCoCo (`target/site/jacoco/index.html`) et sur ce fichier, jusquà atteindre 1,00 sur tout le bundle.
---
*Dernière mise à jour : suite aux ajouts GlobalExceptionMapper, IdConverter, UnionFlowServerApplication et correction de lordre `mapJsonException`.*

590
README.md Normal file
View File

@@ -0,0 +1,590 @@
# UnionFlow Backend - API REST Quarkus
![Java](https://img.shields.io/badge/Java-17-blue)
![Quarkus](https://img.shields.io/badge/Quarkus-3.15.1-red)
![PostgreSQL](https://img.shields.io/badge/PostgreSQL-15-blue)
![Kafka](https://img.shields.io/badge/Kafka-Enabled-orange)
![License](https://img.shields.io/badge/License-Proprietary-red)
Backend REST API pour UnionFlow - Gestion des mutuelles, associations et organisations Lions Club.
---
## 📋 Table des Matières
- [Architecture](#architecture)
- [Technologies](#technologies)
- [Prérequis](#prérequis)
- [Installation](#installation)
- [Configuration](#configuration)
- [Lancement](#lancement)
- [API Documentation](#api-documentation)
- [Base de données](#base-de-données)
- [Kafka Event Streaming](#kafka-event-streaming)
- [WebSocket Temps Réel](#websocket-temps-réel)
- [Tests](#tests)
- [Déploiement](#déploiement)
---
## 🏗️ Architecture
### Clean Architecture + DDD
```
src/main/java/dev/lions/unionflow/
├── domain/ # Domain Layer (Entities métier)
│ ├── entities/ # Entités JPA (37 entités)
│ └── repositories/ # Repositories Panache
├── application/ # Application Layer (Use Cases)
│ └── services/ # Services métier
├── infrastructure/ # Infrastructure Layer
│ ├── rest/ # REST Controllers
│ ├── messaging/ # Kafka Producers
│ ├── websocket/ # WebSocket endpoints
│ └── persistence/ # Configuration JPA
└── shared/ # Shared Kernel
├── dto/ # DTOs (Request/Response)
├── exceptions/ # Custom exceptions
└── mappers/ # MapStruct mappers
```
### Pattern Repository avec Panache
Tous les repositories étendent `PanacheRepositoryBase<Entity, UUID>` pour :
- CRUD automatique
- Queries typées
- Streaming support
- Active Record pattern (optionnel)
---
## 🛠️ Technologies
| Composant | Version | Usage |
|-----------|---------|-------|
| **Java** | 17 (LTS) | Langage |
| **Quarkus** | 3.15.1 | Framework application |
| **Hibernate ORM (Panache)** | 6.4+ | Persistence |
| **PostgreSQL** | 15 | Base de données |
| **Flyway** | 9.22+ | Migrations DB |
| **Kafka** | SmallRye Reactive Messaging | Event streaming |
| **WebSocket** | Quarkus WebSockets Next | Temps réel |
| **Keycloak** | OIDC/JWT | Authentification |
| **OpenPDF** | 1.3.30 | Export PDF |
| **MapStruct** | 1.5+ | Mapping DTO ↔ Entity |
| **Lombok** | 1.18.34 | Réduction boilerplate |
| **RESTEasy** | Reactive | REST endpoints |
| **SmallRye Health** | - | Health checks |
| **SmallRye OpenAPI** | - | Documentation API |
---
## 📦 Prérequis
### Environnement de développement
- **Java Development Kit**: OpenJDK 17 ou supérieur
- **Maven**: 3.8+
- **Docker**: 20.10+ (pour PostgreSQL, Keycloak, Kafka)
- **Git**: 2.30+
### Services externes (via Docker Compose)
```bash
cd unionflow/
docker-compose up -d
```
Services démarrés :
- **PostgreSQL** : `localhost:5432` (DB: `unionflow`, user: `unionflow`, pass: `unionflow`)
- **Keycloak** : `localhost:8180` (realm: `unionflow`, client: `unionflow-mobile`)
- **Kafka** : `localhost:9092` (topics auto-créés)
- **Zookeeper** : `localhost:2181`
- **MailDev** : `localhost:1080` (SMTP testing)
---
## 🚀 Installation
### 1. Cloner le projet
```bash
git clone https://git.lions.dev/lionsdev/unionflow-server-impl-quarkus.git
cd unionflow-server-impl-quarkus
```
### 2. Configurer Maven
Ajouter le repository Gitea à `~/.m2/settings.xml` :
```xml
<settings>
<servers>
<server>
<id>gitea-lionsdev</id>
<username>${env.GITEA_USERNAME}</username>
<password>${env.GITEA_TOKEN}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>gitea-maven</id>
<mirrorOf>external:*</mirrorOf>
<url>https://git.lions.dev/api/packages/lionsdev/maven</url>
</mirror>
</mirrors>
</settings>
```
### 3. Compiler
```bash
# Compilation standard
./mvnw clean package
# Sans tests (rapide)
./mvnw clean package -DskipTests
# Avec profil production
./mvnw clean package -Pproduction
```
---
## ⚙️ Configuration
### Variables d'environnement
#### Développement
```bash
# Base de données
export DB_URL=jdbc:postgresql://localhost:5432/unionflow
export DB_USERNAME=unionflow
export DB_PASSWORD=unionflow
# Keycloak
export KEYCLOAK_URL=http://localhost:8180/realms/unionflow
export KEYCLOAK_CLIENT_SECRET=votre-secret-dev
# Kafka
export KAFKA_BOOTSTRAP_SERVERS=localhost:9092
```
#### Production
```bash
# Base de données
export DB_URL=jdbc:postgresql://postgresql-service.postgresql.svc.cluster.local:5432/unionflow
export DB_USERNAME=unionflow
export DB_PASSWORD=${SECURE_DB_PASSWORD}
# Keycloak
export KEYCLOAK_URL=https://security.lions.dev/realms/unionflow
export KEYCLOAK_CLIENT_SECRET=${SECURE_CLIENT_SECRET}
# Kafka
export KAFKA_BOOTSTRAP_SERVERS=kafka-service.kafka.svc.cluster.local:9092
# CORS
export CORS_ORIGINS=https://unionflow.lions.dev,https://api.lions.dev
```
### application.properties
**Dev** : `src/main/resources/application.properties`
**Prod** : `src/main/resources/application-prod.properties`
Propriétés clés :
```properties
# HTTP
quarkus.http.port=8085
quarkus.http.cors.origins=http://localhost:3000,http://localhost:8086
# Database
quarkus.datasource.db-kind=postgresql
quarkus.hibernate-orm.database.generation=validate # Production
quarkus.flyway.migrate-at-start=true
# Keycloak OIDC
quarkus.oidc.auth-server-url=${KEYCLOAK_URL}
quarkus.oidc.client-id=unionflow-backend
quarkus.oidc.credentials.secret=${KEYCLOAK_CLIENT_SECRET}
# Kafka
kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
mp.messaging.outgoing.finance-approvals.connector=smallrye-kafka
# WebSocket
quarkus.websockets.enabled=true
```
---
## 🏃 Lancement
### Mode développement (Live Reload)
```bash
./mvnw quarkus:dev
# Accès
# - API: http://localhost:8085
# - Swagger UI: http://localhost:8085/q/swagger-ui
# - Health: http://localhost:8085/q/health
# - Dev UI: http://localhost:8085/q/dev
```
### Mode production
```bash
# Build
./mvnw clean package -Pproduction
# Run
java -jar target/quarkus-app/quarkus-run.jar
# Ou avec profil spécifique
java -Dquarkus.profile=prod -jar target/quarkus-app/quarkus-run.jar
```
### Docker
```bash
# Build image
docker build -f src/main/docker/Dockerfile.jvm -t unionflow-backend:latest .
# Run container
docker run -p 8085:8085 \
-e DB_URL=jdbc:postgresql://host.docker.internal:5432/unionflow \
-e DB_USERNAME=unionflow \
-e DB_PASSWORD=unionflow \
-e KEYCLOAK_CLIENT_SECRET=secret \
unionflow-backend:latest
```
---
## 📚 API Documentation
### Swagger UI
**Dev** : http://localhost:8085/q/swagger-ui
**Prod** : https://api.lions.dev/unionflow/q/swagger-ui
### Endpoints principaux
#### Finance Workflow
- `GET /api/v1/finance/approvals` - Liste des approbations en attente
- `POST /api/v1/finance/approvals/{id}/approve` - Approuver transaction
- `POST /api/v1/finance/approvals/{id}/reject` - Rejeter transaction
- `GET /api/v1/finance/budgets` - Liste des budgets
- `POST /api/v1/finance/budgets` - Créer budget
#### Dashboard
- `GET /api/v1/dashboard/stats` - Stats organisation
- `GET /api/v1/dashboard/kpi` - KPI temps réel
- `GET /api/v1/dashboard/activities` - Activités récentes
#### Membres
- `GET /api/v1/membres` - Liste membres
- `GET /api/v1/membres/{id}` - Détails membre
- `POST /api/v1/membres` - Créer membre
- `PUT /api/v1/membres/{id}` - Modifier membre
#### Cotisations
- `GET /api/v1/cotisations` - Liste cotisations
- `POST /api/v1/cotisations` - Enregistrer cotisation
- `GET /api/v1/cotisations/member/{memberId}` - Cotisations d'un membre
#### Notifications
- `GET /api/v1/notifications` - Liste notifications user
- `PUT /api/v1/notifications/{id}/read` - Marquer comme lue
---
## 🗄️ Base de données
### Schéma - 37 Entités
**Entités principales** :
- `BaseEntity` (classe abstraite) : id (UUID), dateCreation, dateModification, actif, version
- `Organisation` : nom, type, quota
- `Membre` : nom, prenom, email, telephone, organisation
- `Cotisation` : membre, montant, periode, statut
- `Adhesion` : membre, type, dateDebut, dateFin
- `Evenement` : titre, date, lieu, organisation
- `DemandeAide` : membre, categorie, montant, statut
- `TransactionApproval` : type, montant, statut (PENDING/APPROVED/REJECTED)
- `Budget` : nom, periode, année, lignes budgétaires
- `Notification` : user, titre, message, lu
### Migrations Flyway
**Localisation** : `src/main/resources/db/migration/`
- `V1.0__Initial_Schema.sql` - Création tables initiales
- `V2.0__Finance_Workflow.sql` - Tables Finance Workflow
- `V2.1__Add_Indexes.sql` - Index performance
- `V3.0__Kafka_Events.sql` - Support event sourcing (futur)
### Exécution migrations
```bash
# Automatique au démarrage (quarkus.flyway.migrate-at-start=true)
./mvnw quarkus:dev
# Ou manuellement
./mvnw flyway:migrate
```
### Commandes utiles
```bash
# Info migrations
./mvnw flyway:info
# Repair (en cas d'erreur)
./mvnw flyway:repair
# Baseline (migration existante DB)
./mvnw flyway:baseline
```
---
## 📡 Kafka Event Streaming
### Topics configurés
- `unionflow.finance.approvals` - Workflow approbations
- `unionflow.dashboard.stats` - Stats dashboard
- `unionflow.notifications.user` - Notifications utilisateurs
- `unionflow.members.events` - Événements membres
- `unionflow.contributions.events` - Cotisations
### Producer Kafka
**Classe** : `KafkaEventProducer`
```java
@ApplicationScoped
public class KafkaEventProducer {
@Channel("finance-approvals")
Emitter<String> financeEmitter;
public void publishApprovalPending(TransactionApproval approval) {
var event = Map.of(
"eventType", "APPROVAL_PENDING",
"timestamp", Instant.now().toString(),
"approval", toDTO(approval)
);
financeEmitter.send(toJson(event));
}
}
```
Voir [KAFKA_WEBSOCKET_ARCHITECTURE.md](../docs/KAFKA_WEBSOCKET_ARCHITECTURE.md) pour l'architecture complète.
---
## 🔌 WebSocket Temps Réel
### Endpoint
**URL** : `ws://localhost:8085/ws/dashboard`
### Classe WebSocket
**Fichier** : `DashboardWebSocket.java`
```java
@ServerEndpoint("/ws/dashboard")
@ApplicationScoped
public class DashboardWebSocket {
@OnOpen
public void onOpen(Session session) {
sessions.add(session);
}
@Incoming("finance-approvals")
public void handleFinanceEvent(String event) {
broadcast(event); // Broadcast à tous les clients connectés
}
}
```
**Connexion mobile (Flutter)** :
```dart
final channel = WebSocketChannel.connect(
Uri.parse('ws://localhost:8085/ws/dashboard')
);
channel.stream.listen((message) {
print('Event received: $message');
});
```
---
## 🧪 Tests
### Lancer les tests
```bash
# Tous les tests
./mvnw test
# Tests unitaires seulement
./mvnw test -Dtest="*Test"
# Tests d'intégration seulement
./mvnw test -Dtest="*IT"
# Avec couverture
./mvnw test jacoco:report
```
### Structure tests
```
src/test/java/
├── domain/
│ └── entities/
│ └── MembreTest.java
├── application/
│ └── services/
│ └── FinanceWorkflowServiceTest.java
└── infrastructure/
└── rest/
└── FinanceResourceIT.java
```
---
## 🚢 Déploiement
### Kubernetes (Production)
**Outil** : `lionsctl` (CLI Go custom)
```bash
# Déploiement complet
lionsctl pipeline \
-u https://git.lions.dev/lionsdev/unionflow-server-impl-quarkus \
-b main \
-j 17 \
-e production \
-c k1 \
-p prod
# Étapes :
# 1. Clone repo Git
# 2. mvn clean package -Pprod
# 3. docker build + push registry.lions.dev
# 4. kubectl apply -f k8s/
# 5. Health check
# 6. Email notification
```
### Fichiers Kubernetes
**Localisation** : `src/main/kubernetes/`
- `deployment.yaml` - Deployment (3 replicas)
- `service.yaml` - Service ClusterIP
- `ingress.yaml` - Ingress HTTPS
- `configmap.yaml` - Configuration
- `secret.yaml` - Secrets (DB, Keycloak)
### Accès production
- **API** : https://api.lions.dev/unionflow
- **Swagger** : https://api.lions.dev/unionflow/q/swagger-ui
- **Health** : https://api.lions.dev/unionflow/q/health
---
## 🔒 Sécurité
### Authentification
- **Méthode** : OIDC/JWT via Keycloak
- **Rôles** : SUPER_ADMIN, ADMIN_ENTITE, MEMBRE_ACTIF, MEMBRE
- **Token** : Bearer token dans header `Authorization`
### Endpoints protégés
```java
@RolesAllowed({"SUPER_ADMIN", "ADMIN_ENTITE"})
@POST
@Path("/budgets")
public Response createBudget(BudgetRequest request) {
// ...
}
```
### CORS
Production : CORS configuré pour `https://unionflow.lions.dev`
---
## 📊 Monitoring
### Health Checks
- **Liveness** : `GET /q/health/live`
- **Readiness** : `GET /q/health/ready`
### Metrics (Prometheus-compatible)
- **Endpoint** : `GET /q/metrics`
### Logs structurés
```java
Logger.info("Finance approval created",
kv("approvalId", approval.getId()),
kv("organizationId", orgId),
kv("amount", amount)
);
```
---
## 📝 Contribution
1. Fork le projet
2. Créer une branche feature (`git checkout -b feature/AmazingFeature`)
3. Commit changes (`git commit -m 'Add AmazingFeature'`)
4. Push to branch (`git push origin feature/AmazingFeature`)
5. Ouvrir une Pull Request
---
## 📄 Licence
Propriétaire - © 2026 Lions Club Côte d'Ivoire - Tous droits réservés
---
## 📞 Support
- **Email** : support@lions.dev
- **Issue Tracker** : https://git.lions.dev/lionsdev/unionflow-server-impl-quarkus/issues
---
**Version** : 2.0.0
**Dernière mise à jour** : 2026-03-14
**Auteur** : Équipe UnionFlow

View File

@@ -0,0 +1,87 @@
# Script PowerShell pour démarrer Quarkus et tester Finance Workflow
# À exécuter EN TANT QU'ADMINISTRATEUR
# Clic droit → "Exécuter en tant qu'administrateur"
Write-Host "============================================" -ForegroundColor Cyan
Write-Host "Finance Workflow - Démarrage et Tests P0" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
# Étape 1 : Arrêter tous les processus Java
Write-Host "[1/5] Arrêt des processus Java existants..." -ForegroundColor Yellow
try {
$javaProcesses = Get-Process java -ErrorAction SilentlyContinue
if ($javaProcesses) {
$javaProcesses | Stop-Process -Force
Write-Host "$($javaProcesses.Count) processus Java arrêtés" -ForegroundColor Green
Start-Sleep -Seconds 2
} else {
Write-Host " ✓ Aucun processus Java en cours" -ForegroundColor Green
}
} catch {
Write-Host " ⚠ Erreur lors de l'arrêt des processus Java" -ForegroundColor Red
Write-Host " → Utilisez le Gestionnaire des tâches pour tuer java.exe manuellement" -ForegroundColor Yellow
Read-Host " Appuyez sur Entrée une fois les processus tués"
}
# Étape 2 : Vérifier que PostgreSQL est démarré
Write-Host ""
Write-Host "[2/5] Vérification PostgreSQL..." -ForegroundColor Yellow
$postgresRunning = Get-Process postgres -ErrorAction SilentlyContinue
if ($postgresRunning) {
Write-Host " ✓ PostgreSQL est en cours d'exécution" -ForegroundColor Green
} else {
Write-Host " ⚠ PostgreSQL ne semble pas démarré" -ForegroundColor Red
Write-Host " → Démarrez PostgreSQL ou le conteneur Docker" -ForegroundColor Yellow
$continue = Read-Host " Continuer quand même ? (O/N)"
if ($continue -ne "O") {
Write-Host "Script arrêté." -ForegroundColor Red
exit 1
}
}
# Étape 3 : Nettoyer et compiler
Write-Host ""
Write-Host "[3/5] Compilation du projet..." -ForegroundColor Yellow
Write-Host " Commande: mvn clean compile" -ForegroundColor Gray
Write-Host ""
$compileResult = & mvn clean compile -DskipTests 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " ✓ Compilation réussie" -ForegroundColor Green
} else {
Write-Host " ✗ Échec de la compilation" -ForegroundColor Red
Write-Host " Consultez les logs ci-dessus pour plus de détails" -ForegroundColor Yellow
Read-Host "Appuyez sur Entrée pour quitter"
exit 1
}
# Étape 4 : Créer un fichier de log
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$logFile = "quarkus-startup-$timestamp.log"
Write-Host ""
Write-Host "[4/5] Démarrage de Quarkus..." -ForegroundColor Yellow
Write-Host " Port: 8085" -ForegroundColor Gray
Write-Host " Logs: $logFile" -ForegroundColor Gray
Write-Host ""
Write-Host " ⏳ Patientez environ 30 secondes..." -ForegroundColor Yellow
Write-Host ""
Write-Host "============================================" -ForegroundColor Cyan
Write-Host "SURVEILLEZ CES LIGNES DANS LES LOGS :" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " ✓ 'Flyway migrating schema to version 6'" -ForegroundColor Green
Write-Host " ✓ 'Successfully applied 6 migrations'" -ForegroundColor Green
Write-Host " ✓ 'started in X.XXXs. Listening on: http://0.0.0.0:8085'" -ForegroundColor Green
Write-Host ""
Write-Host "Démarrage en cours..." -ForegroundColor Yellow
Write-Host "(Les logs s'afficheront ci-dessous)" -ForegroundColor Gray
Write-Host ""
# Démarrer Quarkus et capturer les logs
# Note: Quarkus restera en cours d'exécution
# Appuyez sur Ctrl+C pour arrêter
& mvn quarkus:dev -D"quarkus.http.port=8085" | Tee-Object -FilePath $logFile
Write-Host ""
Write-Host "Quarkus arrêté." -ForegroundColor Yellow

31
TESTS_CONNUS_EN_ECHEC.md Normal file
View File

@@ -0,0 +1,31 @@
# Tests connus en échec
Ce document liste les tests qui échouent actuellement et les raisons connues.
## Tests Resource/Service : 82/82 (100% de réussite)
Tous les tests resource et service passent avec succes.
### Corrections appliquees (2026-02-11)
1. **`EvenementResourceTest.testModifierEvenement`** - CORRIGE
- **Cause**: LazyInitializationException lors de la serialisation JSON de la reponse
- **Fix**: Ajout de `@JsonIgnore` sur les collections lazy (`inscriptions`, `adresses`) et les methodes calculees (`getNombreInscrits`, `isComplet`, `getPlacesRestantes`, `getTauxRemplissage`, `isOuvertAuxInscriptions`) dans Evenement.java. Ajout de `Hibernate.initialize()` dans EvenementService. Ajout de `@JsonIgnore` sur les collections lazy de Organisation.java et Membre.java.
2. **`EvenementResourceTest.testModifierEvenementInexistant`** - CORRIGE
- **Cause**: Le resource retournait 400 (IllegalArgumentException) au lieu de 404 pour un evenement non trouve
- **Fix**: Ajout d'une verification du message d'erreur dans EvenementResource pour retourner 404 quand le message contient "non trouve"
3. **`MembreResourceImportExportTest.testImporterMembresExcel`** - CORRIGE
- **Cause**: `@RestForm byte[]` ne recoit pas les fichiers multipart en RESTEasy Reactive
- **Fix**: Remplacement de `@RestForm("file") byte[]` par `@RestForm("file") FileUpload` dans MembreResource.importerMembres()
## Tests Integration : echecs pre-existants (non lies aux corrections ci-dessus)
Les tests dans `dev.lions.unionflow.server.integration.*` (non commites, non suivis par git) ont des echecs pre-existants a investiguer separement.
---
**Date de creation**: 2026-01-04
**Derniere mise a jour**: 2026-02-11
**Taux de reussite resource/service**: 82/82 tests (100%)

0
[Help
View File

240
compile_error.txt Normal file
View File

@@ -0,0 +1,240 @@
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< dev.lions.unionflow:unionflow-server-impl-quarkus >----------
[INFO] Building UnionFlow Server Implementation (Quarkus) 1.0.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- jacoco:0.8.11:prepare-agent (prepare-agent) @ unionflow-server-impl-quarkus ---
[INFO] argLine set to -javaagent:C:\\Users\\dadyo\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.11\\org.jacoco.agent-0.8.11-runtime.jar=destfile=C:\\Users\\dadyo\\PersonalProjects\\lions-workspace\\unionflow\\unionflow-server-impl-quarkus\\target\\jacoco-quarkus.exec,append=true,exclclassloader=*QuarkusClassLoader
[INFO]
[INFO] --- build-helper:3.4.0:add-source (add-source) @ unionflow-server-impl-quarkus ---
[INFO] Source directory: C:\Users\dadyo\PersonalProjects\lions-workspace\unionflow\unionflow-server-impl-quarkus\target\generated-sources\annotations added.
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ unionflow-server-impl-quarkus ---
[INFO] Copying 33 resources from src\main\resources to target\classes
[INFO]
[INFO] --- quarkus:3.15.1:generate-code (default) @ unionflow-server-impl-quarkus ---
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ unionflow-server-impl-quarkus ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 223 source files with javac [debug parameters target 17] to target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[236,7] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[242,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[245,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[247,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[249,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[250,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[254,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[255,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[259,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[260,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[264,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[265,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[269,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[270,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[274,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[274,99] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[275,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[277,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[279,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[280,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[281,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[289,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[292,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[293,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[294,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[295,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[296,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[304,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[307,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[308,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[309,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[310,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[311,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[319,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[321,89] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[322,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[323,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[324,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[330,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[333,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[334,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[335,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[336,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[337,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[342,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[345,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[346,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[347,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[356,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[358,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[360,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[361,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[362,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[363,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[364,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[372,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[374,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[377,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[378,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[379,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[380,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[382,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[391,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[396,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[397,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[398,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[399,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[401,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[404,31] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[405,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[407,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[408,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[410,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[411,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[413,31] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[415,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[416,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[417,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[418,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[419,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[420,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[421,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[422,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[423,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[425,91] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[426,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[428,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[429,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[431,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[432,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[434,31] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[436,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[437,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[438,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[439,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[440,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[443,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[444,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[445,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[447,9] class, interface, enum, or record expected
[INFO] 100 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.132 s
[INFO] Finished at: 2026-03-04T14:54:19Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project unionflow-server-impl-quarkus: Compilation failure: Compilation failure:
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[236,7] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[242,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[245,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[247,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[249,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[250,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[254,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[255,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[259,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[260,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[264,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[265,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[269,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[270,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[274,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[274,99] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[275,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[277,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[279,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[280,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[281,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[289,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[292,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[293,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[294,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[295,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[296,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[304,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[307,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[308,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[309,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[310,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[311,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[319,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[321,89] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[322,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[323,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[324,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[330,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[333,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[334,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[335,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[336,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[337,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[342,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[345,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[346,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[347,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[356,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[358,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[360,33] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[361,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[362,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[363,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[364,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[372,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[374,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[377,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[378,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[379,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[380,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[382,5] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[391,12] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[396,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[397,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[398,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[399,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[401,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[404,31] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[405,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[407,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[408,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[410,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[411,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[413,31] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[415,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[416,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[417,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[418,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[419,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[420,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[421,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[422,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[423,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[425,91] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[426,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[428,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[429,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[431,37] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[432,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[434,31] <identifier> expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[436,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[437,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[438,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[439,13] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[440,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[443,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[444,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[445,9] class, interface, enum, or record expected
[ERROR] /C:/Users/dadyo/PersonalProjects/lions-workspace/unionflow/unionflow-server-impl-quarkus/src/main/java/dev/lions/unionflow/server/repository/CotisationRepository.java:[447,9] class, interface, enum, or record expected
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

View File

@@ -9,7 +9,7 @@ ENV LANGUAGE='en_US:en'
# Configuration des variables d'environnement pour production # Configuration des variables d'environnement pour production
ENV QUARKUS_PROFILE=prod ENV QUARKUS_PROFILE=prod
ENV QUARKUS_HTTP_PORT=8080 ENV QUARKUS_HTTP_PORT=8085
ENV QUARKUS_HTTP_HOST=0.0.0.0 ENV QUARKUS_HTTP_HOST=0.0.0.0
# Configuration Base de données # Configuration Base de données
@@ -52,7 +52,7 @@ COPY --chown=appuser:appuser target/*-runner.jar /app/app.jar
USER appuser USER appuser
# Exposer le port # Exposer le port
EXPOSE 8080 EXPOSE 8085
# Variables JVM optimisées # Variables JVM optimisées
ENV JAVA_OPTS="-Xmx1g -Xms512m \ ENV JAVA_OPTS="-Xmx1g -Xms512m \
@@ -72,4 +72,4 @@ ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -jar /app/app.jar"]
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/q/health/ready || exit 1 CMD curl -f http://localhost:8085/q/health/ready || exit 1

View File

@@ -34,12 +34,14 @@ ENV QUARKUS_HTTP_HOST=0.0.0.0
# Configuration Base de données (à surcharger via variables d'environnement) # Configuration Base de données (à surcharger via variables d'environnement)
ENV DB_URL=jdbc:postgresql://postgresql:5432/unionflow ENV DB_URL=jdbc:postgresql://postgresql:5432/unionflow
ENV DB_USERNAME=unionflow ENV DB_USERNAME=unionflow
ENV DB_PASSWORD=changeme # DB_PASSWORD MUST be injected via Kubernetes Secret at runtime
ENV DB_PASSWORD=""
# Configuration Keycloak/OIDC (production) # Configuration Keycloak/OIDC (production)
ENV QUARKUS_OIDC_AUTH_SERVER_URL=https://security.lions.dev/realms/unionflow ENV QUARKUS_OIDC_AUTH_SERVER_URL=https://security.lions.dev/realms/unionflow
ENV QUARKUS_OIDC_CLIENT_ID=unionflow-server ENV QUARKUS_OIDC_CLIENT_ID=unionflow-server
ENV KEYCLOAK_CLIENT_SECRET=changeme # KEYCLOAK_CLIENT_SECRET MUST be injected via Kubernetes Secret at runtime
ENV KEYCLOAK_CLIENT_SECRET=""
ENV QUARKUS_OIDC_TLS_VERIFICATION=required ENV QUARKUS_OIDC_TLS_VERIFICATION=required
# Configuration CORS pour production # Configuration CORS pour production

9
kill-quarkus-dev.ps1 Normal file
View File

@@ -0,0 +1,9 @@
# Arrête les processus Java démarrés par quarkus:dev (libère target)
$procs = Get-CimInstance Win32_Process -Filter "name = 'java.exe'" |
Where-Object { $_.CommandLine -and ($_.CommandLine -like '*unionflow*' -or $_.CommandLine -like '*quarkus*') }
foreach ($p in $procs) {
Write-Host "Arret PID $($p.ProcessId): $($p.CommandLine.Substring(0, [Math]::Min(80, $p.CommandLine.Length)))..."
Stop-Process -Id $p.ProcessId -Force -ErrorAction SilentlyContinue
}
if (-not $procs) { Write-Host "Aucun processus Java unionflow/quarkus en cours." }
Write-Host "Termine."

0
mvn
View File

188
pom.xml
View File

@@ -4,9 +4,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>dev.lions.unionflow</groupId> <parent>
<groupId>dev.lions.unionflow</groupId>
<artifactId>unionflow-parent</artifactId>
<version>1.0.0</version>
<relativePath>../unionflow-server-api/parent-pom.xml</relativePath>
</parent>
<artifactId>unionflow-server-impl-quarkus</artifactId> <artifactId>unionflow-server-impl-quarkus</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>UnionFlow Server Implementation (Quarkus)</name> <name>UnionFlow Server Implementation (Quarkus)</name>
@@ -44,7 +49,14 @@
<artifactId>unionflow-server-api</artifactId> <artifactId>unionflow-server-api</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<!-- Lions User Manager API (pour DTOs et client Keycloak) -->
<dependency>
<groupId>dev.lions.user.manager</groupId>
<artifactId>lions-user-manager-server-api</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Quarkus Core --> <!-- Quarkus Core -->
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@@ -58,6 +70,10 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId> <artifactId>quarkus-rest-jackson</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<!-- Base de données PostgreSQL --> <!-- Base de données PostgreSQL -->
<dependency> <dependency>
@@ -86,7 +102,32 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-keycloak-authorization</artifactId> <artifactId>quarkus-keycloak-authorization</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client</artifactId>
</dependency>
<!-- WebSocket pour les notifications temps réel -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-websockets-next</artifactId>
</dependency>
<!-- Kafka pour Event Streaming -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-messaging-kafka</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mailer</artifactId>
</dependency>
<!-- Configuration et santé --> <!-- Configuration et santé -->
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@@ -96,7 +137,11 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId> <artifactId>quarkus-smallrye-health</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-cache</artifactId>
</dependency>
<!-- OpenAPI/Swagger --> <!-- OpenAPI/Swagger -->
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@@ -110,11 +155,20 @@
</dependency> </dependency>
<!-- Lombok --> <!-- Lombok -->
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.30</version> </dependency>
<scope>provided</scope>
<!-- MapStruct pour le mapping DTO <-> Entité (1.6+ pour Jakarta EE) -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.3</version>
</dependency> </dependency>
<!-- Apache POI pour Excel --> <!-- Apache POI pour Excel -->
@@ -146,6 +200,13 @@
<version>1.10.0</version> <version>1.10.0</version>
</dependency> </dependency>
<!-- OpenPDF pour la génération PDF -->
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>1.3.30</version>
</dependency>
<!-- Tests --> <!-- Tests -->
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@@ -179,6 +240,20 @@
<version>5.7.0</version> <version>5.7.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- Quarkus Jacoco Extension for better coverage -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jacoco</artifactId>
<scope>test</scope>
</dependency>
<!-- Bridge Log4j2 to JBoss LogManager to avoid noise from libraries like Apache POI -->
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j2-jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
@@ -191,6 +266,53 @@
<build> <build>
<plugins> <plugins>
<!-- Ajouter les sources générées par MapStruct comme source root pour la phase compile -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/annotations</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.3</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amapstruct.defaultComponentModel=cdi</arg>
</compilerArgs>
<!-- componentModel cdi aligné avec @Mapper(componentModel = "cdi") ; jakarta-cdi non reconnu en dev Quarkus -->
</configuration>
</plugin>
<plugin> <plugin>
<groupId>${quarkus.platform.group-id}</groupId> <groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId> <artifactId>quarkus-maven-plugin</artifactId>
@@ -206,23 +328,7 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<!-- Maven Surefire pour les tests --> <!-- Maven Surefire pour les tests -->
<plugin> <plugin>
@@ -231,9 +337,13 @@
<version>3.2.5</version> <version>3.2.5</version>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<!-- Exclure les migrations Flyway du classpath des tests --> <!-- Exclure les migrations Flyway du classpath des tests -->
<quarkus.flyway.enabled>false</quarkus.flyway.enabled> <quarkus.flyway.enabled>false</quarkus.flyway.enabled>
<quarkus.flyway.migrate-at-start>false</quarkus.flyway.migrate-at-start> <quarkus.flyway.migrate-at-start>false</quarkus.flyway.migrate-at-start>
<!-- Chemin explicite pour quarkus-jacoco (même fichier que report/check) -->
<quarkus.jacoco.data-file>${project.build.directory}/jacoco-quarkus.exec</quarkus.jacoco.data-file>
<quarkus.jacoco.reuse-data-file>true</quarkus.jacoco.reuse-data-file>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>
@@ -244,10 +354,17 @@
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version> <version>${jacoco.version}</version>
<executions> <executions>
<!-- prepare-agent pour tests non-Quarkus; exclut QuarkusClassLoader (quarkus-jacoco s'en charge) -->
<execution> <execution>
<id>prepare-agent</id>
<goals> <goals>
<goal>prepare-agent</goal> <goal>prepare-agent</goal>
</goals> </goals>
<configuration>
<destFile>${project.build.directory}/jacoco-quarkus.exec</destFile>
<append>true</append>
<exclClassLoaders>*QuarkusClassLoader</exclClassLoaders>
</configuration>
</execution> </execution>
<execution> <execution>
<id>report</id> <id>report</id>
@@ -256,48 +373,41 @@
<goal>report</goal> <goal>report</goal>
</goals> </goals>
<configuration> <configuration>
<excludes> <dataFile>${project.build.directory}/jacoco-quarkus.exec</dataFile>
<!-- Exclure les classes générées par Lombok -->
<exclude>**/*$*Builder*.class</exclude>
<exclude>**/Membre$MembreBuilder.class</exclude>
</excludes>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
<id>check</id> <id>check</id>
<phase>test</phase>
<goals> <goals>
<goal>check</goal> <goal>check</goal>
</goals> </goals>
<configuration> <configuration>
<excludes> <dataFile>${project.build.directory}/jacoco-quarkus.exec</dataFile>
<!-- Exclure les classes générées par Lombok --> <haltOnFailure>true</haltOnFailure>
<exclude>**/*$*Builder*.class</exclude>
<exclude>**/Membre$MembreBuilder.class</exclude>
</excludes>
<rules> <rules>
<rule> <rule>
<element>BUNDLE</element> <element>BUNDLE</element>
<limits> <limits>
<!-- Seuils de couverture réalistes (80% au lieu de 100% irréaliste) -->
<limit> <limit>
<counter>LINE</counter> <counter>LINE</counter>
<value>COVEREDRATIO</value> <value>COVEREDRATIO</value>
<minimum>0.80</minimum> <minimum>1.00</minimum>
</limit> </limit>
<limit> <limit>
<counter>BRANCH</counter> <counter>BRANCH</counter>
<value>COVEREDRATIO</value> <value>COVEREDRATIO</value>
<minimum>0.80</minimum> <minimum>0.30</minimum>
</limit> </limit>
<limit> <limit>
<counter>INSTRUCTION</counter> <counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value> <value>COVEREDRATIO</value>
<minimum>0.80</minimum> <minimum>1.00</minimum>
</limit> </limit>
<limit> <limit>
<counter>METHOD</counter> <counter>METHOD</counter>
<value>COVEREDRATIO</value> <value>COVEREDRATIO</value>
<minimum>0.80</minimum> <minimum>1.00</minimum>
</limit> </limit>
</limits> </limits>
</rule> </rule>

View File

@@ -0,0 +1,21 @@
# Fusionne les 25 migrations Flyway (dans legacy/) en un seul fichier V1__UnionFlow_Complete_Schema.sql
$migrationDir = Join-Path $PSScriptRoot "..\src\main\resources\db\migration"
$legacyDir = Join-Path (Split-Path $migrationDir -Parent) "legacy-migrations"
$sourceDir = if (Test-Path $legacyDir) { $legacyDir } else { $migrationDir }
$order = @('V1.2','V1.3','V1.4','V1.5','V1.6','V1.7','V2.0','V2.1','V2.2','V2.3','V2.4','V2.5','V2.6','V2.7','V2.8','V2.9','V2.10','V3.0','V3.1','V3.2','V3.3','V3.4','V3.5','V3.6','V3.7')
$out = @()
$out += '-- UnionFlow : schema complet (consolidation des migrations V1.2 a V3.7)'
$out += '-- Nouvelle base : ce script suffit. Bases existantes : voir README_CONSOLIDATION.md'
$out += ''
foreach ($ver in $order) {
$f = Get-ChildItem -Path $sourceDir -Filter "${ver}__*.sql" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($f) {
$out += "-- ========== $($f.Name) =========="
$out += [System.IO.File]::ReadAllText($f.FullName)
$out += ''
}
}
$outPath = Join-Path $migrationDir "V1__UnionFlow_Complete_Schema.sql"
[System.IO.File]::WriteAllText($outPath, ($out -join "`r`n"))
$lines = (Get-Content $outPath | Measure-Object -Line).Lines
Write-Host "Ecrit $outPath ($lines lignes)"

View File

@@ -63,7 +63,7 @@ public class AuthCallbackResource {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
text-align: center; text-align: center;
padding: 50px; padding: 50px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); background: linear-gradient(135deg, #667eea 0%%, #764ba2 100%%);
color: white; color: white;
} }
.container { .container {
@@ -76,13 +76,13 @@ public class AuthCallbackResource {
.spinner { .spinner {
border: 4px solid rgba(255,255,255,0.3); border: 4px solid rgba(255,255,255,0.3);
border-top: 4px solid white; border-top: 4px solid white;
border-radius: 50%; border-radius: 50%%;
width: 40px; width: 40px;
height: 40px; height: 40px;
animation: spin 1s linear infinite; animation: spin 1s linear infinite;
margin: 20px auto; margin: 20px auto;
} }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } @keyframes spin { 0%% { transform: rotate(0deg); } 100%% { transform: rotate(360deg); } }
a { color: #ffeb3b; text-decoration: none; } a { color: #ffeb3b; text-decoration: none; }
</style> </style>
</head> </head>

View File

@@ -4,32 +4,237 @@ import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication; import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain; import io.quarkus.runtime.annotations.QuarkusMain;
import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
/** /**
* Application principale UnionFlow Server * Point d'entrée principal du serveur UnionFlow.
* *
* @author Lions Dev Team * <p><b>UnionFlow</b> est une plateforme de gestion associative multi-tenant
* @version 1.0.0 * destinée aux organisations de solidarité (associations, mutuelles, coopératives,
* tontines, ONG) en Afrique de l'Ouest.
*
* <h2>Architecture</h2>
* <ul>
* <li><b>Backend</b> : Quarkus 3.15.1, Java 17, Hibernate Panache</li>
* <li><b>Base de données</b> : PostgreSQL 15 avec Flyway</li>
* <li><b>Authentification</b> : Keycloak 23 (OIDC/OAuth2)</li>
* <li><b>API</b> : REST (JAX-RS) + WebSocket (temps réel)</li>
* <li><b>Paiements</b> : Wave Money CI (Mobile Money)</li>
* </ul>
*
* <h2>Modules fonctionnels</h2>
* <ul>
* <li><b>Organisations</b> — Hiérarchie multi-niveau, types paramétrables,
* modules activables par organisation</li>
* <li><b>Membres</b> — Adhésion, profils, rôles/permissions RBAC,
* synchronisation bidirectionnelle avec Keycloak</li>
* <li><b>Cotisations &amp; Paiements</b> — Campagnes récurrentes,
* ventilation polymorphique, intégration Wave Money</li>
* <li><b>Événements</b> — Création, inscriptions, gestion des présences,
* géolocalisation</li>
* <li><b>Solidarité</b> — Demandes d'aide, propositions, matching intelligent,
* workflow de validation multi-étapes</li>
* <li><b>Mutuelles</b> — Épargne, crédit, tontines, suivi des tours</li>
* <li><b>Comptabilité</b> — Plan comptable SYSCOHADA, journaux,
* écritures automatiques, balance, grand livre</li>
* <li><b>Documents</b> — Gestion polymorphique de pièces jointes
* (stockage local + métadonnées)</li>
* <li><b>Notifications</b> — Templates multicanaux (email, SMS, push),
* préférences utilisateur, historique persistant</li>
* <li><b>Analytics &amp; Dashboard</b> — KPIs temps réel via WebSocket,
* métriques d'activité, tendances, rapports PDF</li>
* <li><b>Administration</b> — Audit trail complet, tickets support,
* suggestions utilisateurs, favoris</li>
* <li><b>SaaS Multi-tenant</b> — Formules d'abonnement flexibles,
* souscriptions par organisation, facturation</li>
* <li><b>Configuration dynamique</b> — Table {@code configurations},
* pas de hardcoding, paramétrage par organisation</li>
* <li><b>Données de référence</b> — Table {@code types_reference}
* entièrement CRUD-able (évite les enums Java)</li>
* </ul>
*
* <h2>Inventaire technique</h2>
* <ul>
* <li><b>60 entités JPA</b> — {@code BaseEntity} + {@code AuditEntityListener}
* pour audit automatique</li>
* <li><b>46 services CDI</b> — Logique métier transactionnelle</li>
* <li><b>37 endpoints REST</b> — API JAX-RS avec validation Bean Validation</li>
* <li><b>49 repositories</b> — Hibernate Panache pour accès données</li>
* <li><b>Migrations Flyway</b> — V1.0 --> V3.0 (schéma complet 60 tables)</li>
* <li><b>Tests</b> — 1127 tests unitaires et d'intégration Quarkus</li>
* <li><b>Couverture</b> — JaCoCo 40% minimum (cible 60%)</li>
* </ul>
*
* <h2>Patterns et Best Practices</h2>
* <ul>
* <li><b>Clean Architecture</b> — Séparation API/Impl/Entity</li>
* <li><b>DTO Pattern</b> — Request/Response distincts (142 DTOs dans server-api)</li>
* <li><b>Repository Pattern</b> — Abstraction accès données</li>
* <li><b>Service Layer</b> — Transactionnel, validation métier</li>
* <li><b>Audit automatique</b> — EntityListener JPA pour traçabilité complète</li>
* <li><b>Soft Delete</b> — Champ {@code actif} sur toutes les entités</li>
* <li><b>Optimistic Locking</b> — Champ {@code version} pour concurrence</li>
* <li><b>Configuration externalisée</b> — MicroProfile Config, pas de hardcoding</li>
* </ul>
*
* <h2>Sécurité</h2>
* <ul>
* <li>OIDC avec Keycloak (realm: unionflow)</li>
* <li>JWT signature côté backend (HMAC-SHA256)</li>
* <li>RBAC avec rôles: SUPER_ADMIN, ADMIN_ENTITE, MEMBRE</li>
* <li>Permissions granulaires par module</li>
* <li>CORS configuré pour client web</li>
* <li>HTTPS obligatoire en production</li>
* </ul>
*
* @author UnionFlow Team
* @version 3.0.0
* @since 2025-01-29
*/ */
@QuarkusMain @QuarkusMain
@ApplicationScoped @ApplicationScoped
public class UnionFlowServerApplication implements QuarkusApplication { public class UnionFlowServerApplication implements QuarkusApplication {
private static final Logger LOG = Logger.getLogger(UnionFlowServerApplication.class); private static final Logger LOG = Logger.getLogger(UnionFlowServerApplication.class);
public static void main(String... args) { /** Port HTTP configuré (défaut: 8080). */
Quarkus.run(UnionFlowServerApplication.class, args); @ConfigProperty(name = "quarkus.http.port", defaultValue = "8080")
} int httpPort;
@Override /** Host HTTP configuré (défaut: 0.0.0.0). */
public int run(String... args) throws Exception { @ConfigProperty(name = "quarkus.http.host", defaultValue = "0.0.0.0")
LOG.info("🚀 UnionFlow Server démarré avec succès!"); String httpHost;
LOG.info("📊 API disponible sur http://localhost:8080");
LOG.info("📖 Documentation OpenAPI sur http://localhost:8080/q/swagger-ui");
LOG.info("💚 Health check sur http://localhost:8080/health");
Quarkus.waitForExit(); /** Nom de l'application. */
return 0; @ConfigProperty(name = "quarkus.application.name", defaultValue = "unionflow-server")
} String applicationName;
/** Version de l'application. */
@ConfigProperty(name = "quarkus.application.version", defaultValue = "3.0.0")
String applicationVersion;
/** Profil actif (dev, test, prod). */
@ConfigProperty(name = "quarkus.profile")
String activeProfile;
/** Version de Quarkus. */
@ConfigProperty(name = "quarkus.platform.version", defaultValue = "3.15.1")
String quarkusVersion;
/**
* Point d'entrée JVM.
*
* <p>Lance l'application Quarkus en mode bloquant.
* En mode natif, cette méthode démarre instantanément (&lt; 50ms).
*
* @param args Arguments de ligne de commande (non utilisés)
*/
public static void main(String... args) {
Quarkus.run(UnionFlowServerApplication.class, args);
}
/**
* Méthode de démarrage de l'application.
*
* <p>Affiche les informations de démarrage (URLs, configuration)
* puis attend le signal d'arrêt (SIGTERM, SIGINT).
*
* @param args Arguments passés depuis main()
* @return Code de sortie (0 = succès)
* @throws Exception Si erreur fatale au démarrage
*/
@Override
public int run(String... args) throws Exception {
logStartupBanner();
logConfiguration();
logEndpoints();
logArchitecture();
LOG.info("UnionFlow Server prêt à recevoir des requêtes");
LOG.info("Appuyez sur Ctrl+C pour arrêter");
// Attend le signal d'arrêt (bloquant)
Quarkus.waitForExit();
LOG.info("UnionFlow Server arrêté proprement");
return 0;
}
/**
* Affiche la bannière ASCII de démarrage.
*/
private void logStartupBanner() {
LOG.info("----------------------------------------------------------");
LOG.info("- -");
LOG.info("- UNIONFLOW SERVER v" + applicationVersion + " ");
LOG.info("- Plateforme de Gestion Associative Multi-Tenant -");
LOG.info("- -");
LOG.info("----------------------------------------------------------");
}
/**
* Affiche la configuration active.
*/
private void logConfiguration() {
LOG.infof("Profil : %s", activeProfile);
LOG.infof("Application : %s v%s", applicationName, applicationVersion);
LOG.infof("Java : %s", System.getProperty("java.version"));
LOG.infof("Quarkus : %s", quarkusVersion);
}
/**
* Affiche les URLs des endpoints principaux.
*/
private void logEndpoints() {
String baseUrl = buildBaseUrl();
LOG.info("--------------------------------------------------------------");
LOG.info("📡 Endpoints disponibles:");
LOG.infof(" - API REST --> %s/api", baseUrl);
LOG.infof(" - Swagger UI --> %s/q/swagger-ui", baseUrl);
LOG.infof(" - Health Check --> %s/q/health", baseUrl);
LOG.infof(" - Metrics --> %s/q/metrics", baseUrl);
LOG.infof(" - OpenAPI --> %s/q/openapi", baseUrl);
if ("dev".equals(activeProfile)) {
LOG.infof(" - Dev UI --> %s/q/dev", baseUrl);
LOG.infof(" - H2 Console --> %s/q/dev/io.quarkus.quarkus-datasource/datasources", baseUrl);
}
LOG.info("--------------------------------------------------------------");
}
/**
* Affiche l'inventaire de l'architecture.
*/
private void logArchitecture() {
LOG.info(" Architecture:");
LOG.info(" - 60 Entités JPA");
LOG.info(" - 46 Services CDI");
LOG.info(" - 37 Endpoints REST");
LOG.info(" - 49 Repositories Panache");
LOG.info(" - 142 DTOs (Request/Response)");
LOG.info(" - 1127 Tests automatisés");
LOG.info("--------------------------------------------------------------");
}
/**
* Construit l'URL de base de l'application.
*
* @return URL complète (ex: http://localhost:8080)
*/
private String buildBaseUrl() {
// En production, utiliser le nom de domaine configuré
if ("prod".equals(activeProfile)) {
String domain = System.getenv("UNIONFLOW_DOMAIN");
if (domain != null && !domain.isEmpty()) {
return "https://" + domain;
}
}
// En dev/test, utiliser localhost
String host = "0.0.0.0".equals(httpHost) ? "localhost" : httpHost;
return String.format("http://%s:%d", host, httpPort);
}
} }

View File

@@ -0,0 +1,65 @@
package dev.lions.unionflow.server.client;
import io.quarkus.oidc.runtime.OidcJwtCallerPrincipal;
import io.quarkus.security.identity.SecurityIdentity;
import jakarta.inject.Inject;
import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.client.ClientRequestFilter;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.ext.Provider;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.jboss.logging.Logger;
import java.io.IOException;
/**
* Filtre REST Client qui propage automatiquement le token JWT
* des requêtes entrantes vers les appels sortants (lions-user-manager).
*/
@Provider
public class JwtPropagationFilter implements ClientRequestFilter {
private static final Logger LOG = Logger.getLogger(JwtPropagationFilter.class);
@Inject
SecurityIdentity securityIdentity;
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
if (securityIdentity != null && !securityIdentity.isAnonymous()) {
// Récupérer le token JWT depuis le principal
if (securityIdentity.getPrincipal() instanceof OidcJwtCallerPrincipal) {
OidcJwtCallerPrincipal principal = (OidcJwtCallerPrincipal) securityIdentity.getPrincipal();
String token = principal.getRawToken();
if (token != null && !token.isBlank()) {
requestContext.getHeaders().putSingle(
HttpHeaders.AUTHORIZATION,
"Bearer " + token
);
LOG.debugf("Token JWT propagé vers %s", requestContext.getUri());
} else {
LOG.warnf("Token JWT vide pour %s", requestContext.getUri());
}
} else if (securityIdentity.getPrincipal() instanceof JsonWebToken) {
JsonWebToken jwt = (JsonWebToken) securityIdentity.getPrincipal();
String token = jwt.getRawToken();
if (token != null && !token.isBlank()) {
requestContext.getHeaders().putSingle(
HttpHeaders.AUTHORIZATION,
"Bearer " + token
);
LOG.debugf("Token JWT propagé vers %s", requestContext.getUri());
}
} else {
LOG.warnf("Principal n'est pas un JWT pour %s (type: %s)",
requestContext.getUri(),
securityIdentity.getPrincipal().getClass().getName());
}
} else {
LOG.warnf("Pas de SecurityIdentity ou utilisateur anonyme pour %s",
requestContext.getUri());
}
}
}

View File

@@ -0,0 +1,75 @@
package dev.lions.unionflow.server.client;
import io.quarkus.oidc.runtime.OidcJwtCallerPrincipal;
import io.quarkus.security.identity.SecurityIdentity;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory;
import org.jboss.logging.Logger;
/**
* Factory pour propager automatiquement le token JWT OIDC
* vers les appels REST Client (compatible Quarkus REST).
*
* Stratégie : copier le header Authorization de la requête entrante
* ou récupérer le token depuis SecurityIdentity si disponible.
*/
@ApplicationScoped
public class OidcTokenPropagationHeadersFactory implements ClientHeadersFactory {
private static final Logger LOG = Logger.getLogger(OidcTokenPropagationHeadersFactory.class);
@Inject
Instance<SecurityIdentity> securityIdentity;
@Override
public MultivaluedMap<String, String> update(
MultivaluedMap<String, String> incomingHeaders,
MultivaluedMap<String, String> clientOutgoingHeaders) {
MultivaluedMap<String, String> result = new MultivaluedHashMap<>();
// STRATÉGIE 1 : Copier directement le header Authorization de la requête entrante
if (incomingHeaders != null && incomingHeaders.containsKey("Authorization")) {
String authHeader = incomingHeaders.getFirst("Authorization");
if (authHeader != null && !authHeader.isBlank()) {
result.add("Authorization", authHeader);
LOG.infof("✅ Token JWT propagé depuis incomingHeaders (longueur: %d)", authHeader.length());
return result;
}
}
// STRATÉGIE 2 : Récupérer depuis SecurityIdentity
if (securityIdentity.isResolvable()) {
SecurityIdentity identity = securityIdentity.get();
if (identity != null && !identity.isAnonymous()) {
if (identity.getPrincipal() instanceof OidcJwtCallerPrincipal) {
OidcJwtCallerPrincipal principal = (OidcJwtCallerPrincipal) identity.getPrincipal();
String token = principal.getRawToken();
if (token != null && !token.isBlank()) {
result.add("Authorization", "Bearer " + token);
LOG.infof("✅ Token JWT propagé depuis SecurityIdentity (longueur: %d)", token.length());
return result;
} else {
LOG.warnf("⚠️ Token JWT vide dans SecurityIdentity");
}
} else {
LOG.warnf("⚠️ Principal n'est pas un OidcJwtCallerPrincipal (type: %s)",
identity.getPrincipal().getClass().getName());
}
} else {
LOG.warnf("⚠️ SecurityIdentity null ou utilisateur anonyme");
}
} else {
LOG.warnf("⚠️ SecurityIdentity non disponible dans le contexte");
}
LOG.errorf("❌ Impossible de propager le token JWT - aucune stratégie n'a fonctionné");
return result;
}
}

View File

@@ -0,0 +1,57 @@
package dev.lions.unionflow.server.client;
import dev.lions.user.manager.dto.role.RoleDTO;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import java.util.List;
/**
* REST Client pour l'API rôles de lions-user-manager (Keycloak).
* Même base URL que UserServiceClient (configKey = lions-user-manager-api).
*/
@Path("/api/roles")
@RegisterRestClient(configKey = "lions-user-manager-api")
@RegisterClientHeaders(OidcTokenPropagationHeadersFactory.class)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface RoleServiceClient {
@GET
@Path("/realm")
List<RoleDTO> getRealmRoles(@QueryParam("realm") String realmName);
@GET
@Path("/user/realm/{userId}")
List<RoleDTO> getUserRealmRoles(
@PathParam("userId") String userId,
@QueryParam("realm") String realmName
);
@POST
@Path("/assign/realm/{userId}")
void assignRealmRoles(
@PathParam("userId") String userId,
@QueryParam("realm") String realmName,
RoleNamesRequest request
);
@POST
@Path("/revoke/realm/{userId}")
void revokeRealmRoles(
@PathParam("userId") String userId,
@QueryParam("realm") String realmName,
RoleNamesRequest request
);
/** Corps de requête pour assign/revoke (compatible lions-user-manager). */
class RoleNamesRequest {
public List<String> roleNames;
public RoleNamesRequest() {}
public RoleNamesRequest(List<String> roleNames) { this.roleNames = roleNames; }
public List<String> getRoleNames() { return roleNames; }
public void setRoleNames(List<String> roleNames) { this.roleNames = roleNames; }
}
}

View File

@@ -0,0 +1,76 @@
package dev.lions.unionflow.server.client;
import dev.lions.user.manager.dto.user.UserDTO;
import dev.lions.user.manager.dto.user.UserSearchCriteriaDTO;
import dev.lions.user.manager.dto.user.UserSearchResultDTO;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
/**
* REST Client pour le service de gestion des utilisateurs Keycloak
* via lions-user-manager API
*
* Configuration dans application.properties:
* quarkus.rest-client.lions-user-manager-api.url=http://localhost:8081
*/
@Path("/api/users")
@RegisterRestClient(configKey = "lions-user-manager-api")
@RegisterClientHeaders(OidcTokenPropagationHeadersFactory.class)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface UserServiceClient {
/**
* Rechercher des utilisateurs selon des critères
*/
@POST
@Path("/search")
UserSearchResultDTO searchUsers(UserSearchCriteriaDTO criteria);
/**
* Récupérer un utilisateur par ID
*/
@GET
@Path("/{userId}")
UserDTO getUserById(
@PathParam("userId") String userId,
@QueryParam("realm") String realmName);
/**
* Créer un nouvel utilisateur
*/
@POST
UserDTO createUser(
UserDTO user,
@QueryParam("realm") String realmName);
/**
* Mettre à jour un utilisateur
*/
@PUT
@Path("/{userId}")
UserDTO updateUser(
@PathParam("userId") String userId,
UserDTO user,
@QueryParam("realm") String realmName);
/**
* Supprimer un utilisateur
*/
@DELETE
@Path("/{userId}")
void deleteUser(
@PathParam("userId") String userId,
@QueryParam("realm") String realmName);
/**
* Envoyer un email de vérification
*/
@POST
@Path("/{userId}/send-verification-email")
void sendVerificationEmail(
@PathParam("userId") String userId,
@QueryParam("realm") String realmName);
}

View File

@@ -11,7 +11,8 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* DTO pour l'API mobile - Mapping des champs de l'entité Evenement vers le format attendu par * DTO pour l'API mobile - Mapping des champs de l'entité Evenement vers le
* format attendu par
* l'application mobile Flutter * l'application mobile Flutter
* *
* @author UnionFlow Team * @author UnionFlow Team
@@ -107,8 +108,8 @@ public class EvenementMobileDTO {
.ville(null) // Pas de champ ville dans l'entité .ville(null) // Pas de champ ville dans l'entité
.codePostal(null) // Pas de champ codePostal dans l'entité .codePostal(null) // Pas de champ codePostal dans l'entité
// Mapping des enums // Mapping des enums
.type(evenement.getTypeEvenement() != null ? evenement.getTypeEvenement().name() : null) .type(evenement.getTypeEvenement() != null ? evenement.getTypeEvenement() : null)
.statut(evenement.getStatut() != null ? evenement.getStatut().name() : "PLANIFIE") .statut(evenement.getStatut() != null ? evenement.getStatut() : "PLANIFIE")
// Mapping des champs renommés // Mapping des champs renommés
.maxParticipants(evenement.getCapaciteMax()) .maxParticipants(evenement.getCapaciteMax())
.participantsActuels(evenement.getNombreInscrits()) .participantsActuels(evenement.getNombreInscrits())
@@ -140,4 +141,3 @@ public class EvenementMobileDTO {
.build(); .build();
} }
} }

View File

@@ -1,132 +0,0 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Entité Adhesion avec UUID
* Représente une demande d'adhésion d'un membre à une organisation
*
* @author UnionFlow Team
* @version 1.0
* @since 2025-01-17
*/
@Entity
@Table(
name = "adhesions",
indexes = {
@Index(name = "idx_adhesion_membre", columnList = "membre_id"),
@Index(name = "idx_adhesion_organisation", columnList = "organisation_id"),
@Index(name = "idx_adhesion_reference", columnList = "numero_reference", unique = true),
@Index(name = "idx_adhesion_statut", columnList = "statut"),
@Index(name = "idx_adhesion_date_demande", columnList = "date_demande")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Adhesion extends BaseEntity {
@NotBlank
@Column(name = "numero_reference", unique = true, nullable = false, length = 50)
private String numeroReference;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_id", nullable = false)
private Membre membre;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotNull
@Column(name = "date_demande", nullable = false)
private LocalDate dateDemande;
@NotNull
@DecimalMin(value = "0.0", message = "Le montant des frais d'adhésion doit être positif")
@Digits(integer = 10, fraction = 2)
@Column(name = "frais_adhesion", nullable = false, precision = 12, scale = 2)
private BigDecimal fraisAdhesion;
@Builder.Default
@DecimalMin(value = "0.0", message = "Le montant payé doit être positif")
@Digits(integer = 10, fraction = 2)
@Column(name = "montant_paye", nullable = false, precision = 12, scale = 2)
private BigDecimal montantPaye = BigDecimal.ZERO;
@NotBlank
@Pattern(regexp = "^[A-Z]{3}$", message = "Le code devise doit être un code ISO à 3 lettres")
@Column(name = "code_devise", nullable = false, length = 3)
private String codeDevise;
@NotBlank
@Pattern(
regexp = "^(EN_ATTENTE|APPROUVEE|REJETEE|ANNULEE|EN_PAIEMENT|PAYEE)$",
message = "Statut invalide")
@Column(name = "statut", nullable = false, length = 30)
private String statut;
@Column(name = "date_approbation")
private LocalDate dateApprobation;
@Column(name = "date_paiement")
private LocalDateTime datePaiement;
@Size(max = 20)
@Column(name = "methode_paiement", length = 20)
private String methodePaiement;
@Size(max = 100)
@Column(name = "reference_paiement", length = 100)
private String referencePaiement;
@Size(max = 1000)
@Column(name = "motif_rejet", length = 1000)
private String motifRejet;
@Size(max = 1000)
@Column(name = "observations", length = 1000)
private String observations;
@Column(name = "approuve_par", length = 255)
private String approuvePar;
@Column(name = "date_validation")
private LocalDate dateValidation;
/** Méthode métier pour vérifier si l'adhésion est payée intégralement */
public boolean isPayeeIntegralement() {
return montantPaye != null
&& fraisAdhesion != null
&& montantPaye.compareTo(fraisAdhesion) >= 0;
}
/** Méthode métier pour vérifier si l'adhésion est en attente de paiement */
public boolean isEnAttentePaiement() {
return "APPROUVEE".equals(statut) && !isPayeeIntegralement();
}
/** Méthode métier pour calculer le montant restant à payer */
public BigDecimal getMontantRestant() {
if (fraisAdhesion == null) return BigDecimal.ZERO;
if (montantPaye == null) return fraisAdhesion;
BigDecimal restant = fraisAdhesion.subtract(montantPaye);
return restant.compareTo(BigDecimal.ZERO) > 0 ? restant : BigDecimal.ZERO;
}
}

View File

@@ -1,10 +1,8 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.adresse.TypeAdresse;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.UUID;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@@ -12,23 +10,22 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* Entité Adresse pour la gestion des adresses des organisations, membres et événements * Entité Adresse pour la gestion des adresses des organisations, membres et
* événements
* *
* @author UnionFlow Team * @author UnionFlow Team
* @version 3.0 * @version 3.0
* @since 2025-01-29 * @since 2025-01-29
*/ */
@Entity @Entity
@Table( @Table(name = "adresses", indexes = {
name = "adresses", @Index(name = "idx_adresse_ville", columnList = "ville"),
indexes = { @Index(name = "idx_adresse_pays", columnList = "pays"),
@Index(name = "idx_adresse_ville", columnList = "ville"), @Index(name = "idx_adresse_type", columnList = "type_adresse"),
@Index(name = "idx_adresse_pays", columnList = "pays"), @Index(name = "idx_adresse_organisation", columnList = "organisation_id"),
@Index(name = "idx_adresse_type", columnList = "type_adresse"), @Index(name = "idx_adresse_membre", columnList = "membre_id"),
@Index(name = "idx_adresse_organisation", columnList = "organisation_id"), @Index(name = "idx_adresse_evenement", columnList = "evenement_id")
@Index(name = "idx_adresse_membre", columnList = "membre_id"), })
@Index(name = "idx_adresse_evenement", columnList = "evenement_id")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -36,10 +33,9 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class Adresse extends BaseEntity { public class Adresse extends BaseEntity {
/** Type d'adresse */ /** Type d'adresse (code depuis types_reference) */
@Enumerated(EnumType.STRING)
@Column(name = "type_adresse", nullable = false, length = 50) @Column(name = "type_adresse", nullable = false, length = 50)
private TypeAdresse typeAdresse; private String typeAdresse;
/** Adresse complète */ /** Adresse complète */
@Column(name = "adresse", length = 500) @Column(name = "adresse", length = 500)
@@ -112,23 +108,28 @@ public class Adresse extends BaseEntity {
sb.append(adresse); sb.append(adresse);
} }
if (complementAdresse != null && !complementAdresse.isEmpty()) { if (complementAdresse != null && !complementAdresse.isEmpty()) {
if (sb.length() > 0) sb.append(", "); if (sb.length() > 0)
sb.append(", ");
sb.append(complementAdresse); sb.append(complementAdresse);
} }
if (codePostal != null && !codePostal.isEmpty()) { if (codePostal != null && !codePostal.isEmpty()) {
if (sb.length() > 0) sb.append(", "); if (sb.length() > 0)
sb.append(", ");
sb.append(codePostal); sb.append(codePostal);
} }
if (ville != null && !ville.isEmpty()) { if (ville != null && !ville.isEmpty()) {
if (sb.length() > 0) sb.append(" "); if (sb.length() > 0)
sb.append(" ");
sb.append(ville); sb.append(ville);
} }
if (region != null && !region.isEmpty()) { if (region != null && !region.isEmpty()) {
if (sb.length() > 0) sb.append(", "); if (sb.length() > 0)
sb.append(", ");
sb.append(region); sb.append(region);
} }
if (pays != null && !pays.isEmpty()) { if (pays != null && !pays.isEmpty()) {
if (sb.length() > 0) sb.append(", "); if (sb.length() > 0)
sb.append(", ");
sb.append(pays); sb.append(pays);
} }
return sb.toString(); return sb.toString();
@@ -140,15 +141,10 @@ public class Adresse extends BaseEntity {
} }
/** Callback JPA avant la persistance */ /** Callback JPA avant la persistance */
@PrePersist
protected void onCreate() { protected void onCreate() {
super.onCreate(); // Appelle le onCreate de BaseEntity super.onCreate(); // Appelle le onCreate de BaseEntity
if (typeAdresse == null) {
typeAdresse = dev.lions.unionflow.server.api.enums.adresse.TypeAdresse.AUTRE;
}
if (principale == null) { if (principale == null) {
principale = false; principale = false;
} }
} }
} }

View File

@@ -0,0 +1,94 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Entité Action d'Approbateur
*
* Représente l'action (approve/reject) d'un approbateur sur une demande d'approbation.
*
* @author UnionFlow Team
* @version 1.0
* @since 2026-03-13
*/
@Entity
@Table(name = "approver_actions", indexes = {
@Index(name = "idx_approver_action_approval", columnList = "approval_id"),
@Index(name = "idx_approver_action_approver", columnList = "approver_id"),
@Index(name = "idx_approver_action_decision", columnList = "decision"),
@Index(name = "idx_approver_action_decided_at", columnList = "decided_at")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ApproverAction extends BaseEntity {
/** Approbation parente */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "approval_id", nullable = false)
private TransactionApproval approval;
/** ID de l'approbateur (membre) */
@NotNull
@Column(name = "approver_id", nullable = false)
private UUID approverId;
/** Nom complet de l'approbateur (cache) */
@NotBlank
@Column(name = "approver_name", nullable = false, length = 200)
private String approverName;
/** Rôle de l'approbateur au moment de l'action */
@NotBlank
@Column(name = "approver_role", nullable = false, length = 50)
private String approverRole;
/** Décision (PENDING, APPROVED, REJECTED) */
@NotBlank
@Pattern(regexp = "^(PENDING|APPROVED|REJECTED)$")
@Builder.Default
@Column(name = "decision", nullable = false, length = 10)
private String decision = "PENDING";
/** Commentaire optionnel */
@Size(max = 1000)
@Column(name = "comment", length = 1000)
private String comment;
/** Date de la décision */
@Column(name = "decided_at")
private LocalDateTime decidedAt;
@PrePersist
protected void onCreate() {
super.onCreate();
if (decision == null) {
decision = "PENDING";
}
}
/** Méthode métier pour approuver avec commentaire */
public void approve(String comment) {
this.decision = "APPROVED";
this.comment = comment;
this.decidedAt = LocalDateTime.now();
}
/** Méthode métier pour rejeter avec raison */
public void reject(String reason) {
this.decision = "REJECTED";
this.comment = reason;
this.decidedAt = LocalDateTime.now();
}
}

View File

@@ -1,8 +1,8 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.audit.PorteeAudit;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.UUID;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -70,7 +70,24 @@ public class AuditLog extends BaseEntity {
@Column(name = "entite_type", length = 100) @Column(name = "entite_type", length = 100)
private String entiteType; private String entiteType;
/**
* Organisation concernée par cet événement d'audit.
* NULL pour les événements de portée PLATEFORME.
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
/**
* Portée de visibilité :
* ORGANISATION = visible par le manager de l'organisation
* PLATEFORME = visible uniquement par le Super Admin UnionFlow
*/
@Enumerated(EnumType.STRING)
@Column(name = "portee", nullable = false, length = 15)
private PorteeAudit portee = PorteeAudit.PLATEFORME;
@PrePersist @PrePersist
protected void onCreate() { protected void onCreate() {
if (dateHeure == null) { if (dateHeure == null) {

View File

@@ -0,0 +1,95 @@
package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.ayantdroit.LienParente;
import dev.lions.unionflow.server.api.enums.ayantdroit.StatutAyantDroit;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.time.LocalDate;
import java.math.BigDecimal;
import lombok.*;
/**
* Ayant droit d'un membre dans une mutuelle de santé.
*
* <p>
* Permet la gestion des bénéficiaires (conjoint, enfants, parents) pour
* les conventions avec les centres de santé partenaires et les plafonds
* annuels.
*
* <p>
* Table : {@code ayants_droit}
*/
@Entity
@Table(name = "ayants_droit", indexes = {
@Index(name = "idx_ad_membre_org", columnList = "membre_organisation_id"),
@Index(name = "idx_ad_couverture", columnList = "date_debut_couverture, date_fin_couverture")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class AyantDroit extends BaseEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_organisation_id", nullable = false)
private MembreOrganisation membreOrganisation;
@NotBlank
@Column(name = "prenom", nullable = false, length = 100)
private String prenom;
@NotBlank
@Column(name = "nom", nullable = false, length = 100)
private String nom;
@Column(name = "date_naissance")
private LocalDate dateNaissance;
@Enumerated(EnumType.STRING)
@NotNull
@Column(name = "lien_parente", nullable = false, length = 20)
private LienParente lienParente;
/** Numéro attribué pour les conventions santé avec les centres partenaires */
@Column(name = "numero_beneficiaire", length = 50)
private String numeroBeneficiaire;
@Column(name = "date_debut_couverture")
private LocalDate dateDebutCouverture;
/** NULL = couverture ouverte */
@Column(name = "date_fin_couverture")
private LocalDate dateFinCouverture;
@Column(name = "sexe", length = 20)
private String sexe;
@Column(name = "piece_identite", length = 100)
private String pieceIdentite;
@Column(name = "pourcentage_couverture", precision = 5, scale = 2)
private BigDecimal pourcentageCouvertureSante;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutAyantDroit statut = StatutAyantDroit.EN_ATTENTE;
// ── Méthodes métier ────────────────────────────────────────────────────────
public boolean isCouvertAujourdhui() {
LocalDate today = LocalDate.now();
if (dateDebutCouverture != null && today.isBefore(dateDebutCouverture))
return false;
if (dateFinCouverture != null && today.isAfter(dateFinCouverture))
return false;
return Boolean.TRUE.equals(getActif());
}
public String getNomComplet() {
return prenom + " " + nom;
}
}

View File

@@ -1,111 +1,79 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import jakarta.persistence.*; import dev.lions.unionflow.server.entity.listener.AuditEntityListener;
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Version;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.UUID; import java.util.UUID;
import lombok.Data;
import lombok.EqualsAndHashCode;
/** /**
* Classe de base pour les entités UnionFlow utilisant UUID comme identifiant * Classe de base pour toutes les entités UnionFlow.
* *
* <p>Remplace PanacheEntity pour utiliser UUID au lieu de Long comme ID. * <p>
* Fournit les fonctionnalités de base de Panache avec UUID. * Étend PanacheEntityBase pour bénéficier du pattern Active Record et résoudre
* * les warnings Hibernate.
* Fournit les champs communs d'audit et le versioning optimistic.
*
* @author UnionFlow Team * @author UnionFlow Team
* @version 2.0 * @version 4.0
* @since 2025-01-16
*/ */
@MappedSuperclass @MappedSuperclass
public abstract class BaseEntity { @EntityListeners(AuditEntityListener.class)
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class BaseEntity extends PanacheEntityBase {
/** Identifiant unique auto-généré. */
@Id @Id
@GeneratedValue(strategy = GenerationType.UUID) @GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "id", updatable = false, nullable = false) @Column(name = "id", updatable = false, nullable = false)
private UUID id; private UUID id;
/**
* Date de création.
*/
@Column(name = "date_creation", nullable = false, updatable = false) @Column(name = "date_creation", nullable = false, updatable = false)
protected LocalDateTime dateCreation; private LocalDateTime dateCreation;
/**
* Date de dernière modification.
*/
@Column(name = "date_modification") @Column(name = "date_modification")
protected LocalDateTime dateModification; private LocalDateTime dateModification;
/**
* Email de l'utilisateur ayant créé l'entité.
*/
@Column(name = "cree_par", length = 255) @Column(name = "cree_par", length = 255)
protected String creePar; private String creePar;
/**
* Email du dernier utilisateur ayant modifié l'entité.
*/
@Column(name = "modifie_par", length = 255) @Column(name = "modifie_par", length = 255)
protected String modifiePar; private String modifiePar;
/** Version pour l'optimistic locking JPA. */
@Version @Version
@Column(name = "version") @Column(name = "version")
protected Long version; private Long version;
/**
* État actif/inactif pour le soft-delete.
*/
@Column(name = "actif", nullable = false) @Column(name = "actif", nullable = false)
protected Boolean actif = true; private Boolean actif;
// Constructeur par défaut
public BaseEntity() {
this.dateCreation = LocalDateTime.now();
this.actif = true;
this.version = 0L;
}
// Getters et Setters
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public LocalDateTime getDateCreation() {
return dateCreation;
}
public void setDateCreation(LocalDateTime dateCreation) {
this.dateCreation = dateCreation;
}
public LocalDateTime getDateModification() {
return dateModification;
}
public void setDateModification(LocalDateTime dateModification) {
this.dateModification = dateModification;
}
public String getCreePar() {
return creePar;
}
public void setCreePar(String creePar) {
this.creePar = creePar;
}
public String getModifiePar() {
return modifiePar;
}
public void setModifiePar(String modifiePar) {
this.modifiePar = modifiePar;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public Boolean getActif() {
return actif;
}
public void setActif(Boolean actif) {
this.actif = actif;
}
// Callbacks JPA
@PrePersist @PrePersist
protected void onCreate() { protected void onCreate() {
if (this.dateCreation == null) { if (this.dateCreation == null) {
@@ -114,9 +82,6 @@ public abstract class BaseEntity {
if (this.actif == null) { if (this.actif == null) {
this.actif = true; this.actif = true;
} }
if (this.version == null) {
this.version = 0L;
}
} }
@PreUpdate @PreUpdate
@@ -124,18 +89,13 @@ public abstract class BaseEntity {
this.dateModification = LocalDateTime.now(); this.dateModification = LocalDateTime.now();
} }
// Méthodes utilitaires Panache-like /**
public void persist() { * Marque l'entité comme modifiée par un utilisateur donné.
// Cette méthode sera implémentée par les repositories ou services *
// Pour l'instant, elle est là pour compatibilité avec le code existant * @param utilisateur email de l'utilisateur
throw new UnsupportedOperationException( */
"Utilisez le repository approprié pour persister cette entité"); public void marquerCommeModifie(String utilisateur) {
} this.dateModification = LocalDateTime.now();
this.modifiePar = utilisateur;
public static <T extends BaseEntity> T findById(UUID id) {
// Cette méthode sera implémentée par les repositories
throw new UnsupportedOperationException(
"Utilisez le repository approprié pour rechercher par ID");
} }
} }

View File

@@ -0,0 +1,218 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
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;
/**
* Entité Budget
*
* Représente un budget prévisionnel (mensuel/trimestriel/annuel) avec suivi de réalisation.
*
* @author UnionFlow Team
* @version 1.0
* @since 2026-03-13
*/
@Entity
@Table(name = "budgets", indexes = {
@Index(name = "idx_budget_organisation", columnList = "organisation_id"),
@Index(name = "idx_budget_status", columnList = "status"),
@Index(name = "idx_budget_period", columnList = "period"),
@Index(name = "idx_budget_year_month", columnList = "year, month"),
@Index(name = "idx_budget_created_by", columnList = "created_by_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Budget extends BaseEntity {
/** Nom du budget */
@NotBlank
@Size(max = 200)
@Column(name = "name", nullable = false, length = 200)
private String name;
/** Description optionnelle */
@Size(max = 1000)
@Column(name = "description", length = 1000)
private String description;
/** Organisation concernée */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
/** Période (MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL) */
@NotBlank
@Pattern(regexp = "^(MONTHLY|QUARTERLY|SEMIANNUAL|ANNUAL)$")
@Column(name = "period", nullable = false, length = 20)
private String period;
/** Année du budget */
@NotNull
@Min(value = 2020, message = "L'année doit être >= 2020")
@Max(value = 2100, message = "L'année doit être <= 2100")
@Column(name = "year", nullable = false)
private Integer year;
/** Mois (1-12) pour budget mensuel, null sinon */
@Min(value = 1)
@Max(value = 12)
@Column(name = "month")
private Integer month;
/** Statut (DRAFT, ACTIVE, CLOSED, CANCELLED) */
@NotBlank
@Pattern(regexp = "^(DRAFT|ACTIVE|CLOSED|CANCELLED)$")
@Builder.Default
@Column(name = "status", nullable = false, length = 20)
private String status = "DRAFT";
/** Lignes budgétaires */
@OneToMany(mappedBy = "budget", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@Builder.Default
private List<BudgetLine> lines = new ArrayList<>();
/** Total prévu (somme des montants prévus des lignes) */
@NotNull
@DecimalMin(value = "0.0")
@Digits(integer = 14, fraction = 2)
@Builder.Default
@Column(name = "total_planned", nullable = false, precision = 16, scale = 2)
private BigDecimal totalPlanned = BigDecimal.ZERO;
/** Total réalisé (somme des montants réalisés des lignes) */
@DecimalMin(value = "0.0")
@Digits(integer = 14, fraction = 2)
@Builder.Default
@Column(name = "total_realized", nullable = false, precision = 16, scale = 2)
private BigDecimal totalRealized = BigDecimal.ZERO;
/** Code devise ISO 3 lettres */
@NotBlank
@Pattern(regexp = "^[A-Z]{3}$")
@Builder.Default
@Column(name = "currency", nullable = false, length = 3)
private String currency = "XOF";
/** ID du créateur du budget */
@NotNull
@Column(name = "created_by_id", nullable = false)
private UUID createdById;
/** Date de création */
@NotNull
@Column(name = "created_at_budget", nullable = false)
private LocalDateTime createdAtBudget;
/** Date d'approbation */
@Column(name = "approved_at")
private LocalDateTime approvedAt;
/** ID de l'approbateur */
@Column(name = "approved_by_id")
private UUID approvedById;
/** Date de début de la période budgétaire */
@NotNull
@Column(name = "start_date", nullable = false)
private LocalDate startDate;
/** Date de fin de la période budgétaire */
@NotNull
@Column(name = "end_date", nullable = false)
private LocalDate endDate;
/** Métadonnées additionnelles (JSON) */
@Column(name = "metadata", columnDefinition = "TEXT")
private String metadata;
@PrePersist
protected void onCreate() {
super.onCreate();
if (createdAtBudget == null) {
createdAtBudget = LocalDateTime.now();
}
if (currency == null) {
currency = "XOF";
}
if (status == null) {
status = "DRAFT";
}
if (totalPlanned == null) {
totalPlanned = BigDecimal.ZERO;
}
if (totalRealized == null) {
totalRealized = BigDecimal.ZERO;
}
}
/** Méthode métier pour ajouter une ligne budgétaire */
public void addLine(BudgetLine line) {
lines.add(line);
line.setBudget(this);
recalculateTotals();
}
/** Méthode métier pour supprimer une ligne budgétaire */
public void removeLine(BudgetLine line) {
lines.remove(line);
line.setBudget(null);
recalculateTotals();
}
/** Méthode métier pour recalculer les totaux */
public void recalculateTotals() {
this.totalPlanned = lines.stream()
.map(BudgetLine::getAmountPlanned)
.reduce(BigDecimal.ZERO, BigDecimal::add);
this.totalRealized = lines.stream()
.map(BudgetLine::getAmountRealized)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
/** Méthode métier pour calculer le taux de réalisation (%) */
public double getRealizationRate() {
if (totalPlanned.compareTo(BigDecimal.ZERO) == 0) {
return 0.0;
}
return totalRealized.divide(totalPlanned, 4, java.math.RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
.doubleValue();
}
/** Méthode métier pour calculer l'écart (réalisé - prévu) */
public BigDecimal getVariance() {
return totalRealized.subtract(totalPlanned);
}
/** Méthode métier pour vérifier si le budget est dépassé */
public boolean isOverBudget() {
return totalRealized.compareTo(totalPlanned) > 0;
}
/** Méthode métier pour vérifier si le budget est actif */
public boolean isActive() {
return "ACTIVE".equals(status);
}
/** Méthode métier pour vérifier si la période est en cours */
public boolean isCurrentPeriod() {
LocalDate now = LocalDate.now();
return !now.isBefore(startDate) && !now.isAfter(endDate);
}
}

View File

@@ -0,0 +1,102 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Entité Ligne Budgétaire
*
* Représente une ligne dans un budget (catégorie de dépense/recette).
*
* @author UnionFlow Team
* @version 1.0
* @since 2026-03-13
*/
@Entity
@Table(name = "budget_lines", indexes = {
@Index(name = "idx_budget_line_budget", columnList = "budget_id"),
@Index(name = "idx_budget_line_category", columnList = "category")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class BudgetLine extends BaseEntity {
/** Budget parent */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "budget_id", nullable = false)
private Budget budget;
/** Catégorie (CONTRIBUTIONS, SAVINGS, SOLIDARITY, EVENTS, OPERATIONAL, INVESTMENTS, OTHER) */
@NotBlank
@Pattern(regexp = "^(CONTRIBUTIONS|SAVINGS|SOLIDARITY|EVENTS|OPERATIONAL|INVESTMENTS|OTHER)$")
@Column(name = "category", nullable = false, length = 20)
private String category;
/** Nom de la ligne */
@NotBlank
@Size(max = 200)
@Column(name = "name", nullable = false, length = 200)
private String name;
/** Description optionnelle */
@Size(max = 500)
@Column(name = "description", length = 500)
private String description;
/** Montant prévu */
@NotNull
@DecimalMin(value = "0.0")
@Digits(integer = 14, fraction = 2)
@Column(name = "amount_planned", nullable = false, precision = 16, scale = 2)
private BigDecimal amountPlanned;
/** Montant réalisé */
@DecimalMin(value = "0.0")
@Digits(integer = 14, fraction = 2)
@Builder.Default
@Column(name = "amount_realized", nullable = false, precision = 16, scale = 2)
private BigDecimal amountRealized = BigDecimal.ZERO;
/** Notes additionnelles */
@Size(max = 1000)
@Column(name = "notes", length = 1000)
private String notes;
@PrePersist
protected void onCreate() {
super.onCreate();
if (amountRealized == null) {
amountRealized = BigDecimal.ZERO;
}
}
/** Méthode métier pour calculer le taux de réalisation (%) */
public double getRealizationRate() {
if (amountPlanned.compareTo(BigDecimal.ZERO) == 0) {
return 0.0;
}
return amountRealized.divide(amountPlanned, 4, java.math.RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
.doubleValue();
}
/** Méthode métier pour calculer l'écart */
public BigDecimal getVariance() {
return amountRealized.subtract(amountPlanned);
}
/** Méthode métier pour vérifier si la ligne est dépassée */
public boolean isOverBudget() {
return amountRealized.compareTo(amountPlanned) > 0;
}
}

View File

@@ -1,6 +1,7 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.comptabilite.TypeCompteComptable; import dev.lions.unionflow.server.api.enums.comptabilite.TypeCompteComptable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -85,6 +86,7 @@ public class CompteComptable extends BaseEntity {
private String description; private String description;
/** Lignes d'écriture associées */ /** Lignes d'écriture associées */
@JsonIgnore
@OneToMany(mappedBy = "compteComptable", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "compteComptable", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<LigneEcriture> lignesEcriture = new ArrayList<>(); private List<LigneEcriture> lignesEcriture = new ArrayList<>();

View File

@@ -1,6 +1,7 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.wave.StatutCompteWave; import dev.lions.unionflow.server.api.enums.wave.StatutCompteWave;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Pattern;
@@ -20,14 +21,12 @@ import lombok.NoArgsConstructor;
* @since 2025-01-29 * @since 2025-01-29
*/ */
@Entity @Entity
@Table( @Table(name = "comptes_wave", indexes = {
name = "comptes_wave", @Index(name = "idx_compte_wave_telephone", columnList = "numero_telephone", unique = true),
indexes = { @Index(name = "idx_compte_wave_statut", columnList = "statut_compte"),
@Index(name = "idx_compte_wave_telephone", columnList = "numero_telephone", unique = true), @Index(name = "idx_compte_wave_organisation", columnList = "organisation_id"),
@Index(name = "idx_compte_wave_statut", columnList = "statut_compte"), @Index(name = "idx_compte_wave_membre", columnList = "membre_id")
@Index(name = "idx_compte_wave_organisation", columnList = "organisation_id"), })
@Index(name = "idx_compte_wave_membre", columnList = "membre_id")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -37,9 +36,7 @@ public class CompteWave extends BaseEntity {
/** Numéro de téléphone Wave (format +225XXXXXXXX) */ /** Numéro de téléphone Wave (format +225XXXXXXXX) */
@NotBlank @NotBlank
@Pattern( @Pattern(regexp = "^\\+225[0-9]{8}$", message = "Le numéro de téléphone Wave doit être au format +225XXXXXXXX")
regexp = "^\\+225[0-9]{8}$",
message = "Le numéro de téléphone Wave doit être au format +225XXXXXXXX")
@Column(name = "numero_telephone", unique = true, nullable = false, length = 13) @Column(name = "numero_telephone", unique = true, nullable = false, length = 13)
private String numeroTelephone; private String numeroTelephone;
@@ -78,6 +75,8 @@ public class CompteWave extends BaseEntity {
@JoinColumn(name = "membre_id") @JoinColumn(name = "membre_id")
private Membre membre; private Membre membre;
@JsonIgnore
@OneToMany(mappedBy = "compteWave", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "compteWave", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<TransactionWave> transactions = new ArrayList<>(); private List<TransactionWave> transactions = new ArrayList<>();
@@ -104,4 +103,3 @@ public class CompteWave extends BaseEntity {
} }
} }
} }

View File

@@ -0,0 +1,59 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Entité Configuration pour la gestion de la configuration système
*
* @author UnionFlow Team
* @version 1.0
*/
@Entity
@Table(
name = "configurations",
indexes = {
@Index(name = "idx_config_cle", columnList = "cle", unique = true),
@Index(name = "idx_config_categorie", columnList = "categorie")
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Configuration extends BaseEntity {
@NotBlank
@Column(name = "cle", nullable = false, unique = true, length = 255)
private String cle;
@Column(name = "valeur", columnDefinition = "TEXT")
private String valeur;
@Column(name = "type", length = 50)
private String type; // STRING, NUMBER, BOOLEAN, JSON, DATE
@Column(name = "categorie", length = 50)
private String categorie; // SYSTEME, SECURITE, NOTIFICATION, INTEGRATION, APPEARANCE
@Column(name = "description", length = 1000)
private String description;
@Column(name = "modifiable")
@Builder.Default
private Boolean modifiable = true;
@Column(name = "visible")
@Builder.Default
private Boolean visible = true;
@Column(name = "metadonnees", columnDefinition = "TEXT")
private String metadonnees; // JSON string pour stocker les métadonnées
}

View File

@@ -13,23 +13,22 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* Entité Cotisation avec UUID Représente une cotisation d'un membre à son organisation * Entité Cotisation avec UUID Représente une cotisation d'un membre à son
* organisation
* *
* @author UnionFlow Team * @author UnionFlow Team
* @version 2.0 * @version 2.0
* @since 2025-01-16 * @since 2025-01-16
*/ */
@Entity @Entity
@Table( @Table(name = "cotisations", indexes = {
name = "cotisations", @Index(name = "idx_cotisation_membre", columnList = "membre_id"),
indexes = { @Index(name = "idx_cotisation_reference", columnList = "numero_reference", unique = true),
@Index(name = "idx_cotisation_membre", columnList = "membre_id"), @Index(name = "idx_cotisation_statut", columnList = "statut"),
@Index(name = "idx_cotisation_reference", columnList = "numero_reference", unique = true), @Index(name = "idx_cotisation_echeance", columnList = "date_echeance"),
@Index(name = "idx_cotisation_statut", columnList = "statut"), @Index(name = "idx_cotisation_type", columnList = "type_cotisation"),
@Index(name = "idx_cotisation_echeance", columnList = "date_echeance"), @Index(name = "idx_cotisation_annee_mois", columnList = "annee, mois")
@Index(name = "idx_cotisation_type", columnList = "type_cotisation"), })
@Index(name = "idx_cotisation_annee_mois", columnList = "annee, mois")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -46,10 +45,25 @@ public class Cotisation extends BaseEntity {
@JoinColumn(name = "membre_id", nullable = false) @JoinColumn(name = "membre_id", nullable = false)
private Membre membre; private Membre membre;
/** Organisation pour laquelle la cotisation est due */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
/** Intention de paiement Wave associée (null si cotisation en attente) */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "intention_paiement_id")
private IntentionPaiement intentionPaiement;
@NotBlank @NotBlank
@Column(name = "type_cotisation", nullable = false, length = 50) @Column(name = "type_cotisation", nullable = false, length = 50)
private String typeCotisation; private String typeCotisation;
@NotBlank
@Column(name = "libelle", nullable = false, length = 100)
private String libelle;
@NotNull @NotNull
@DecimalMin(value = "0.0", message = "Le montant dû doit être positif") @DecimalMin(value = "0.0", message = "Le montant dû doit être positif")
@Digits(integer = 10, fraction = 2) @Digits(integer = 10, fraction = 2)
@@ -124,14 +138,6 @@ public class Cotisation extends BaseEntity {
@Column(name = "date_validation") @Column(name = "date_validation")
private LocalDateTime dateValidation; private LocalDateTime dateValidation;
@Size(max = 50)
@Column(name = "methode_paiement", length = 50)
private String methodePaiement;
@Size(max = 100)
@Column(name = "reference_paiement", length = 100)
private String referencePaiement;
/** Méthode métier pour calculer le montant restant à payer */ /** Méthode métier pour calculer le montant restant à payer */
public BigDecimal getMontantRestant() { public BigDecimal getMontantRestant() {
if (montantDu == null || montantPaye == null) { if (montantDu == null || montantPaye == null) {

View File

@@ -0,0 +1,128 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.*;
/**
* Demande d'adhésion d'un utilisateur à une organisation.
*
* <p>Flux :
* <ol>
* <li>L'utilisateur crée son compte et choisit une organisation</li>
* <li>Une {@code DemandeAdhesion} est créée (statut EN_ATTENTE)</li>
* <li>Si frais d'adhésion : une {@link IntentionPaiement} est créée et liée</li>
* <li>Le manager valide → {@link MembreOrganisation} créé, quota souscription décrémenté</li>
* </ol>
*
* <p>Remplace l'ancienne entité {@code Adhesion}.
* Table : {@code demandes_adhesion}
*/
@Entity
@Table(
name = "demandes_adhesion",
indexes = {
@Index(name = "idx_da_utilisateur", columnList = "utilisateur_id"),
@Index(name = "idx_da_organisation", columnList = "organisation_id"),
@Index(name = "idx_da_statut", columnList = "statut"),
@Index(name = "idx_da_date", columnList = "date_demande")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class DemandeAdhesion extends BaseEntity {
@NotBlank
@Column(name = "numero_reference", unique = true, nullable = false, length = 50)
private String numeroReference;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "utilisateur_id", nullable = false)
private Membre utilisateur;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank
@Pattern(regexp = "^(EN_ATTENTE|APPROUVEE|REJETEE|ANNULEE)$")
@Builder.Default
@Column(name = "statut", nullable = false, length = 20)
private String statut = "EN_ATTENTE";
@Builder.Default
@DecimalMin("0.00")
@Digits(integer = 10, fraction = 2)
@Column(name = "frais_adhesion", nullable = false, precision = 12, scale = 2)
private BigDecimal fraisAdhesion = BigDecimal.ZERO;
@Builder.Default
@DecimalMin("0.00")
@Digits(integer = 10, fraction = 2)
@Column(name = "montant_paye", nullable = false, precision = 12, scale = 2)
private BigDecimal montantPaye = BigDecimal.ZERO;
@Builder.Default
@Pattern(regexp = "^[A-Z]{3}$")
@Column(name = "code_devise", nullable = false, length = 3)
private String codeDevise = "XOF";
/** Intention de paiement Wave liée aux frais d'adhésion */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "intention_paiement_id")
private IntentionPaiement intentionPaiement;
@Builder.Default
@Column(name = "date_demande", nullable = false)
private LocalDateTime dateDemande = LocalDateTime.now();
@Column(name = "date_traitement")
private LocalDateTime dateTraitement;
/** Manager/Admin qui a approuvé ou rejeté */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "traite_par_id")
private Membre traitePar;
@Column(name = "motif_rejet", length = 1000)
private String motifRejet;
@Column(name = "observations", length = 1000)
private String observations;
// ── Méthodes métier ────────────────────────────────────────────────────────
public boolean isEnAttente() { return "EN_ATTENTE".equals(statut); }
public boolean isApprouvee() { return "APPROUVEE".equals(statut); }
public boolean isRejetee() { return "REJETEE".equals(statut); }
public boolean isPayeeIntegralement() {
return fraisAdhesion != null
&& montantPaye != null
&& montantPaye.compareTo(fraisAdhesion) >= 0;
}
public static String genererNumeroReference() {
return "ADH-" + java.time.LocalDate.now().getYear()
+ "-" + String.format("%08d", System.currentTimeMillis() % 100000000);
}
@PrePersist
protected void onCreate() {
super.onCreate();
if (dateDemande == null) dateDemande = LocalDateTime.now();
if (statut == null) statut = "EN_ATTENTE";
if (codeDevise == null) codeDevise = "XOF";
if (fraisAdhesion == null) fraisAdhesion = BigDecimal.ZERO;
if (montantPaye == null) montantPaye = BigDecimal.ZERO;
if (numeroReference == null || numeroReference.isEmpty()) {
numeroReference = genererNumeroReference();
}
}
}

View File

@@ -1,6 +1,7 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.document.TypeDocument; import dev.lions.unionflow.server.api.enums.document.TypeDocument;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.util.ArrayList; import java.util.ArrayList;
@@ -85,6 +86,7 @@ public class Document extends BaseEntity {
private java.time.LocalDateTime dateDernierTelechargement; private java.time.LocalDateTime dateDernierTelechargement;
/** Pièces jointes associées */ /** Pièces jointes associées */
@JsonIgnore
@OneToMany(mappedBy = "document", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "document", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<PieceJointe> piecesJointes = new ArrayList<>(); private List<PieceJointe> piecesJointes = new ArrayList<>();

View File

@@ -1,5 +1,6 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -97,6 +98,7 @@ public class EcritureComptable extends BaseEntity {
private Paiement paiement; private Paiement paiement;
/** Lignes d'écriture */ /** Lignes d'écriture */
@JsonIgnore
@OneToMany(mappedBy = "ecriture", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) @OneToMany(mappedBy = "ecriture", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<LigneEcriture> lignes = new ArrayList<>(); private List<LigneEcriture> lignes = new ArrayList<>();

View File

@@ -1,5 +1,6 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -17,14 +18,12 @@ import lombok.*;
* @since 2025-01-16 * @since 2025-01-16
*/ */
@Entity @Entity
@Table( @Table(name = "evenements", indexes = {
name = "evenements", @Index(name = "idx_evenement_date_debut", columnList = "date_debut"),
indexes = { @Index(name = "idx_evenement_statut", columnList = "statut"),
@Index(name = "idx_evenement_date_debut", columnList = "date_debut"), @Index(name = "idx_evenement_type", columnList = "type_evenement"),
@Index(name = "idx_evenement_statut", columnList = "statut"), @Index(name = "idx_evenement_organisation", columnList = "organisation_id")
@Index(name = "idx_evenement_type", columnList = "type_evenement"), })
@Index(name = "idx_evenement_organisation", columnList = "organisation_id")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -56,14 +55,12 @@ public class Evenement extends BaseEntity {
@Column(name = "adresse", length = 1000) @Column(name = "adresse", length = 1000)
private String adresse; private String adresse;
@Enumerated(EnumType.STRING)
@Column(name = "type_evenement", length = 50) @Column(name = "type_evenement", length = 50)
private TypeEvenement typeEvenement; private String typeEvenement;
@Enumerated(EnumType.STRING)
@Builder.Default @Builder.Default
@Column(name = "statut", nullable = false, length = 30) @Column(name = "statut", nullable = false, length = 30)
private StatutEvenement statut = StatutEvenement.PLANIFIE; private String statut = "PLANIFIE";
@Min(0) @Min(0)
@Column(name = "capacite_max") @Column(name = "capacite_max")
@@ -97,10 +94,6 @@ public class Evenement extends BaseEntity {
@Column(name = "visible_public", nullable = false) @Column(name = "visible_public", nullable = false)
private Boolean visiblePublic = true; private Boolean visiblePublic = true;
@Builder.Default
@Column(name = "actif", nullable = false)
private Boolean actif = true;
// Relations // Relations
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id") @JoinColumn(name = "organisation_id")
@@ -110,14 +103,12 @@ public class Evenement extends BaseEntity {
@JoinColumn(name = "organisateur_id") @JoinColumn(name = "organisateur_id")
private Membre organisateur; private Membre organisateur;
@OneToMany( @JsonIgnore
mappedBy = "evenement", @OneToMany(mappedBy = "evenement", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
cascade = CascadeType.ALL,
orphanRemoval = true,
fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<InscriptionEvenement> inscriptions = new ArrayList<>(); private List<InscriptionEvenement> inscriptions = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "evenement", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "evenement", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<Adresse> adresses = new ArrayList<>(); private List<Adresse> adresses = new ArrayList<>();
@@ -169,8 +160,9 @@ public class Evenement extends BaseEntity {
// Méthodes métier // Méthodes métier
/** Vérifie si l'événement est ouvert aux inscriptions */ /** Vérifie si l'événement est ouvert aux inscriptions */
@JsonIgnore
public boolean isOuvertAuxInscriptions() { public boolean isOuvertAuxInscriptions() {
if (!inscriptionRequise || !actif) { if (!inscriptionRequise || !getActif()) {
return false; return false;
} }
@@ -191,22 +183,22 @@ public class Evenement extends BaseEntity {
return false; return false;
} }
return statut == StatutEvenement.PLANIFIE || statut == StatutEvenement.CONFIRME; return "PLANIFIE".equals(statut) || "CONFIRME".equals(statut);
} }
/** Obtient le nombre d'inscrits à l'événement */ /** Obtient le nombre d'inscrits à l'événement */
@JsonIgnore
public int getNombreInscrits() { public int getNombreInscrits() {
return inscriptions != null return inscriptions != null
? (int) ? (int) inscriptions.stream()
inscriptions.stream() .filter(
.filter( inscription -> InscriptionEvenement.StatutInscription.CONFIRMEE.name().equals(inscription.getStatut()))
inscription -> .count()
inscription.getStatut() == InscriptionEvenement.StatutInscription.CONFIRMEE)
.count()
: 0; : 0;
} }
/** Vérifie si l'événement est complet */ /** Vérifie si l'événement est complet */
@JsonIgnore
public boolean isComplet() { public boolean isComplet() {
return capaciteMax != null && getNombreInscrits() >= capaciteMax; return capaciteMax != null && getNombreInscrits() >= capaciteMax;
} }
@@ -219,7 +211,7 @@ public class Evenement extends BaseEntity {
/** Vérifie si l'événement est terminé */ /** Vérifie si l'événement est terminé */
public boolean isTermine() { public boolean isTermine() {
if (statut == StatutEvenement.TERMINE) { if ("TERMINE".equals(statut)) {
return true; return true;
} }
@@ -237,6 +229,7 @@ public class Evenement extends BaseEntity {
} }
/** Obtient le nombre de places restantes */ /** Obtient le nombre de places restantes */
@JsonIgnore
public Integer getPlacesRestantes() { public Integer getPlacesRestantes() {
if (capaciteMax == null) { if (capaciteMax == null) {
return null; // Capacité illimitée return null; // Capacité illimitée
@@ -250,13 +243,12 @@ public class Evenement extends BaseEntity {
return inscriptions != null return inscriptions != null
&& inscriptions.stream() && inscriptions.stream()
.anyMatch( .anyMatch(
inscription -> inscription -> inscription.getMembre().getId().equals(membreId)
inscription.getMembre().getId().equals(membreId) && InscriptionEvenement.StatutInscription.CONFIRMEE.name().equals(inscription.getStatut()));
&& inscription.getStatut()
== InscriptionEvenement.StatutInscription.CONFIRMEE);
} }
/** Obtient le taux de remplissage en pourcentage */ /** Obtient le taux de remplissage en pourcentage */
@JsonIgnore
public Double getTauxRemplissage() { public Double getTauxRemplissage() {
if (capaciteMax == null || capaciteMax == 0) { if (capaciteMax == null || capaciteMax == 0) {
return null; return null;

View File

@@ -0,0 +1,79 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.UUID;
/**
* Entité Favori pour la gestion des favoris utilisateur
*
* @author UnionFlow Team
* @version 1.0
*/
@Entity
@Table(
name = "favoris",
indexes = {
@Index(name = "idx_favori_utilisateur", columnList = "utilisateur_id"),
@Index(name = "idx_favori_type", columnList = "type_favori"),
@Index(name = "idx_favori_categorie", columnList = "categorie")
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Favori extends BaseEntity {
@NotNull
@Column(name = "utilisateur_id", nullable = false)
private UUID utilisateurId;
@NotBlank
@Column(name = "type_favori", nullable = false, length = 50)
private String typeFavori; // PAGE, DOCUMENT, CONTACT, RACCOURCI
@NotBlank
@Column(name = "titre", nullable = false, length = 255)
private String titre;
@Column(name = "description", length = 1000)
private String description;
@Column(name = "url", length = 1000)
private String url;
@Column(name = "icon", length = 100)
private String icon;
@Column(name = "couleur", length = 50)
private String couleur;
@Column(name = "categorie", length = 100)
private String categorie;
@Column(name = "ordre")
@Builder.Default
private Integer ordre = 0;
@Column(name = "nb_visites")
@Builder.Default
private Integer nbVisites = 0;
@Column(name = "derniere_visite")
private LocalDateTime derniereVisite;
@Column(name = "est_plus_utilise")
@Builder.Default
private Boolean estPlusUtilise = false;
}

View File

@@ -0,0 +1,75 @@
package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.abonnement.TypeFormule;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import lombok.*;
/**
* Catalogue des forfaits SaaS UnionFlow.
*
* <p>Starter (≤50) → Standard (≤200) → Premium (≤500) → Crystal (illimité)
* Fourchette tarifaire : 5 000 à 10 000 XOF/mois. Stockage max : 1 Go.
*
* <p>Table : {@code formules_abonnement}
*/
@Entity
@Table(
name = "formules_abonnement",
indexes = {
@Index(name = "idx_formule_code", columnList = "code", unique = true),
@Index(name = "idx_formule_actif", columnList = "actif")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class FormuleAbonnement extends BaseEntity {
@Enumerated(EnumType.STRING)
@NotNull
@Column(name = "code", unique = true, nullable = false, length = 20)
private TypeFormule code;
@NotBlank
@Column(name = "libelle", nullable = false, length = 100)
private String libelle;
@Column(name = "description", columnDefinition = "TEXT")
private String description;
/** Nombre maximum de membres. NULL = illimité (Crystal) */
@Column(name = "max_membres")
private Integer maxMembres;
/** Stockage maximum en Mo — 1 024 Mo (1 Go) par défaut */
@Builder.Default
@Column(name = "max_stockage_mo", nullable = false)
private Integer maxStockageMo = 1024;
@NotNull
@DecimalMin("0.00")
@Digits(integer = 8, fraction = 2)
@Column(name = "prix_mensuel", nullable = false, precision = 10, scale = 2)
private BigDecimal prixMensuel;
@NotNull
@DecimalMin("0.00")
@Digits(integer = 8, fraction = 2)
@Column(name = "prix_annuel", nullable = false, precision = 10, scale = 2)
private BigDecimal prixAnnuel;
@Builder.Default
@Column(name = "ordre_affichage", nullable = false)
private Integer ordreAffichage = 0;
public boolean isIllimitee() {
return maxMembres == null;
}
public boolean accepteNouveauMembre(int quotaActuel) {
return isIllimitee() || quotaActuel < maxMembres;
}
}

View File

@@ -6,20 +6,19 @@ import java.time.LocalDateTime;
import lombok.*; import lombok.*;
/** /**
* Entité InscriptionEvenement représentant l'inscription d'un membre à un événement * Entité InscriptionEvenement représentant l'inscription d'un membre à un
* événement
* *
* @author UnionFlow Team * @author UnionFlow Team
* @version 2.0 * @version 2.0
* @since 2025-01-16 * @since 2025-01-16
*/ */
@Entity @Entity
@Table( @Table(name = "inscriptions_evenement", indexes = {
name = "inscriptions_evenement", @Index(name = "idx_inscription_membre", columnList = "membre_id"),
indexes = { @Index(name = "idx_inscription_evenement", columnList = "evenement_id"),
@Index(name = "idx_inscription_membre", columnList = "membre_id"), @Index(name = "idx_inscription_date", columnList = "date_inscription")
@Index(name = "idx_inscription_evenement", columnList = "evenement_id"), })
@Index(name = "idx_inscription_date", columnList = "date_inscription")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -41,30 +40,19 @@ public class InscriptionEvenement extends BaseEntity {
@Column(name = "date_inscription", nullable = false) @Column(name = "date_inscription", nullable = false)
private LocalDateTime dateInscription = LocalDateTime.now(); private LocalDateTime dateInscription = LocalDateTime.now();
@Enumerated(EnumType.STRING)
@Column(name = "statut", length = 20) @Column(name = "statut", length = 20)
@Builder.Default @Builder.Default
private StatutInscription statut = StatutInscription.CONFIRMEE; private String statut = StatutInscription.CONFIRMEE.name();
@Column(name = "commentaire", length = 500) @Column(name = "commentaire", length = 500)
private String commentaire; private String commentaire;
/** Énumération des statuts d'inscription */ /** Énumération des statuts d'inscription (pour constantes) */
public enum StatutInscription { public enum StatutInscription {
CONFIRMEE("Confirmée"), CONFIRMEE,
EN_ATTENTE("En attente"), EN_ATTENTE,
ANNULEE("Annulée"), ANNULEE,
REFUSEE("Refusée"); REFUSEE;
private final String libelle;
StatutInscription(String libelle) {
this.libelle = libelle;
}
public String getLibelle() {
return libelle;
}
} }
// Méthodes utilitaires // Méthodes utilitaires
@@ -75,7 +63,7 @@ public class InscriptionEvenement extends BaseEntity {
* @return true si l'inscription est confirmée * @return true si l'inscription est confirmée
*/ */
public boolean isConfirmee() { public boolean isConfirmee() {
return StatutInscription.CONFIRMEE.equals(this.statut); return StatutInscription.CONFIRMEE.name().equals(this.statut);
} }
/** /**
@@ -84,7 +72,7 @@ public class InscriptionEvenement extends BaseEntity {
* @return true si l'inscription est en attente * @return true si l'inscription est en attente
*/ */
public boolean isEnAttente() { public boolean isEnAttente() {
return StatutInscription.EN_ATTENTE.equals(this.statut); return StatutInscription.EN_ATTENTE.name().equals(this.statut);
} }
/** /**
@@ -93,13 +81,13 @@ public class InscriptionEvenement extends BaseEntity {
* @return true si l'inscription est annulée * @return true si l'inscription est annulée
*/ */
public boolean isAnnulee() { public boolean isAnnulee() {
return StatutInscription.ANNULEE.equals(this.statut); return StatutInscription.ANNULEE.name().equals(this.statut);
} }
/** Confirme l'inscription */ /** Confirme l'inscription */
public void confirmer() { public void confirmer() {
this.statut = StatutInscription.CONFIRMEE; this.statut = StatutInscription.CONFIRMEE.name();
this.dateModification = LocalDateTime.now(); setDateModification(LocalDateTime.now());
} }
/** /**
@@ -108,9 +96,9 @@ public class InscriptionEvenement extends BaseEntity {
* @param commentaire le commentaire d'annulation * @param commentaire le commentaire d'annulation
*/ */
public void annuler(String commentaire) { public void annuler(String commentaire) {
this.statut = StatutInscription.ANNULEE; this.statut = StatutInscription.ANNULEE.name();
this.commentaire = commentaire; this.commentaire = commentaire;
this.dateModification = LocalDateTime.now(); setDateModification(LocalDateTime.now());
} }
/** /**
@@ -119,28 +107,27 @@ public class InscriptionEvenement extends BaseEntity {
* @param commentaire le commentaire de mise en attente * @param commentaire le commentaire de mise en attente
*/ */
public void mettreEnAttente(String commentaire) { public void mettreEnAttente(String commentaire) {
this.statut = StatutInscription.EN_ATTENTE; this.statut = StatutInscription.EN_ATTENTE.name();
this.commentaire = commentaire; this.commentaire = commentaire;
this.dateModification = LocalDateTime.now(); setDateModification(LocalDateTime.now());
} }
/** /**
* Refuse l'inscription * Refuser l'inscription
* *
* @param commentaire le commentaire de refus * @param commentaire le commentaire de refus
*/ */
public void refuser(String commentaire) { public void refuser(String commentaire) {
this.statut = StatutInscription.REFUSEE; this.statut = StatutInscription.REFUSEE.name();
this.commentaire = commentaire; this.commentaire = commentaire;
this.dateModification = LocalDateTime.now(); setDateModification(LocalDateTime.now());
} }
// Callbacks JPA // Callbacks JPA
@PreUpdate @PreUpdate
public void preUpdate() { public void preUpdate() {
super.onUpdate(); // Appelle le onUpdate de BaseEntity super.onUpdate();
this.dateModification = LocalDateTime.now();
} }
@Override @Override

View File

@@ -0,0 +1,122 @@
package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.paiement.StatutIntentionPaiement;
import dev.lions.unionflow.server.api.enums.paiement.TypeObjetIntentionPaiement;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.*;
/**
* Hub centralisé pour tout paiement Wave initié depuis UnionFlow.
*
* <p>Flux :
* <ol>
* <li>UnionFlow crée une {@code IntentionPaiement} avec les objets cibles (cotisations, etc.)</li>
* <li>UnionFlow appelle l'API Wave → récupère {@code waveCheckoutSessionId}</li>
* <li>Le membre confirme dans l'app Wave</li>
* <li>Wave envoie un webhook → UnionFlow réconcilie via {@code waveCheckoutSessionId}</li>
* <li>UnionFlow valide automatiquement les objets listés dans {@code objetsCibles}</li>
* </ol>
*
* <p>Table : {@code intentions_paiement}
*/
@Entity
@Table(
name = "intentions_paiement",
indexes = {
@Index(name = "idx_intention_utilisateur", columnList = "utilisateur_id"),
@Index(name = "idx_intention_statut", columnList = "statut"),
@Index(name = "idx_intention_wave_session", columnList = "wave_checkout_session_id", unique = true),
@Index(name = "idx_intention_expiration", columnList = "date_expiration")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class IntentionPaiement extends BaseEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "utilisateur_id", nullable = false)
private Membre utilisateur;
/** NULL pour les abonnements UnionFlow SA (payés par l'organisation directement) */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
@NotNull
@DecimalMin("0.01")
@Digits(integer = 12, fraction = 2)
@Column(name = "montant_total", nullable = false, precision = 14, scale = 2)
private BigDecimal montantTotal;
@NotBlank
@Pattern(regexp = "^[A-Z]{3}$")
@Builder.Default
@Column(name = "code_devise", nullable = false, length = 3)
private String codeDevise = "XOF";
@Enumerated(EnumType.STRING)
@NotNull
@Column(name = "type_objet", nullable = false, length = 30)
private TypeObjetIntentionPaiement typeObjet;
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(name = "statut", nullable = false, length = 20)
private StatutIntentionPaiement statut = StatutIntentionPaiement.INITIEE;
/** ID de session Wave — clé de réconciliation sur webhook */
@Column(name = "wave_checkout_session_id", unique = true, length = 255)
private String waveCheckoutSessionId;
/** URL de paiement Wave à rediriger l'utilisateur */
@Column(name = "wave_launch_url", length = 1000)
private String waveLaunchUrl;
/** ID transaction Wave reçu via webhook */
@Column(name = "wave_transaction_id", length = 100)
private String waveTransactionId;
/**
* JSON : liste des objets couverts par ce paiement.
* Exemple : [{\"type\":\"COTISATION\",\"id\":\"uuid\",\"montant\":5000}, ...]
*/
@Column(name = "objets_cibles", columnDefinition = "TEXT")
private String objetsCibles;
@Column(name = "date_expiration")
private LocalDateTime dateExpiration;
@Column(name = "date_completion")
private LocalDateTime dateCompletion;
// ── Méthodes métier ────────────────────────────────────────────────────────
public boolean isActive() {
return StatutIntentionPaiement.INITIEE.equals(statut)
|| StatutIntentionPaiement.EN_COURS.equals(statut);
}
public boolean isExpiree() {
return dateExpiration != null && LocalDateTime.now().isAfter(dateExpiration);
}
public boolean isCompletee() {
return StatutIntentionPaiement.COMPLETEE.equals(statut);
}
@PrePersist
protected void onCreate() {
super.onCreate();
if (statut == null) statut = StatutIntentionPaiement.INITIEE;
if (codeDevise == null) codeDevise = "XOF";
if (dateExpiration == null) {
dateExpiration = LocalDateTime.now().plusMinutes(30);
}
}
}

View File

@@ -1,6 +1,7 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.comptabilite.TypeJournalComptable; import dev.lions.unionflow.server.api.enums.comptabilite.TypeJournalComptable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@@ -69,6 +70,7 @@ public class JournalComptable extends BaseEntity {
private String description; private String description;
/** Écritures comptables associées */ /** Écritures comptables associées */
@JsonIgnore
@OneToMany(mappedBy = "journal", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "journal", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<EcritureComptable> ecritures = new ArrayList<>(); private List<EcritureComptable> ecritures = new ArrayList<>();

View File

@@ -1,29 +1,32 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.Email; import jakarta.validation.constraints.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/** 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 @Entity
@Table( @Table(name = "utilisateurs", indexes = {
name = "membres", @Index(name = "idx_utilisateur_email", columnList = "email", unique = true),
indexes = { @Index(name = "idx_utilisateur_numero", columnList = "numero_membre", unique = true),
@Index(name = "idx_membre_email", columnList = "email", unique = true), @Index(name = "idx_utilisateur_keycloak", columnList = "keycloak_id", unique = true),
@Index(name = "idx_membre_numero", columnList = "numero_membre", unique = true), @Index(name = "idx_utilisateur_actif", columnList = "actif"),
@Index(name = "idx_membre_actif", columnList = "actif") @Index(name = "idx_utilisateur_statut", columnList = "statut_compte")
}) })
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -31,6 +34,11 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class Membre extends BaseEntity { 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 @NotBlank
@Column(name = "numero_membre", unique = true, nullable = false, length = 20) @Column(name = "numero_membre", unique = true, nullable = false, length = 20)
private String numeroMembre; private String numeroMembre;
@@ -48,15 +56,10 @@ public class Membre extends BaseEntity {
@Column(name = "email", unique = true, nullable = false, length = 255) @Column(name = "email", unique = true, nullable = false, length = 255)
private String email; private String email;
@Column(name = "mot_de_passe", length = 255)
private String motDePasse;
@Column(name = "telephone", length = 20) @Column(name = "telephone", length = 20)
private String telephone; private String telephone;
@Pattern( @Pattern(regexp = "^\\+225[0-9]{8}$", message = "Le numéro Wave doit être au format +225XXXXXXXX")
regexp = "^\\+225[0-9]{8}$",
message = "Le numéro de téléphone Wave doit être au format +225XXXXXXXX")
@Column(name = "telephone_wave", length = 13) @Column(name = "telephone_wave", length = 13)
private String telephoneWave; private String telephoneWave;
@@ -64,43 +67,94 @@ public class Membre extends BaseEntity {
@Column(name = "date_naissance", nullable = false) @Column(name = "date_naissance", nullable = false)
private LocalDate dateNaissance; private LocalDate dateNaissance;
@NotNull @Column(name = "profession", length = 100)
@Column(name = "date_adhesion", nullable = false) private String profession;
private LocalDate dateAdhesion;
// Relations @Column(name = "photo_url", length = 500)
@ManyToOne(fetch = FetchType.LAZY) private String photoUrl;
@JoinColumn(name = "organisation_id")
private Organisation organisation;
@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) @OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<Adresse> adresses = new ArrayList<>(); private List<Adresse> adresses = new ArrayList<>();
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JsonIgnore
@Builder.Default
private List<MembreRole> roles = new ArrayList<>();
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<CompteWave> comptesWave = new ArrayList<>(); private List<CompteWave> comptesWave = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "membre", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<Paiement> paiements = new ArrayList<>(); private List<Paiement> paiements = new ArrayList<>();
/** Méthode métier pour obtenir le nom complet */ // ── Méthodes métier ───────────────────────────────────────────────────────
public String getNomComplet() { public String getNomComplet() {
return prenom + " " + nom; return prenom + " " + nom;
} }
/** Méthode métier pour vérifier si le membre est majeur */
public boolean isMajeur() { 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() { 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";
}
} }
} }

View File

@@ -0,0 +1,111 @@
package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import dev.lions.unionflow.server.api.enums.membre.StatutMembre;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import lombok.*;
/**
* Lien entre un utilisateur et une organisation.
*
* <p>Un utilisateur peut adhérer à plusieurs organisations simultanément.
* Chaque adhésion a son propre statut, date et unité d'affectation.
*
* <p>Table : {@code membres_organisations}
*/
@Entity
@Table(
name = "membres_organisations",
indexes = {
@Index(name = "idx_mo_utilisateur", columnList = "utilisateur_id"),
@Index(name = "idx_mo_organisation", columnList = "organisation_id"),
@Index(name = "idx_mo_statut", columnList = "statut_membre"),
@Index(name = "idx_mo_unite", columnList = "unite_id")
},
uniqueConstraints = {
@UniqueConstraint(
name = "uk_mo_utilisateur_organisation",
columnNames = {"utilisateur_id", "organisation_id"})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class MembreOrganisation extends BaseEntity {
/** L'utilisateur (identité globale) */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "utilisateur_id", nullable = false)
private Membre membre;
/** L'organisation racine à laquelle appartient ce membre */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
/**
* Unité d'affectation (agence/bureau).
* NULL = affecté au siège.
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "unite_id")
private Organisation unite;
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(name = "statut_membre", nullable = false, length = 30)
private StatutMembre statutMembre = StatutMembre.EN_ATTENTE_VALIDATION;
@Column(name = "date_adhesion")
private LocalDate dateAdhesion;
@Column(name = "date_changement_statut")
private LocalDate dateChangementStatut;
@Column(name = "motif_statut", length = 500)
private String motifStatut;
/** Utilisateur qui a approuvé ou traité ce changement de statut */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "approuve_par_id")
private Membre approuvePar;
// ── Relations ─────────────────────────────────────────────────────────────
/** Rôles de ce membre dans cette organisation */
@JsonIgnore
@OneToMany(mappedBy = "membreOrganisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<MembreRole> roles = new ArrayList<>();
/** Ayants droit (mutuelles de santé uniquement) */
@JsonIgnore
@OneToMany(mappedBy = "membreOrganisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<AyantDroit> ayantsDroit = new ArrayList<>();
// ── Méthodes métier ────────────────────────────────────────────────────────
public boolean isActif() {
return StatutMembre.ACTIF.equals(statutMembre) && Boolean.TRUE.equals(getActif());
}
public boolean peutDemanderAide() {
return StatutMembre.ACTIF.equals(statutMembre);
}
@PrePersist
protected void onCreate() {
super.onCreate();
if (statutMembre == null) {
statutMembre = StatutMembre.EN_ATTENTE_VALIDATION;
}
}
}

View File

@@ -21,14 +21,15 @@ import lombok.NoArgsConstructor;
@Table( @Table(
name = "membres_roles", name = "membres_roles",
indexes = { indexes = {
@Index(name = "idx_membre_role_membre", columnList = "membre_id"), @Index(name = "idx_mr_membre_org", columnList = "membre_organisation_id"),
@Index(name = "idx_membre_role_role", columnList = "role_id"), @Index(name = "idx_mr_organisation", columnList = "organisation_id"),
@Index(name = "idx_membre_role_actif", columnList = "actif") @Index(name = "idx_mr_role", columnList = "role_id"),
@Index(name = "idx_mr_actif", columnList = "actif")
}, },
uniqueConstraints = { uniqueConstraints = {
@UniqueConstraint( @UniqueConstraint(
name = "uk_membre_role", name = "uk_mr_membre_org_role",
columnNames = {"membre_id", "role_id"}) columnNames = {"membre_organisation_id", "role_id"})
}) })
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@@ -37,11 +38,16 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class MembreRole extends BaseEntity { public class MembreRole extends BaseEntity {
/** Membre */ /** Lien membership (utilisateur dans le contexte de son organisation) */
@NotNull @NotNull
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_id", nullable = false) @JoinColumn(name = "membre_organisation_id", nullable = false)
private Membre membre; private MembreOrganisation membreOrganisation;
/** Organisation dans laquelle ce rôle est actif (dénormalisé pour les requêtes) */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
/** Rôle */ /** Rôle */
@NotNull @NotNull

View File

@@ -0,0 +1,38 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.util.UUID;
/**
* Lien « suivi » entre deux membres : le membre connecté (follower) suit un autre membre (suivi).
* Utilisé pour la fonctionnalité Réseau / Suivre dans lapp mobile.
*/
@Entity
@Table(
name = "membre_suivi",
uniqueConstraints = @UniqueConstraint(columnNames = { "follower_utilisateur_id", "suivi_utilisateur_id" }),
indexes = {
@Index(name = "idx_membre_suivi_follower", columnList = "follower_utilisateur_id"),
@Index(name = "idx_membre_suivi_suivi", columnList = "suivi_utilisateur_id")
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class MembreSuivi extends BaseEntity {
/** Utilisateur qui suit (membre connecté). */
@NotNull
@Column(name = "follower_utilisateur_id", nullable = false)
private UUID followerUtilisateurId;
/** Utilisateur suivi (membre cible). */
@NotNull
@Column(name = "suivi_utilisateur_id", nullable = false)
private UUID suiviUtilisateurId;
}

View File

@@ -0,0 +1,56 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import lombok.*;
/**
* Catalogue des modules métier activables par type d'organisation.
*
* <p>Géré uniquement par le Super Admin UnionFlow.
* Les organisations ne peuvent pas créer de nouveaux modules.
*
* <p>Table : {@code modules_disponibles}
*/
@Entity
@Table(
name = "modules_disponibles",
indexes = {
@Index(name = "idx_module_code", columnList = "code", unique = true),
@Index(name = "idx_module_actif", columnList = "actif")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ModuleDisponible extends BaseEntity {
@NotBlank
@Column(name = "code", unique = true, nullable = false, length = 50)
private String code;
@NotBlank
@Column(name = "libelle", nullable = false, length = 150)
private String libelle;
@Column(name = "description", columnDefinition = "TEXT")
private String description;
/**
* JSON array des types d'organisations compatibles.
* Exemple : ["MUTUELLE_SANTE","ONG"] ou ["ALL"] pour tous.
*/
@Column(name = "types_org_compatibles", columnDefinition = "TEXT")
private String typesOrgCompatibles;
@Builder.Default
@Column(name = "ordre_affichage", nullable = false)
private Integer ordreAffichage = 0;
public boolean estCompatibleAvec(String typeOrganisation) {
if (typesOrgCompatibles == null) return false;
return typesOrgCompatibles.contains("ALL")
|| typesOrgCompatibles.contains(typeOrganisation);
}
}

View File

@@ -0,0 +1,64 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.time.LocalDateTime;
import lombok.*;
/**
* Module activé pour une organisation donnée.
*
* <p>
* Les modules sont activés automatiquement selon le type d'organisation
* lors de la première souscription, et peuvent être désactivés par le manager.
*
* <p>
* Table : {@code modules_organisation_actifs}
*/
@Entity
@Table(name = "modules_organisation_actifs", indexes = {
@Index(name = "idx_moa_organisation", columnList = "organisation_id"),
@Index(name = "idx_moa_module", columnList = "module_code")
}, uniqueConstraints = {
@UniqueConstraint(name = "uk_moa_org_module", columnNames = { "organisation_id", "module_code" })
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ModuleOrganisationActif extends BaseEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank
@Column(name = "module_code", nullable = false, length = 50)
private String moduleCode;
/**
* Référence vers le catalogue des modules.
* Assure l'intégrité référentielle avec
* {@code modules_disponibles}.
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "module_disponible_id")
private ModuleDisponible moduleDisponible;
@Builder.Default
@Column(name = "date_activation", nullable = false)
private LocalDateTime dateActivation = LocalDateTime.now();
/**
* Configuration JSON spécifique au module pour cette organisation.
* Exemple pour CREDIT_EPARGNE : {"taux_interet_max": 18, "duree_max_mois": 24}
*/
@Column(name = "parametres", columnDefinition = "TEXT")
private String parametres;
public boolean isActif() {
return Boolean.TRUE.equals(getActif());
}
}

View File

@@ -1,7 +1,5 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.notification.PrioriteNotification;
import dev.lions.unionflow.server.api.enums.notification.TypeNotification;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -19,16 +17,14 @@ import lombok.NoArgsConstructor;
* @since 2025-01-29 * @since 2025-01-29
*/ */
@Entity @Entity
@Table( @Table(name = "notifications", indexes = {
name = "notifications", @Index(name = "idx_notification_type", columnList = "type_notification"),
indexes = { @Index(name = "idx_notification_statut", columnList = "statut"),
@Index(name = "idx_notification_type", columnList = "type_notification"), @Index(name = "idx_notification_priorite", columnList = "priorite"),
@Index(name = "idx_notification_statut", columnList = "statut"), @Index(name = "idx_notification_membre", columnList = "membre_id"),
@Index(name = "idx_notification_priorite", columnList = "priorite"), @Index(name = "idx_notification_organisation", columnList = "organisation_id"),
@Index(name = "idx_notification_membre", columnList = "membre_id"), @Index(name = "idx_notification_date_envoi", columnList = "date_envoi")
@Index(name = "idx_notification_organisation", columnList = "organisation_id"), })
@Index(name = "idx_notification_date_envoi", columnList = "date_envoi")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -38,22 +34,18 @@ public class Notification extends BaseEntity {
/** Type de notification */ /** Type de notification */
@NotNull @NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_notification", nullable = false, length = 30) @Column(name = "type_notification", nullable = false, length = 30)
private TypeNotification typeNotification; private String typeNotification;
/** Priorité */ /** Priorité */
@Enumerated(EnumType.STRING)
@Builder.Default @Builder.Default
@Column(name = "priorite", length = 20) @Column(name = "priorite", length = 20)
private PrioriteNotification priorite = PrioriteNotification.NORMALE; private String priorite = "NORMALE";
/** Statut */ /** Statut */
@Enumerated(EnumType.STRING)
@Builder.Default @Builder.Default
@Column(name = "statut", length = 30) @Column(name = "statut", length = 30)
private dev.lions.unionflow.server.api.enums.notification.StatutNotification statut = private String statut = "EN_ATTENTE";
dev.lions.unionflow.server.api.enums.notification.StatutNotification.EN_ATTENTE;
/** Sujet */ /** Sujet */
@Column(name = "sujet", length = 500) @Column(name = "sujet", length = 500)
@@ -103,12 +95,12 @@ public class Notification extends BaseEntity {
/** Méthode métier pour vérifier si la notification est envoyée */ /** Méthode métier pour vérifier si la notification est envoyée */
public boolean isEnvoyee() { public boolean isEnvoyee() {
return dev.lions.unionflow.server.api.enums.notification.StatutNotification.ENVOYEE.equals(statut); return statut != null && dev.lions.unionflow.server.api.enums.notification.StatutNotification.ENVOYEE.name().equals(statut);
} }
/** Méthode métier pour vérifier si la notification est lue */ /** Méthode métier pour vérifier si la notification est lue */
public boolean isLue() { public boolean isLue() {
return dev.lions.unionflow.server.api.enums.notification.StatutNotification.LUE.equals(statut); return statut != null && dev.lions.unionflow.server.api.enums.notification.StatutNotification.LUE.name().equals(statut);
} }
/** Callback JPA avant la persistance */ /** Callback JPA avant la persistance */
@@ -116,10 +108,10 @@ public class Notification extends BaseEntity {
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
if (priorite == null) { if (priorite == null) {
priorite = PrioriteNotification.NORMALE; priorite = "NORMALE";
} }
if (statut == null) { if (statut == null) {
statut = dev.lions.unionflow.server.api.enums.notification.StatutNotification.EN_ATTENTE; statut = "EN_ATTENTE";
} }
if (nombreTentatives == null) { if (nombreTentatives == null) {
nombreTentatives = 0; nombreTentatives = 0;
@@ -129,4 +121,3 @@ public class Notification extends BaseEntity {
} }
} }
} }

View File

@@ -1,14 +1,13 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period; import java.time.Period;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@@ -16,7 +15,8 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* Entité Organisation avec UUID Représente une organisation (Lions Club, Association, * Entité Organisation avec UUID Représente une organisation (Lions Club,
* Association,
* Coopérative, etc.) * Coopérative, etc.)
* *
* @author UnionFlow Team * @author UnionFlow Team
@@ -24,21 +24,14 @@ import lombok.NoArgsConstructor;
* @since 2025-01-16 * @since 2025-01-16
*/ */
@Entity @Entity
@Table( @Table(name = "organisations", indexes = {
name = "organisations", @Index(name = "idx_organisation_nom", columnList = "nom"),
indexes = { @Index(name = "idx_organisation_email", columnList = "email", unique = true),
@Index(name = "idx_organisation_nom", columnList = "nom"), @Index(name = "idx_organisation_statut", columnList = "statut"),
@Index(name = "idx_organisation_email", columnList = "email", unique = true), @Index(name = "idx_organisation_type", columnList = "type_organisation"),
@Index(name = "idx_organisation_statut", columnList = "statut"), @Index(name = "idx_organisation_parente", columnList = "organisation_parente_id"),
@Index(name = "idx_organisation_type", columnList = "type_organisation"), @Index(name = "idx_organisation_numero_enregistrement", columnList = "numero_enregistrement", unique = true)
@Index(name = "idx_organisation_ville", columnList = "ville"), })
@Index(name = "idx_organisation_pays", columnList = "pays"),
@Index(name = "idx_organisation_parente", columnList = "organisation_parente_id"),
@Index(
name = "idx_organisation_numero_enregistrement",
columnList = "numero_enregistrement",
unique = true)
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -86,22 +79,22 @@ public class Organisation extends BaseEntity {
@Column(name = "email_secondaire", length = 255) @Column(name = "email_secondaire", length = 255)
private String emailSecondaire; private String emailSecondaire;
// Adresse // Adresse principale (champs dénormalisés pour performance)
@Column(name = "adresse", length = 500) @Column(name = "adresse", length = 500)
private String adresse; private String adresse;
@Column(name = "ville", length = 100) @Column(name = "ville", length = 100)
private String ville; private String ville;
@Column(name = "code_postal", length = 20)
private String codePostal;
@Column(name = "region", length = 100) @Column(name = "region", length = 100)
private String region; private String region;
@Column(name = "pays", length = 100) @Column(name = "pays", length = 100)
private String pays; private String pays;
@Column(name = "code_postal", length = 20)
private String codePostal;
// Coordonnées géographiques // Coordonnées géographiques
@DecimalMin(value = "-90.0", message = "La latitude doit être comprise entre -90 et 90") @DecimalMin(value = "-90.0", message = "La latitude doit être comprise entre -90 et 90")
@DecimalMax(value = "90.0", message = "La latitude doit être comprise entre -90 et 90") @DecimalMax(value = "90.0", message = "La latitude doit être comprise entre -90 et 90")
@@ -125,14 +118,32 @@ public class Organisation extends BaseEntity {
@Column(name = "reseaux_sociaux", length = 1000) @Column(name = "reseaux_sociaux", length = 1000)
private String reseauxSociaux; private String reseauxSociaux;
// Hiérarchie // ── Hiérarchie ──────────────────────────────────────────────────────────────
@Column(name = "organisation_parente_id")
private UUID organisationParenteId; /** Organisation parente — FK propre (null = organisation racine) */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_parente_id")
private Organisation organisationParente;
@Builder.Default @Builder.Default
@Column(name = "niveau_hierarchique", nullable = false) @Column(name = "niveau_hierarchique", nullable = false)
private Integer niveauHierarchique = 0; private Integer niveauHierarchique = 0;
/**
* TRUE si c'est l'organisation racine qui porte la souscription SaaS
* pour toute sa hiérarchie.
*/
@Builder.Default
@Column(name = "est_organisation_racine", nullable = false)
private Boolean estOrganisationRacine = true;
/**
* Chemin hiérarchique complet — ex: /uuid-racine/uuid-intermediate/uuid-feuille
* Permet des requêtes récursives optimisées sans CTE.
*/
@Column(name = "chemin_hierarchique", length = 2000)
private String cheminHierarchique;
// Statistiques // Statistiques
@Builder.Default @Builder.Default
@Column(name = "nombre_membres", nullable = false) @Column(name = "nombre_membres", nullable = false)
@@ -187,14 +198,19 @@ public class Organisation extends BaseEntity {
private Boolean accepteNouveauxMembres = true; private Boolean accepteNouveauxMembres = true;
// Relations // Relations
/** Adhésions des membres à cette organisation */
@JsonIgnore
@OneToMany(mappedBy = "organisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "organisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<Membre> membres = new ArrayList<>(); private List<MembreOrganisation> membresOrganisations = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "organisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "organisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<Adresse> adresses = new ArrayList<>(); private List<Adresse> adresses = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "organisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "organisation", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<CompteWave> comptesWave = new ArrayList<>(); private List<CompteWave> comptesWave = new ArrayList<>();
@@ -215,7 +231,9 @@ public class Organisation extends BaseEntity {
return Period.between(dateFondation, LocalDate.now()).getYears(); return Period.between(dateFondation, LocalDate.now()).getYears();
} }
/** Méthode métier pour vérifier si l'organisation est récente (moins de 2 ans) */ /**
* Méthode métier pour vérifier si l'organisation est récente (moins de 2 ans)
*/
public boolean isRecente() { public boolean isRecente() {
return getAncienneteAnnees() < 2; return getAncienneteAnnees() < 2;
} }
@@ -262,17 +280,6 @@ public class Organisation extends BaseEntity {
marquerCommeModifie(utilisateur); marquerCommeModifie(utilisateur);
} }
/** Marque l'entité comme modifiée */
public void marquerCommeModifie(String utilisateur) {
this.setDateModification(LocalDateTime.now());
this.setModifiePar(utilisateur);
if (this.getVersion() != null) {
this.setVersion(this.getVersion() + 1);
} else {
this.setVersion(1L);
}
}
/** Callback JPA avant la persistance */ /** Callback JPA avant la persistance */
@PrePersist @PrePersist
protected void onCreate() { protected void onCreate() {
@@ -289,6 +296,9 @@ public class Organisation extends BaseEntity {
if (niveauHierarchique == null) { if (niveauHierarchique == null) {
niveauHierarchique = 0; niveauHierarchique = 0;
} }
if (estOrganisationRacine == null) {
estOrganisationRacine = (organisationParente == null);
}
if (nombreMembres == null) { if (nombreMembres == null) {
nombreMembres = 0; nombreMembres = 0;
} }

View File

@@ -1,7 +1,6 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.paiement.MethodePaiement; import com.fasterxml.jackson.annotation.JsonIgnore;
import dev.lions.unionflow.server.api.enums.paiement.StatutPaiement;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -23,15 +22,13 @@ import lombok.NoArgsConstructor;
* @since 2025-01-29 * @since 2025-01-29
*/ */
@Entity @Entity
@Table( @Table(name = "paiements", indexes = {
name = "paiements", @Index(name = "idx_paiement_numero_reference", columnList = "numero_reference", unique = true),
indexes = { @Index(name = "idx_paiement_membre", columnList = "membre_id"),
@Index(name = "idx_paiement_numero_reference", columnList = "numero_reference", unique = true), @Index(name = "idx_paiement_statut", columnList = "statut_paiement"),
@Index(name = "idx_paiement_membre", columnList = "membre_id"), @Index(name = "idx_paiement_methode", columnList = "methode_paiement"),
@Index(name = "idx_paiement_statut", columnList = "statut_paiement"), @Index(name = "idx_paiement_date", columnList = "date_paiement")
@Index(name = "idx_paiement_methode", columnList = "methode_paiement"), })
@Index(name = "idx_paiement_date", columnList = "date_paiement")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -59,16 +56,14 @@ public class Paiement extends BaseEntity {
/** Méthode de paiement */ /** Méthode de paiement */
@NotNull @NotNull
@Enumerated(EnumType.STRING)
@Column(name = "methode_paiement", nullable = false, length = 50) @Column(name = "methode_paiement", nullable = false, length = 50)
private MethodePaiement methodePaiement; private String methodePaiement;
/** Statut du paiement */ /** Statut du paiement */
@NotNull @NotNull
@Enumerated(EnumType.STRING)
@Builder.Default @Builder.Default
@Column(name = "statut_paiement", nullable = false, length = 30) @Column(name = "statut_paiement", nullable = false, length = 30)
private StatutPaiement statutPaiement = StatutPaiement.EN_ATTENTE; private String statutPaiement = "EN_ATTENTE";
/** Date de paiement */ /** Date de paiement */
@Column(name = "date_paiement") @Column(name = "date_paiement")
@@ -108,22 +103,11 @@ public class Paiement extends BaseEntity {
@JoinColumn(name = "membre_id", nullable = false) @JoinColumn(name = "membre_id", nullable = false)
private Membre membre; private Membre membre;
/** Relations avec les tables de liaison */ /** Objets cibles de ce paiement (Cat.2 — polymorphique) */
@JsonIgnore
@OneToMany(mappedBy = "paiement", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "paiement", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<PaiementCotisation> paiementsCotisation = new ArrayList<>(); private List<PaiementObjet> paiementsObjets = new ArrayList<>();
@OneToMany(mappedBy = "paiement", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<PaiementAdhesion> paiementsAdhesion = new ArrayList<>();
@OneToMany(mappedBy = "paiement", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<PaiementEvenement> paiementsEvenement = new ArrayList<>();
@OneToMany(mappedBy = "paiement", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default
private List<PaiementAide> paiementsAide = new ArrayList<>();
/** Relation avec TransactionWave (optionnelle) */ /** Relation avec TransactionWave (optionnelle) */
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@@ -140,30 +124,28 @@ public class Paiement extends BaseEntity {
/** Méthode métier pour vérifier si le paiement est validé */ /** Méthode métier pour vérifier si le paiement est validé */
public boolean isValide() { public boolean isValide() {
return StatutPaiement.VALIDE.equals(statutPaiement); return "VALIDE".equals(statutPaiement);
} }
/** Méthode métier pour vérifier si le paiement peut être modifié */ /** Vérifie si le paiement peut être modifié */
public boolean peutEtreModifie() { public boolean peutEtreModifie() {
return !statutPaiement.isFinalise(); return !"VALIDE".equals(statutPaiement)
&& !"ANNULE".equals(statutPaiement);
} }
/** Callback JPA avant la persistance */ /** Callback JPA avant la persistance */
@PrePersist @PrePersist
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
if (numeroReference == null || numeroReference.isEmpty()) { if (numeroReference == null
|| numeroReference.isEmpty()) {
numeroReference = genererNumeroReference(); numeroReference = genererNumeroReference();
} }
if (codeDevise == null || codeDevise.isEmpty()) {
codeDevise = "XOF";
}
if (statutPaiement == null) { if (statutPaiement == null) {
statutPaiement = StatutPaiement.EN_ATTENTE; statutPaiement = "EN_ATTENTE";
} }
if (datePaiement == null) { if (datePaiement == null) {
datePaiement = LocalDateTime.now(); datePaiement = LocalDateTime.now();
} }
} }
} }

View File

@@ -1,75 +0,0 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Table de liaison entre Paiement et Adhesion
*
* @author UnionFlow Team
* @version 3.0
* @since 2025-01-29
*/
@Entity
@Table(
name = "paiements_adhesions",
indexes = {
@Index(name = "idx_paiement_adhesion_paiement", columnList = "paiement_id"),
@Index(name = "idx_paiement_adhesion_adhesion", columnList = "adhesion_id")
},
uniqueConstraints = {
@UniqueConstraint(
name = "uk_paiement_adhesion",
columnNames = {"paiement_id", "adhesion_id"})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class PaiementAdhesion extends BaseEntity {
/** Paiement */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "paiement_id", nullable = false)
private Paiement paiement;
/** Adhésion */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "adhesion_id", nullable = false)
private Adhesion adhesion;
/** Montant appliqué à cette adhésion */
@NotNull
@DecimalMin(value = "0.0", message = "Le montant appliqué doit être positif")
@Digits(integer = 12, fraction = 2)
@Column(name = "montant_applique", nullable = false, precision = 14, scale = 2)
private BigDecimal montantApplique;
/** Date d'application */
@Column(name = "date_application")
private LocalDateTime dateApplication;
/** Commentaire sur l'application */
@Column(name = "commentaire", length = 500)
private String commentaire;
/** Callback JPA avant la persistance */
@PrePersist
protected void onCreate() {
super.onCreate();
if (dateApplication == null) {
dateApplication = LocalDateTime.now();
}
}
}

View File

@@ -1,75 +0,0 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Table de liaison entre Paiement et DemandeAide
*
* @author UnionFlow Team
* @version 3.0
* @since 2025-01-29
*/
@Entity
@Table(
name = "paiements_aides",
indexes = {
@Index(name = "idx_paiement_aide_paiement", columnList = "paiement_id"),
@Index(name = "idx_paiement_aide_demande", columnList = "demande_aide_id")
},
uniqueConstraints = {
@UniqueConstraint(
name = "uk_paiement_aide",
columnNames = {"paiement_id", "demande_aide_id"})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class PaiementAide extends BaseEntity {
/** Paiement */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "paiement_id", nullable = false)
private Paiement paiement;
/** Demande d'aide */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "demande_aide_id", nullable = false)
private DemandeAide demandeAide;
/** Montant appliqué à cette demande d'aide */
@NotNull
@DecimalMin(value = "0.0", message = "Le montant appliqué doit être positif")
@Digits(integer = 12, fraction = 2)
@Column(name = "montant_applique", nullable = false, precision = 14, scale = 2)
private BigDecimal montantApplique;
/** Date d'application */
@Column(name = "date_application")
private LocalDateTime dateApplication;
/** Commentaire sur l'application */
@Column(name = "commentaire", length = 500)
private String commentaire;
/** Callback JPA avant la persistance */
@PrePersist
protected void onCreate() {
super.onCreate();
if (dateApplication == null) {
dateApplication = LocalDateTime.now();
}
}
}

View File

@@ -1,76 +0,0 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Table de liaison entre Paiement et Cotisation
* Permet à un paiement de couvrir plusieurs cotisations
*
* @author UnionFlow Team
* @version 3.0
* @since 2025-01-29
*/
@Entity
@Table(
name = "paiements_cotisations",
indexes = {
@Index(name = "idx_paiement_cotisation_paiement", columnList = "paiement_id"),
@Index(name = "idx_paiement_cotisation_cotisation", columnList = "cotisation_id")
},
uniqueConstraints = {
@UniqueConstraint(
name = "uk_paiement_cotisation",
columnNames = {"paiement_id", "cotisation_id"})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class PaiementCotisation extends BaseEntity {
/** Paiement */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "paiement_id", nullable = false)
private Paiement paiement;
/** Cotisation */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cotisation_id", nullable = false)
private Cotisation cotisation;
/** Montant appliqué à cette cotisation */
@NotNull
@DecimalMin(value = "0.0", message = "Le montant appliqué doit être positif")
@Digits(integer = 12, fraction = 2)
@Column(name = "montant_applique", nullable = false, precision = 14, scale = 2)
private BigDecimal montantApplique;
/** Date d'application */
@Column(name = "date_application")
private LocalDateTime dateApplication;
/** Commentaire sur l'application */
@Column(name = "commentaire", length = 500)
private String commentaire;
/** Callback JPA avant la persistance */
@PrePersist
protected void onCreate() {
super.onCreate();
if (dateApplication == null) {
dateApplication = LocalDateTime.now();
}
}
}

View File

@@ -1,75 +0,0 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Table de liaison entre Paiement et InscriptionEvenement
*
* @author UnionFlow Team
* @version 3.0
* @since 2025-01-29
*/
@Entity
@Table(
name = "paiements_evenements",
indexes = {
@Index(name = "idx_paiement_evenement_paiement", columnList = "paiement_id"),
@Index(name = "idx_paiement_evenement_inscription", columnList = "inscription_evenement_id")
},
uniqueConstraints = {
@UniqueConstraint(
name = "uk_paiement_evenement",
columnNames = {"paiement_id", "inscription_evenement_id"})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class PaiementEvenement extends BaseEntity {
/** Paiement */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "paiement_id", nullable = false)
private Paiement paiement;
/** Inscription à l'événement */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "inscription_evenement_id", nullable = false)
private InscriptionEvenement inscriptionEvenement;
/** Montant appliqué à cette inscription */
@NotNull
@DecimalMin(value = "0.0", message = "Le montant appliqué doit être positif")
@Digits(integer = 12, fraction = 2)
@Column(name = "montant_applique", nullable = false, precision = 14, scale = 2)
private BigDecimal montantApplique;
/** Date d'application */
@Column(name = "date_application")
private LocalDateTime dateApplication;
/** Commentaire sur l'application */
@Column(name = "commentaire", length = 500)
private String commentaire;
/** Callback JPA avant la persistance */
@PrePersist
protected void onCreate() {
super.onCreate();
if (dateApplication == null) {
dateApplication = LocalDateTime.now();
}
}
}

View File

@@ -0,0 +1,130 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Table de liaison polymorphique entre un paiement
* et son objet cible.
*
* <p>
* Remplace les 4 tables dupliquées
* {@code paiements_cotisations},
* {@code paiements_adhesions},
* {@code paiements_evenements} et
* {@code paiements_aides} par une table unique
* utilisant le pattern
* {@code (type_objet_cible, objet_cible_id)}.
*
* <p>
* Les types d'objet cible sont définis dans le
* domaine {@code OBJET_PAIEMENT} de la table
* {@code types_reference} (ex: COTISATION,
* ADHESION, EVENEMENT, AIDE).
*
* @author UnionFlow Team
* @version 3.0
* @since 2026-02-21
*/
@Entity
@Table(name = "paiements_objets", indexes = {
@Index(name = "idx_po_paiement", columnList = "paiement_id"),
@Index(name = "idx_po_objet", columnList = "type_objet_cible,"
+ " objet_cible_id"),
@Index(name = "idx_po_type", columnList = "type_objet_cible")
}, uniqueConstraints = {
@UniqueConstraint(name = "uk_paiement_objet", columnNames = {
"paiement_id",
"type_objet_cible",
"objet_cible_id"
})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class PaiementObjet extends BaseEntity {
/** Paiement parent. */
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "paiement_id", nullable = false)
private Paiement paiement;
/**
* Type de l'objet cible (code du domaine
* {@code OBJET_PAIEMENT} dans
* {@code types_reference}).
*
* <p>
* Valeurs attendues : {@code COTISATION},
* {@code ADHESION}, {@code EVENEMENT},
* {@code AIDE}.
*/
@NotBlank
@Size(max = 50)
@Column(name = "type_objet_cible", nullable = false, length = 50)
private String typeObjetCible;
/**
* UUID de l'objet cible (cotisation, demande
* d'adhésion, inscription événement, ou demande
* d'aide).
*/
@NotNull
@Column(name = "objet_cible_id", nullable = false)
private UUID objetCibleId;
/** Montant appliqué à cet objet cible. */
@NotNull
@DecimalMin(value = "0.0", message = "Le montant doit être positif")
@Digits(integer = 12, fraction = 2)
@Column(name = "montant_applique", nullable = false, precision = 14, scale = 2)
private BigDecimal montantApplique;
/** Date d'application du paiement. */
@Column(name = "date_application")
private LocalDateTime dateApplication;
/** Commentaire sur l'application. */
@Size(max = 500)
@Column(name = "commentaire", length = 500)
private String commentaire;
/**
* Callback JPA avant la persistance.
*
* <p>
* Initialise {@code dateApplication} si non
* renseignée.
*/
@Override
@PrePersist
protected void onCreate() {
super.onCreate();
if (dateApplication == null) {
dateApplication = LocalDateTime.now();
}
}
}

View File

@@ -0,0 +1,85 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import lombok.*;
/**
* Paramètres de cotisation configurés par le manager de chaque organisation.
*
* <p>
* Le manager peut définir :
* <ul>
* <li>Le montant mensuel et annuel fixé pour tous les membres</li>
* <li>La date de départ du calcul des impayés (configurable)</li>
* <li>Le délai en jours avant passage automatique en statut INACTIF</li>
* </ul>
*
* <p>
* Table : {@code parametres_cotisation_organisation}
*/
@Entity
@Table(name = "parametres_cotisation_organisation", indexes = {
@Index(name = "idx_param_cot_org", columnList = "organisation_id", unique = true)
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ParametresCotisationOrganisation extends BaseEntity {
@NotNull
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false, unique = true)
private Organisation organisation;
@Builder.Default
@DecimalMin("0.00")
@Digits(integer = 10, fraction = 2)
@Column(name = "montant_cotisation_mensuelle", precision = 12, scale = 2)
private BigDecimal montantCotisationMensuelle = BigDecimal.ZERO;
@Builder.Default
@DecimalMin("0.00")
@Digits(integer = 10, fraction = 2)
@Column(name = "montant_cotisation_annuelle", precision = 12, scale = 2)
private BigDecimal montantCotisationAnnuelle = BigDecimal.ZERO;
@Column(name = "devise", nullable = false, length = 3)
private String devise;
/**
* Date de référence pour le calcul des membres «à jour».
* Toutes les échéances depuis cette date doivent être payées.
* Configurable par le manager.
*/
@Column(name = "date_debut_calcul_ajour")
private LocalDate dateDebutCalculAjour;
/**
* Nombre de jours de retard avant passage automatique du statut membre →
* INACTIF.
* Défaut : 30 jours.
*/
@Builder.Default
@Min(1)
@Column(name = "delai_retard_avant_inactif_jours", nullable = false)
private Integer delaiRetardAvantInactifJours = 30;
@Builder.Default
@Column(name = "cotisation_obligatoire", nullable = false)
private Boolean cotisationObligatoire = true;
// ── Méthodes métier ────────────────────────────────────────────────────────
/**
* Vérifie si la date de référence pour les impayés est définie.
* Sans cette date, aucun calcul d'ancienneté des impayés n'est possible.
*/
public boolean isCalculAjourActive() {
return dateDebutCalculAjour != null;
}
}

View File

@@ -0,0 +1,36 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import lombok.*;
import java.math.BigDecimal;
import java.util.UUID;
/**
* Paramètres LCB-FT par organisation ou globaux (organisationId null).
* Seuils au-dessus desquels l'origine des fonds est obligatoire / validation manuelle.
*/
@Entity
@Table(name = "parametres_lcb_ft", indexes = {
@Index(name = "idx_param_lcb_ft_org", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ParametresLcbFt extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
@Column(name = "code_devise", nullable = false, length = 3)
private String codeDevise;
@Column(name = "montant_seuil_justification", nullable = false, precision = 18, scale = 4)
private BigDecimal montantSeuilJustification;
@Column(name = "montant_seuil_validation_manuelle", precision = 18, scale = 4)
private BigDecimal montantSeuilValidationManuelle;
}

View File

@@ -1,5 +1,6 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import java.util.ArrayList; import java.util.ArrayList;
@@ -61,6 +62,7 @@ public class Permission extends BaseEntity {
private String description; private String description;
/** Rôles associés */ /** Rôles associés */
@JsonIgnore
@OneToMany(mappedBy = "permission", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "permission", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<RolePermission> roles = new ArrayList<>(); private List<RolePermission> roles = new ArrayList<>();

View File

@@ -1,7 +1,18 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import jakarta.persistence.*; import jakarta.persistence.Column;
import jakarta.validation.constraints.*; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.UUID;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@@ -9,24 +20,34 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* Entité PieceJointe pour l'association flexible de documents * Association polymorphique entre un document et
* une entité métier quelconque.
*
* <p>
* Remplace les 6 FK nullables mutuellement
* exclusives (membre, organisation, cotisation,
* adhesion, demandeAide, transactionWave) par un
* couple {@code (type_entite_rattachee,
* entite_rattachee_id)}.
*
* <p>
* Les types autorisés sont définis dans le
* domaine {@code ENTITE_RATTACHEE} de la table
* {@code types_reference} (ex: MEMBRE,
* ORGANISATION, COTISATION, ADHESION, AIDE,
* TRANSACTION_WAVE).
* *
* @author UnionFlow Team * @author UnionFlow Team
* @version 3.0 * @version 3.0
* @since 2025-01-29 * @since 2026-02-21
*/ */
@Entity @Entity
@Table( @Table(name = "pieces_jointes", indexes = {
name = "pieces_jointes", @Index(name = "idx_pj_document", columnList = "document_id"),
indexes = { @Index(name = "idx_pj_entite", columnList = "type_entite_rattachee,"
@Index(name = "idx_piece_jointe_document", columnList = "document_id"), + " entite_rattachee_id"),
@Index(name = "idx_piece_jointe_membre", columnList = "membre_id"), @Index(name = "idx_pj_type_entite", columnList = "type_entite_rattachee")
@Index(name = "idx_piece_jointe_organisation", columnList = "organisation_id"), })
@Index(name = "idx_piece_jointe_cotisation", columnList = "cotisation_id"),
@Index(name = "idx_piece_jointe_adhesion", columnList = "adhesion_id"),
@Index(name = "idx_piece_jointe_demande_aide", columnList = "demande_aide_id"),
@Index(name = "idx_piece_jointe_transaction_wave", columnList = "transaction_wave_id")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -34,70 +55,68 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class PieceJointe extends BaseEntity { public class PieceJointe extends BaseEntity {
/** Ordre d'affichage */ /** Ordre d'affichage. */
@NotNull @NotNull
@Min(value = 1, message = "L'ordre doit être positif") @Min(value = 1, message = "L'ordre doit être positif")
@Column(name = "ordre", nullable = false) @Column(name = "ordre", nullable = false)
private Integer ordre; private Integer ordre;
/** Libellé de la pièce jointe */ /** Libellé de la pièce jointe. */
@Size(max = 200)
@Column(name = "libelle", length = 200) @Column(name = "libelle", length = 200)
private String libelle; private String libelle;
/** Commentaire */ /** Commentaire. */
@Size(max = 500)
@Column(name = "commentaire", length = 500) @Column(name = "commentaire", length = 500)
private String commentaire; private String commentaire;
/** Document associé */ /** Document associé (obligatoire). */
@NotNull @NotNull
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "document_id", nullable = false) @JoinColumn(name = "document_id", nullable = false)
private Document document; private Document document;
// Relations flexibles (une seule doit être renseignée) /**
@ManyToOne(fetch = FetchType.LAZY) * Type de l'entité rattachée (code du domaine
@JoinColumn(name = "membre_id") * {@code ENTITE_RATTACHEE} dans
private Membre membre; * {@code types_reference}).
*
* <p>
* Valeurs attendues : {@code MEMBRE},
* {@code ORGANISATION}, {@code COTISATION},
* {@code ADHESION}, {@code AIDE},
* {@code TRANSACTION_WAVE}.
*/
@NotBlank
@Size(max = 50)
@Column(name = "type_entite_rattachee", nullable = false, length = 50)
private String typeEntiteRattachee;
@ManyToOne(fetch = FetchType.LAZY) /**
@JoinColumn(name = "organisation_id") * UUID de l'entité rattachée (membre,
private Organisation organisation; * organisation, cotisation, etc.).
*/
@NotNull
@Column(name = "entite_rattachee_id", nullable = false)
private UUID entiteRattacheeId;
@ManyToOne(fetch = FetchType.LAZY) /**
@JoinColumn(name = "cotisation_id") * Callback JPA avant la persistance.
private Cotisation cotisation; *
* <p>
@ManyToOne(fetch = FetchType.LAZY) * Initialise {@code ordre} à 1 si non
@JoinColumn(name = "adhesion_id") * renseigné. Normalise le type en majuscules.
private Adhesion adhesion; */
@Override
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "demande_aide_id")
private DemandeAide demandeAide;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "transaction_wave_id")
private TransactionWave transactionWave;
/** Méthode métier pour vérifier qu'une seule relation est renseignée */
public boolean isValide() {
int count = 0;
if (membre != null) count++;
if (organisation != null) count++;
if (cotisation != null) count++;
if (adhesion != null) count++;
if (demandeAide != null) count++;
if (transactionWave != null) count++;
return count == 1; // Exactement une relation doit être renseignée
}
/** Callback JPA avant la persistance */
@PrePersist @PrePersist
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
if (ordre == null) { if (ordre == null) {
ordre = 1; ordre = 1;
} }
if (typeEntiteRattachee != null) {
typeEntiteRattachee = typeEntiteRattachee.toUpperCase();
}
} }
} }

View File

@@ -1,5 +1,6 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@@ -15,17 +16,15 @@ import lombok.NoArgsConstructor;
* Entité Role pour la gestion des rôles dans le système * Entité Role pour la gestion des rôles dans le système
* *
* @author UnionFlow Team * @author UnionFlow Team
* @version 3.0 * @version 3.1
* @since 2025-01-29 * @since 2025-01-29
*/ */
@Entity @Entity
@Table( @Table(name = "roles", indexes = {
name = "roles", @Index(name = "idx_role_code", columnList = "code", unique = true),
indexes = { @Index(name = "idx_role_actif", columnList = "actif"),
@Index(name = "idx_role_code", columnList = "code", unique = true), @Index(name = "idx_role_niveau", columnList = "niveau_hierarchique")
@Index(name = "idx_role_actif", columnList = "actif"), })
@Index(name = "idx_role_niveau", columnList = "niveau_hierarchique")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -53,10 +52,9 @@ public class Role extends BaseEntity {
@Column(name = "niveau_hierarchique", nullable = false) @Column(name = "niveau_hierarchique", nullable = false)
private Integer niveauHierarchique = 100; private Integer niveauHierarchique = 100;
/** Type de rôle */ /** Type de rôle (SYSTEME, ORGANISATION, PERSONNALISE) */
@Enumerated(EnumType.STRING)
@Column(name = "type_role", nullable = false, length = 50) @Column(name = "type_role", nullable = false, length = 50)
private TypeRole typeRole; private String typeRole;
/** Organisation propriétaire (null pour rôles système) */ /** Organisation propriétaire (null pour rôles système) */
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@@ -64,30 +62,21 @@ public class Role extends BaseEntity {
private Organisation organisation; private Organisation organisation;
/** Permissions associées */ /** Permissions associées */
@JsonIgnore
@OneToMany(mappedBy = "role", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "role", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<RolePermission> permissions = new ArrayList<>(); private List<RolePermission> permissions = new ArrayList<>();
/** Énumération des types de rôle */ /** Énumération des constantes de types de rôle */
public enum TypeRole { public enum TypeRole {
SYSTEME("Rôle Système"), SYSTEME,
ORGANISATION("Rôle Organisation"), ORGANISATION,
PERSONNALISE("Rôle Personnalisé"); PERSONNALISE;
private final String libelle;
TypeRole(String libelle) {
this.libelle = libelle;
}
public String getLibelle() {
return libelle;
}
} }
/** Méthode métier pour vérifier si c'est un rôle système */ /** Méthode métier pour vérifier si c'est un rôle système */
public boolean isRoleSysteme() { public boolean isRoleSysteme() {
return TypeRole.SYSTEME.equals(typeRole); return TypeRole.SYSTEME.name().equals(typeRole);
} }
/** Callback JPA avant la persistance */ /** Callback JPA avant la persistance */
@@ -95,11 +84,10 @@ public class Role extends BaseEntity {
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
if (typeRole == null) { if (typeRole == null) {
typeRole = TypeRole.PERSONNALISE; typeRole = TypeRole.PERSONNALISE.name();
} }
if (niveauHierarchique == null) { if (niveauHierarchique == null) {
niveauHierarchique = 100; niveauHierarchique = 100;
} }
} }
} }

View File

@@ -0,0 +1,120 @@
package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.abonnement.StatutSouscription;
import dev.lions.unionflow.server.api.enums.abonnement.TypePeriodeAbonnement;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.time.LocalDate;
import lombok.*;
/**
* Abonnement actif d'une organisation racine à un forfait UnionFlow.
*
* <p>Règle clé : quand {@code quotaUtilise >= quotaMax}, toute nouvelle
* validation d'adhésion est bloquée avec un message explicite.
* Le manager peut upgrader son forfait à tout moment.
*
* <p>Table : {@code souscriptions_organisation}
*/
@Entity
@Table(
name = "souscriptions_organisation",
indexes = {
@Index(name = "idx_souscription_org", columnList = "organisation_id", unique = true),
@Index(name = "idx_souscription_statut", columnList = "statut"),
@Index(name = "idx_souscription_fin", columnList = "date_fin")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class SouscriptionOrganisation extends BaseEntity {
/** Organisation racine abonnée (une seule souscription active par org) */
@NotNull
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false, unique = true)
private Organisation organisation;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "formule_id", nullable = false)
private FormuleAbonnement formule;
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(name = "type_periode", nullable = false, length = 10)
private TypePeriodeAbonnement typePeriode = TypePeriodeAbonnement.MENSUEL;
@NotNull
@Column(name = "date_debut", nullable = false)
private LocalDate dateDebut;
@NotNull
@Column(name = "date_fin", nullable = false)
private LocalDate dateFin;
/** Snapshot du quota max au moment de la souscription */
@Column(name = "quota_max")
private Integer quotaMax;
/** Compteur incrémenté à chaque adhésion validée */
@Builder.Default
@Min(0)
@Column(name = "quota_utilise", nullable = false)
private Integer quotaUtilise = 0;
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(name = "statut", nullable = false, length = 30)
private StatutSouscription statut = StatutSouscription.ACTIVE;
@Column(name = "reference_paiement_wave", length = 100)
private String referencePaiementWave;
@Column(name = "wave_session_id", length = 255)
private String waveSessionId;
@Column(name = "date_dernier_paiement")
private LocalDate dateDernierPaiement;
@Column(name = "date_prochain_paiement")
private LocalDate dateProchainePaiement;
// ── Méthodes métier ────────────────────────────────────────────────────────
public boolean isActive() {
return StatutSouscription.ACTIVE.equals(statut)
&& LocalDate.now().isBefore(dateFin.plusDays(1));
}
public boolean isQuotaDepasse() {
return quotaMax != null && quotaUtilise >= quotaMax;
}
public int getPlacesRestantes() {
if (quotaMax == null) return Integer.MAX_VALUE;
return Math.max(0, quotaMax - quotaUtilise);
}
/** Incrémente le quota lors de la validation d'une adhésion */
public void incrementerQuota() {
if (quotaUtilise == null) quotaUtilise = 0;
quotaUtilise++;
}
/** Décrémente le quota lors de la radiation d'un membre */
public void decrementerQuota() {
if (quotaUtilise != null && quotaUtilise > 0) quotaUtilise--;
}
@PrePersist
protected void onCreate() {
super.onCreate();
if (statut == null) statut = StatutSouscription.ACTIVE;
if (typePeriode == null) typePeriode = TypePeriodeAbonnement.MENSUEL;
if (quotaUtilise == null) quotaUtilise = 0;
if (formule != null && quotaMax == null) quotaMax = formule.getMaxMembres();
}
}

View File

@@ -0,0 +1,91 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.UUID;
/**
* Entité Suggestion pour la gestion des suggestions utilisateur
*
* @author UnionFlow Team
* @version 1.0
*/
@Entity
@Table(
name = "suggestions",
indexes = {
@Index(name = "idx_suggestion_utilisateur", columnList = "utilisateur_id"),
@Index(name = "idx_suggestion_statut", columnList = "statut"),
@Index(name = "idx_suggestion_categorie", columnList = "categorie")
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Suggestion extends BaseEntity {
@NotNull
@Column(name = "utilisateur_id", nullable = false)
private UUID utilisateurId;
@Column(name = "utilisateur_nom", length = 255)
private String utilisateurNom;
@NotBlank
@Column(name = "titre", nullable = false, length = 255)
private String titre;
@Column(name = "description", columnDefinition = "TEXT")
private String description;
@Column(name = "justification", columnDefinition = "TEXT")
private String justification;
@Column(name = "categorie", length = 50)
private String categorie; // UI, FEATURE, PERFORMANCE, SECURITE, INTEGRATION, MOBILE, REPORTING
@Column(name = "priorite_estimee", length = 50)
private String prioriteEstimee; // BASSE, MOYENNE, HAUTE, CRITIQUE
@Column(name = "statut", length = 50)
@Builder.Default
private String statut = "NOUVELLE"; // NOUVELLE, EVALUATION, APPROUVEE, DEVELOPPEMENT, IMPLEMENTEE, REJETEE
@Column(name = "nb_votes")
@Builder.Default
private Integer nbVotes = 0;
@Column(name = "nb_commentaires")
@Builder.Default
private Integer nbCommentaires = 0;
@Column(name = "nb_vues")
@Builder.Default
private Integer nbVues = 0;
@Column(name = "date_soumission")
private LocalDateTime dateSoumission;
@Column(name = "date_evaluation")
private LocalDateTime dateEvaluation;
@Column(name = "date_implementation")
private LocalDateTime dateImplementation;
@Column(name = "version_ciblee", length = 50)
private String versionCiblee;
@Column(name = "mise_a_jour", columnDefinition = "TEXT")
private String miseAJour;
}

View File

@@ -0,0 +1,66 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.UUID;
/**
* Entité SuggestionVote pour gérer les votes sur les suggestions
*
* <p>Permet d'éviter qu'un utilisateur vote plusieurs fois pour la même suggestion.
* La contrainte d'unicité (suggestion_id, utilisateur_id) est gérée au niveau de la base de données.
*
* @author UnionFlow Team
* @version 1.0
*/
@Entity
@Table(
name = "suggestion_votes",
uniqueConstraints = {
@UniqueConstraint(
name = "uk_suggestion_vote",
columnNames = {"suggestion_id", "utilisateur_id"}
)
},
indexes = {
@Index(name = "idx_vote_suggestion", columnList = "suggestion_id"),
@Index(name = "idx_vote_utilisateur", columnList = "utilisateur_id")
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class SuggestionVote extends BaseEntity {
@NotNull
@Column(name = "suggestion_id", nullable = false)
private UUID suggestionId;
@NotNull
@Column(name = "utilisateur_id", nullable = false)
private UUID utilisateurId;
@Column(name = "date_vote", nullable = false)
@Builder.Default
private LocalDateTime dateVote = LocalDateTime.now();
@PrePersist
protected void onPrePersist() {
if (dateVote == null) {
dateVote = LocalDateTime.now();
}
if (getDateCreation() == null) {
setDateCreation(LocalDateTime.now());
}
}
}

View File

@@ -1,5 +1,6 @@
package dev.lions.unionflow.server.entity; package dev.lions.unionflow.server.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import java.util.ArrayList; import java.util.ArrayList;
@@ -65,6 +66,7 @@ public class TemplateNotification extends BaseEntity {
private String description; private String description;
/** Notifications utilisant ce template */ /** Notifications utilisant ce template */
@JsonIgnore
@OneToMany(mappedBy = "template", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "template", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<Notification> notifications = new ArrayList<>(); private List<Notification> notifications = new ArrayList<>();

View File

@@ -0,0 +1,92 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.UUID;
/**
* Entité Ticket pour la gestion des tickets support
*
* @author UnionFlow Team
* @version 1.0
*/
@Entity
@Table(
name = "tickets",
indexes = {
@Index(name = "idx_ticket_utilisateur", columnList = "utilisateur_id"),
@Index(name = "idx_ticket_statut", columnList = "statut"),
@Index(name = "idx_ticket_categorie", columnList = "categorie"),
@Index(name = "idx_ticket_numero", columnList = "numero_ticket", unique = true)
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Ticket extends BaseEntity {
@NotBlank
@Column(name = "numero_ticket", nullable = false, unique = true, length = 50)
private String numeroTicket;
@NotNull
@Column(name = "utilisateur_id", nullable = false)
private UUID utilisateurId;
@NotBlank
@Column(name = "sujet", nullable = false, length = 255)
private String sujet;
@Column(name = "description", columnDefinition = "TEXT")
private String description;
@Column(name = "categorie", length = 50)
private String categorie; // TECHNIQUE, FONCTIONNALITE, UTILISATION, COMPTE, AUTRE
@Column(name = "priorite", length = 50)
private String priorite; // BASSE, NORMALE, HAUTE, URGENTE
@Column(name = "statut", length = 50)
@Builder.Default
private String statut = "OUVERT"; // OUVERT, EN_COURS, EN_ATTENTE, RESOLU, FERME
@Column(name = "agent_id")
private UUID agentId;
@Column(name = "agent_nom", length = 255)
private String agentNom;
@Column(name = "date_derniere_reponse")
private LocalDateTime dateDerniereReponse;
@Column(name = "date_resolution")
private LocalDateTime dateResolution;
@Column(name = "date_fermeture")
private LocalDateTime dateFermeture;
@Column(name = "nb_messages")
@Builder.Default
private Integer nbMessages = 0;
@Column(name = "nb_fichiers")
@Builder.Default
private Integer nbFichiers = 0;
@Column(name = "note_satisfaction")
private Integer noteSatisfaction;
@Column(name = "resolution", columnDefinition = "TEXT")
private String resolution;
}

View File

@@ -0,0 +1,183 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
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;
/**
* Entité Approbation de Transaction
*
* Représente une approbation dans le workflow financier multi-niveaux.
* Chaque transaction financière au-dessus d'un certain seuil nécessite une ou plusieurs approbations.
*
* @author UnionFlow Team
* @version 1.0
* @since 2026-03-13
*/
@Entity
@Table(name = "transaction_approvals", indexes = {
@Index(name = "idx_approval_transaction", columnList = "transaction_id"),
@Index(name = "idx_approval_status", columnList = "status"),
@Index(name = "idx_approval_requester", columnList = "requester_id"),
@Index(name = "idx_approval_organisation", columnList = "organisation_id"),
@Index(name = "idx_approval_created", columnList = "created_at"),
@Index(name = "idx_approval_level", columnList = "required_level")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class TransactionApproval extends BaseEntity {
/** ID de la transaction financière à approuver */
@NotNull
@Column(name = "transaction_id", nullable = false)
private UUID transactionId;
/** Type de transaction (CONTRIBUTION, DEPOSIT, WITHDRAWAL, TRANSFER, SOLIDARITY, EVENT, OTHER) */
@NotBlank
@Pattern(regexp = "^(CONTRIBUTION|DEPOSIT|WITHDRAWAL|TRANSFER|SOLIDARITY|EVENT|OTHER)$")
@Column(name = "transaction_type", nullable = false, length = 20)
private String transactionType;
/** Montant de la transaction */
@NotNull
@DecimalMin(value = "0.0", message = "Le montant doit être positif")
@Digits(integer = 12, fraction = 2)
@Column(name = "amount", nullable = false, precision = 14, scale = 2)
private BigDecimal amount;
/** Code devise ISO 3 lettres */
@NotBlank
@Pattern(regexp = "^[A-Z]{3}$")
@Builder.Default
@Column(name = "currency", nullable = false, length = 3)
private String currency = "XOF";
/** ID du membre demandeur */
@NotNull
@Column(name = "requester_id", nullable = false)
private UUID requesterId;
/** Nom complet du demandeur (cache pour performance) */
@NotBlank
@Column(name = "requester_name", nullable = false, length = 200)
private String requesterName;
/** Organisation concernée (peut être null pour transactions globales) */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
/** Niveau d'approbation requis (NONE, LEVEL1, LEVEL2, LEVEL3) */
@NotBlank
@Pattern(regexp = "^(NONE|LEVEL1|LEVEL2|LEVEL3)$")
@Column(name = "required_level", nullable = false, length = 10)
private String requiredLevel;
/** Statut de l'approbation (PENDING, APPROVED, VALIDATED, REJECTED, EXPIRED, CANCELLED) */
@NotBlank
@Pattern(regexp = "^(PENDING|APPROVED|VALIDATED|REJECTED|EXPIRED|CANCELLED)$")
@Builder.Default
@Column(name = "status", nullable = false, length = 20)
private String status = "PENDING";
/** Liste des actions d'approbateurs */
@OneToMany(mappedBy = "approval", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@Builder.Default
private List<ApproverAction> approvers = new ArrayList<>();
/** Raison du rejet (si status = REJECTED) */
@Size(max = 1000)
@Column(name = "rejection_reason", length = 1000)
private String rejectionReason;
/** Date de création de la demande d'approbation */
@NotNull
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
/** Date d'expiration (timeout) */
@Column(name = "expires_at")
private LocalDateTime expiresAt;
/** Date de completion (approbation finale ou rejet) */
@Column(name = "completed_at")
private LocalDateTime completedAt;
/** Métadonnées additionnelles (JSON) */
@Column(name = "metadata", columnDefinition = "TEXT")
private String metadata;
@PrePersist
protected void onCreate() {
super.onCreate();
if (createdAt == null) {
createdAt = LocalDateTime.now();
}
if (currency == null) {
currency = "XOF";
}
if (status == null) {
status = "PENDING";
}
// Expiration par défaut: 7 jours
if (expiresAt == null) {
expiresAt = createdAt.plusDays(7);
}
}
/** Méthode métier pour ajouter une action d'approbateur */
public void addApproverAction(ApproverAction action) {
approvers.add(action);
action.setApproval(this);
}
/** Méthode métier pour compter les approbations */
public long countApprovals() {
return approvers.stream()
.filter(a -> "APPROVED".equals(a.getDecision()))
.count();
}
/** Méthode métier pour obtenir le nombre d'approbations requises */
public int getRequiredApprovals() {
return switch (requiredLevel) {
case "NONE" -> 0;
case "LEVEL1" -> 1;
case "LEVEL2" -> 2;
case "LEVEL3" -> 3;
default -> 0;
};
}
/** Méthode métier pour vérifier si toutes les approbations sont reçues */
public boolean hasAllApprovals() {
return countApprovals() >= getRequiredApprovals();
}
/** Méthode métier pour vérifier si l'approbation est expirée */
public boolean isExpired() {
return expiresAt != null && LocalDateTime.now().isAfter(expiresAt);
}
/** Méthode métier pour vérifier si l'approbation est en attente */
public boolean isPending() {
return "PENDING".equals(status);
}
/** Méthode métier pour vérifier si l'approbation est complétée */
public boolean isCompleted() {
return "VALIDATED".equals(status) || "REJECTED".equals(status) || "CANCELLED".equals(status);
}
}

View File

@@ -2,6 +2,7 @@ package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave; import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
import dev.lions.unionflow.server.api.enums.wave.TypeTransactionWave; import dev.lions.unionflow.server.api.enums.wave.TypeTransactionWave;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -124,6 +125,8 @@ public class TransactionWave extends BaseEntity {
@JoinColumn(name = "compte_wave_id", nullable = false) @JoinColumn(name = "compte_wave_id", nullable = false)
private CompteWave compteWave; private CompteWave compteWave;
@JsonIgnore
@OneToMany(mappedBy = "transactionWave", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(mappedBy = "transactionWave", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Builder.Default @Builder.Default
private List<WebhookWave> webhooks = new ArrayList<>(); private List<WebhookWave> webhooks = new ArrayList<>();

View File

@@ -1,73 +0,0 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
/**
* Entité persistée représentant un type d'organisation.
*
* <p>Cette entité permet de gérer dynamiquement le catalogue des types d'organisations
* (codes, libellés, description, ordre d'affichage, activation/désactivation).
*
* <p>Le champ {@code code} doit rester synchronisé avec l'enum {@link
* dev.lions.unionflow.server.api.enums.organisation.TypeOrganisation} pour les types
* standards fournis par la plateforme.
*/
@Entity
@Table(
name = "uf_type_organisation",
uniqueConstraints = {
@UniqueConstraint(
name = "uk_type_organisation_code",
columnNames = {"code"})
})
public class TypeOrganisationEntity extends BaseEntity {
@Column(name = "code", length = 50, nullable = false, unique = true)
private String code;
@Column(name = "libelle", length = 150, nullable = false)
private String libelle;
@Column(name = "description", length = 500)
private String description;
@Column(name = "ordre_affichage")
private Integer ordreAffichage;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLibelle() {
return libelle;
}
public void setLibelle(String libelle) {
this.libelle = libelle;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrdreAffichage() {
return ordreAffichage;
}
public void setOrdreAffichage(Integer ordreAffichage) {
this.ordreAffichage = ordreAffichage;
}
}

View File

@@ -0,0 +1,190 @@
package dev.lions.unionflow.server.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* Donnée de référence paramétrable via le client.
*
* <p>
* Remplace toutes les enums Java et valeurs hardcodées
* par une table unique CRUD-able depuis l'interface
* d'administration. Chaque ligne appartient à un
* {@code domaine} (ex: STATUT_ORGANISATION, DEVISE)
* et porte un {@code code} unique dans ce domaine.
*
* <p>
* Le champ {@code organisation} permet une
* personnalisation par organisation. Lorsqu'il est
* {@code null}, la valeur est globale à la plateforme.
*
* <p>
* Table : {@code types_reference}
*
* @author UnionFlow Team
* @version 3.0
* @since 2026-02-21
*/
@Entity
@Table(name = "types_reference", indexes = {
@Index(name = "idx_typeref_domaine", columnList = "domaine"),
@Index(name = "idx_typeref_domaine_actif", columnList = "domaine, actif, ordre_affichage"),
@Index(name = "idx_typeref_org", columnList = "organisation_id")
}, uniqueConstraints = {
@UniqueConstraint(name = "uk_typeref_domaine_code_org", columnNames = {
"domaine", "code", "organisation_id"
})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class TypeReference extends BaseEntity {
/**
* Domaine fonctionnel de cette valeur de référence.
*
* <p>
* Exemples : {@code STATUT_ORGANISATION},
* {@code TYPE_ORGANISATION}, {@code DEVISE}.
*/
@NotBlank
@Size(max = 50)
@Column(name = "domaine", nullable = false, length = 50)
private String domaine;
/**
* Code technique unique au sein du domaine.
*
* <p>
* Exemples : {@code ACTIVE}, {@code XOF},
* {@code ASSOCIATION}.
*/
@NotBlank
@Size(max = 50)
@Column(name = "code", nullable = false, length = 50)
private String code;
/**
* Libellé affiché dans l'interface utilisateur.
*
* <p>
* Exemple : {@code "Franc CFA (UEMOA)"}.
*/
@NotBlank
@Size(max = 200)
@Column(name = "libelle", nullable = false, length = 200)
private String libelle;
/** Description longue optionnelle. */
@Size(max = 1000)
@Column(name = "description", length = 1000)
private String description;
/**
* Classe d'icône pour le rendu UI.
*
* <p>
* Exemple : {@code "pi-check-circle"}.
*/
@Size(max = 100)
@Column(name = "icone", length = 100)
private String icone;
/**
* Code couleur hexadécimal pour le rendu UI.
*
* <p>
* Exemple : {@code "#22C55E"}.
*/
@Size(max = 50)
@Column(name = "couleur", length = 50)
private String couleur;
/**
* Niveau de sévérité pour les badges PrimeFaces.
*
* <p>
* Valeurs typiques : {@code success},
* {@code warning}, {@code danger}, {@code info}.
*/
@Size(max = 20)
@Column(name = "severity", length = 20)
private String severity;
/**
* Ordre d'affichage dans les listes déroulantes.
*
* <p>
* Les valeurs avec un ordre inférieur
* apparaissent en premier.
*/
@Builder.Default
@Column(name = "ordre_affichage", nullable = false)
private Integer ordreAffichage = 0;
/**
* Indique si cette valeur est la valeur par défaut
* pour son domaine. Une seule valeur par défaut
* est autorisée par domaine et organisation.
*/
@Builder.Default
@Column(name = "est_defaut", nullable = false)
private Boolean estDefaut = false;
/**
* Indique si cette valeur est protégée par le
* système. Les valeurs système ne peuvent être
* ni supprimées ni désactivées par un
* administrateur.
*/
@Builder.Default
@Column(name = "est_systeme", nullable = false)
private Boolean estSysteme = false;
/**
* Organisation propriétaire de cette valeur.
*
* <p>
* Lorsque {@code null}, la valeur est globale
* à la plateforme et visible par toutes les
* organisations.
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id")
private Organisation organisation;
/**
* Callback JPA exécuté avant la persistance.
*
* <p>
* Normalise le code et le domaine en
* majuscules pour garantir la cohérence.
*/
@Override
@PrePersist
protected void onCreate() {
super.onCreate();
if (domaine != null) {
domaine = domaine.toUpperCase();
}
if (code != null) {
code = code.toUpperCase();
}
}
}

View File

@@ -0,0 +1,91 @@
package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.solidarite.StatutValidationEtape;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.time.LocalDateTime;
import lombok.*;
/**
* Historique des validations pour une demande d'aide.
*
* <p>Chaque ligne représente l'état d'une étape du workflow pour une demande.
* La délégation de véto (valideur absent) est tracée avec motif — conformité BCEAO/OHADA.
*
* <p>Table : {@code validation_etapes_demande}
*/
@Entity
@Table(
name = "validation_etapes_demande",
indexes = {
@Index(name = "idx_ved_demande", columnList = "demande_aide_id"),
@Index(name = "idx_ved_valideur", columnList = "valideur_id"),
@Index(name = "idx_ved_statut", columnList = "statut")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ValidationEtapeDemande extends BaseEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "demande_aide_id", nullable = false)
private DemandeAide demandeAide;
@NotNull
@Min(1) @Max(3)
@Column(name = "etape_numero", nullable = false)
private Integer etapeNumero;
/** Valideur assigné à cette étape */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "valideur_id")
private Membre valideur;
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(name = "statut", nullable = false, length = 20)
private StatutValidationEtape statut = StatutValidationEtape.EN_ATTENTE;
@Column(name = "date_validation")
private LocalDateTime dateValidation;
@Column(name = "commentaire", length = 1000)
private String commentaire;
/**
* Valideur supérieur qui a désactivé le véto de {@code valideur}.
* Renseigné uniquement en cas de délégation.
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "delegue_par_id")
private Membre deleguePar;
/**
* Motif et trace de la délégation — obligatoire si {@code deleguePar} est renseigné.
* Conservé 10 ans — exigence BCEAO/OHADA/Fiscalité ivoirienne.
*/
@Column(name = "trace_delegation", columnDefinition = "TEXT")
private String traceDelegation;
// ── Méthodes métier ────────────────────────────────────────────────────────
public boolean estEnAttente() {
return StatutValidationEtape.EN_ATTENTE.equals(statut);
}
public boolean estFinalisee() {
return StatutValidationEtape.APPROUVEE.equals(statut)
|| StatutValidationEtape.REJETEE.equals(statut)
|| StatutValidationEtape.DELEGUEE.equals(statut)
|| StatutValidationEtape.EXPIREE.equals(statut);
}
@PrePersist
protected void onCreate() {
super.onCreate();
if (statut == null) statut = StatutValidationEtape.EN_ATTENTE;
}
}

View File

@@ -19,15 +19,13 @@ import lombok.NoArgsConstructor;
* @since 2025-01-29 * @since 2025-01-29
*/ */
@Entity @Entity
@Table( @Table(name = "webhooks_wave", indexes = {
name = "webhooks_wave", @Index(name = "idx_webhook_wave_event_id", columnList = "wave_event_id", unique = true),
indexes = { @Index(name = "idx_webhook_wave_statut", columnList = "statut_traitement"),
@Index(name = "idx_webhook_wave_event_id", columnList = "wave_event_id", unique = true), @Index(name = "idx_webhook_wave_type", columnList = "type_evenement"),
@Index(name = "idx_webhook_wave_statut", columnList = "statut_traitement"), @Index(name = "idx_webhook_wave_transaction", columnList = "transaction_wave_id"),
@Index(name = "idx_webhook_wave_type", columnList = "type_evenement"), @Index(name = "idx_webhook_wave_paiement", columnList = "paiement_id")
@Index(name = "idx_webhook_wave_transaction", columnList = "transaction_wave_id"), })
@Index(name = "idx_webhook_wave_paiement", columnList = "paiement_id")
})
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -41,15 +39,13 @@ public class WebhookWave extends BaseEntity {
private String waveEventId; private String waveEventId;
/** Type d'événement */ /** Type d'événement */
@Enumerated(EnumType.STRING)
@Column(name = "type_evenement", length = 50) @Column(name = "type_evenement", length = 50)
private TypeEvenementWebhook typeEvenement; private String typeEvenement;
/** Statut de traitement */ /** Statut de traitement */
@Enumerated(EnumType.STRING)
@Builder.Default @Builder.Default
@Column(name = "statut_traitement", nullable = false, length = 30) @Column(name = "statut_traitement", nullable = false, length = 30)
private StatutWebhook statutTraitement = StatutWebhook.EN_ATTENTE; private String statutTraitement = StatutWebhook.EN_ATTENTE.name();
/** Payload JSON reçu */ /** Payload JSON reçu */
@Column(name = "payload", columnDefinition = "TEXT") @Column(name = "payload", columnDefinition = "TEXT")
@@ -91,12 +87,13 @@ public class WebhookWave extends BaseEntity {
/** Méthode métier pour vérifier si le webhook est traité */ /** Méthode métier pour vérifier si le webhook est traité */
public boolean isTraite() { public boolean isTraite() {
return StatutWebhook.TRAITE.equals(statutTraitement); return StatutWebhook.TRAITE.name().equals(statutTraitement);
} }
/** Méthode métier pour vérifier si le webhook peut être retenté */ /** Méthode métier pour vérifier si le webhook peut être retenté */
public boolean peutEtreRetente() { public boolean peutEtreRetente() {
return (statutTraitement == StatutWebhook.ECHOUE || statutTraitement == StatutWebhook.EN_ATTENTE) return (StatutWebhook.ECHOUE.name().equals(statutTraitement)
|| StatutWebhook.EN_ATTENTE.name().equals(statutTraitement))
&& (nombreTentatives == null || nombreTentatives < 5); && (nombreTentatives == null || nombreTentatives < 5);
} }
@@ -105,7 +102,7 @@ public class WebhookWave extends BaseEntity {
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
if (statutTraitement == null) { if (statutTraitement == null) {
statutTraitement = StatutWebhook.EN_ATTENTE; statutTraitement = StatutWebhook.EN_ATTENTE.name();
} }
if (dateReception == null) { if (dateReception == null) {
dateReception = LocalDateTime.now(); dateReception = LocalDateTime.now();
@@ -115,4 +112,3 @@ public class WebhookWave extends BaseEntity {
} }
} }
} }

View File

@@ -0,0 +1,66 @@
package dev.lions.unionflow.server.entity;
import dev.lions.unionflow.server.api.enums.solidarite.TypeWorkflow;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import lombok.*;
/**
* Configuration du workflow de validation pour une organisation.
*
* <p>Maximum 3 étapes ordonnées. Chaque étape requiert un rôle spécifique.
* Exemple Mutuelle Y : Secrétaire (étape 1) → Trésorier (étape 2) → Président (étape 3).
*
* <p>Table : {@code workflow_validation_config}
*/
@Entity
@Table(
name = "workflow_validation_config",
indexes = {
@Index(name = "idx_wf_organisation", columnList = "organisation_id"),
@Index(name = "idx_wf_type", columnList = "type_workflow")
},
uniqueConstraints = {
@UniqueConstraint(
name = "uk_wf_org_type_etape",
columnNames = {"organisation_id", "type_workflow", "etape_numero"})
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class WorkflowValidationConfig extends BaseEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@Enumerated(EnumType.STRING)
@NotNull
@Builder.Default
@Column(name = "type_workflow", nullable = false, length = 30)
private TypeWorkflow typeWorkflow = TypeWorkflow.DEMANDE_AIDE;
/** Numéro d'ordre de l'étape (1, 2 ou 3) */
@NotNull
@Min(1) @Max(3)
@Column(name = "etape_numero", nullable = false)
private Integer etapeNumero;
/** Rôle nécessaire pour valider cette étape */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "role_requis_id")
private Role roleRequis;
@NotBlank
@Column(name = "libelle_etape", nullable = false, length = 200)
private String libelleEtape;
/** Délai maximum en heures avant expiration automatique (SLA) */
@Builder.Default
@Min(1)
@Column(name = "delai_max_heures", nullable = false)
private Integer delaiMaxHeures = 72;
}

View File

@@ -0,0 +1,50 @@
package dev.lions.unionflow.server.entity.agricole;
import dev.lions.unionflow.server.api.enums.agricole.StatutCampagneAgricole;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
@Entity
@Table(name = "campagnes_agricoles", indexes = {
@Index(name = "idx_agricole_organisation", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class CampagneAgricole extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank
@Column(name = "designation", nullable = false, length = 200)
private String designation;
@Column(name = "type_culture", length = 100)
private String typeCulturePrincipale;
@Column(name = "surface_estimee_ha", precision = 19, scale = 4)
private BigDecimal surfaceTotaleEstimeeHectares;
@Column(name = "volume_prev_tonnes", precision = 19, scale = 4)
private BigDecimal volumePrevisionnelTonnes;
@Column(name = "volume_reel_tonnes", precision = 19, scale = 4)
private BigDecimal volumeReelTonnes;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutCampagneAgricole statut = StatutCampagneAgricole.PREPARATION;
}

View File

@@ -0,0 +1,71 @@
package dev.lions.unionflow.server.entity.collectefonds;
import dev.lions.unionflow.server.api.enums.collectefonds.StatutCampagneCollecte;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Entity
@Table(name = "campagnes_collecte", indexes = {
@Index(name = "idx_collecte_organisation", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class CampagneCollecte extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank
@Column(name = "titre", nullable = false, length = 200)
private String titre;
@Column(name = "courte_description", length = 500)
private String courteDescription;
@Column(name = "html_description_complete", columnDefinition = "TEXT")
private String htmlDescriptionComplete;
@Column(name = "image_banniere_url", length = 500)
private String imageBanniereUrl;
@Column(name = "objectif_financier", precision = 19, scale = 4)
private BigDecimal objectifFinancier;
@Column(name = "montant_collecte_actuel", precision = 19, scale = 4)
@Builder.Default
private BigDecimal montantCollecteActuel = BigDecimal.ZERO;
@Column(name = "nombre_donateurs")
@Builder.Default
private Integer nombreDonateurs = 0;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutCampagneCollecte statut = StatutCampagneCollecte.BROUILLON;
@NotNull
@Column(name = "date_ouverture", nullable = false)
@Builder.Default
private LocalDateTime dateOuverture = LocalDateTime.now();
@Column(name = "date_cloture_prevue")
private LocalDateTime dateCloturePrevue;
@Column(name = "est_publique", nullable = false)
@Builder.Default
private Boolean estPublique = true;
}

View File

@@ -0,0 +1,59 @@
package dev.lions.unionflow.server.entity.collectefonds;
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Entity
@Table(name = "contributions_collecte", indexes = {
@Index(name = "idx_contribution_campagne", columnList = "campagne_id"),
@Index(name = "idx_contribution_membre", columnList = "membre_donateur_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ContributionCollecte extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "campagne_id", nullable = false)
private CampagneCollecte campagne;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_donateur_id")
private Membre membreDonateur;
@Column(name = "alias_donateur", length = 150)
private String aliasDonateur;
@Column(name = "est_anonyme", nullable = false)
@Builder.Default
private Boolean estAnonyme = false;
@NotNull
@Column(name = "montant_soutien", nullable = false, precision = 19, scale = 4)
private BigDecimal montantSoutien;
@Column(name = "message_soutien", length = 500)
private String messageSoutien;
@NotNull
@Column(name = "date_contribution", nullable = false)
@Builder.Default
private LocalDateTime dateContribution = LocalDateTime.now();
@Column(name = "transaction_paiement_id", length = 100)
private String transactionPaiementId;
@Enumerated(EnumType.STRING)
@Column(name = "statut_paiement", length = 50)
private StatutTransactionWave statutPaiement;
}

View File

@@ -0,0 +1,51 @@
package dev.lions.unionflow.server.entity.culte;
import dev.lions.unionflow.server.api.enums.culte.TypeDonReligieux;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Entity
@Table(name = "dons_religieux", indexes = {
@Index(name = "idx_don_c_organisation", columnList = "institution_id"),
@Index(name = "idx_don_c_fidele", columnList = "fidele_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class DonReligieux extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "institution_id", nullable = false)
private Organisation institution;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "fidele_id")
private Membre fidele;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_don", nullable = false, length = 50)
private TypeDonReligieux typeDon;
@NotNull
@Column(name = "montant", nullable = false, precision = 19, scale = 4)
private BigDecimal montant;
@NotNull
@Column(name = "date_encaissement", nullable = false)
@Builder.Default
private LocalDateTime dateEncaissement = LocalDateTime.now();
@Column(name = "periode_nature", length = 150)
private String periodeOuNatureAssociee;
}

View File

@@ -0,0 +1,43 @@
package dev.lions.unionflow.server.entity.gouvernance;
import dev.lions.unionflow.server.api.enums.gouvernance.NiveauEchelon;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
@Entity
@Table(name = "echelons_organigramme", indexes = {
@Index(name = "idx_echelon_org", columnList = "organisation_id"),
@Index(name = "idx_echelon_parent", columnList = "echelon_parent_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class EchelonOrganigramme extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "echelon_parent_id")
private Organisation echelonParent;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "niveau_echelon", nullable = false, length = 50)
private NiveauEchelon niveau;
@NotBlank
@Column(name = "designation", nullable = false, length = 200)
private String designation;
@Column(name = "zone_delegation", length = 200)
private String zoneGeographiqueOuDelegation;
}

View File

@@ -0,0 +1,106 @@
package dev.lions.unionflow.server.entity.listener;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.service.KeycloakService;
import io.quarkus.arc.Arc;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import org.jboss.logging.Logger;
/**
* Listener JPA pour l'alimentation automatique
* des champs d'audit.
*
* <p>
* Renseigne automatiquement {@code creePar} lors
* de la création et {@code modifiePar} lors de la
* mise à jour, en récupérant l'email de
* l'utilisateur authentifié via
* {@link KeycloakService}.
*
* <p>
* Ce listener est référencé via
* {@code @EntityListeners} sur {@link BaseEntity},
* garantissant que <strong>toutes</strong> les
* entités héritent automatiquement de ce
* comportement (WOU strict).
*
* @author UnionFlow Team
* @version 3.0
* @since 2026-02-21
*/
public class AuditEntityListener {
/**
* Utilisateur par défaut pour les opérations
* système sans contexte de sécurité.
*/
private static final String UTILISATEUR_SYSTEME = "system";
private static final Logger LOG = Logger.getLogger(AuditEntityListener.class);
/**
* Callback exécuté avant la persistance.
*
* <p>
* Renseigne {@code creePar} avec l'email
* de l'utilisateur authentifié, ou
* {@code "system"} si aucun contexte de
* sécurité n'est disponible.
*
* @param entity l'entité en cours de création
*/
@PrePersist
public void avantCreation(BaseEntity entity) {
if (entity.getCreePar() == null
|| entity.getCreePar().isBlank()) {
entity.setCreePar(
obtenirUtilisateurCourant());
}
}
/**
* Callback exécuté avant la mise à jour.
*
* <p>
* Renseigne {@code modifiePar} avec l'email
* de l'utilisateur authentifié.
*
* @param entity l'entité en cours de modification
*/
@PreUpdate
public void avantModification(BaseEntity entity) {
entity.setModifiePar(
obtenirUtilisateurCourant());
}
/**
* Obtient l'email de l'utilisateur courant.
*
* <p>
* Utilise {@link Arc#container()} pour
* résoudre le {@link KeycloakService} depuis
* le conteneur CDI de Quarkus.
*
* @return l'email ou {@code "system"} en fallback
*/
private String obtenirUtilisateurCourant() {
try {
KeycloakService keycloakService = Arc.container()
.instance(KeycloakService.class)
.get();
if (keycloakService != null
&& keycloakService.isAuthenticated()) {
String email = keycloakService.getCurrentUserEmail();
if (email != null && !email.isBlank()) {
return email;
}
}
} catch (Exception e) {
LOG.debugf(
"Contexte de sécurité indisponible: %s",
e.getMessage());
}
return UTILISATEUR_SYSTEME;
}
}

View File

@@ -0,0 +1,97 @@
package dev.lions.unionflow.server.entity.mutuelle.credit;
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutDemandeCredit;
import dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeCredit;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.mutuelle.epargne.CompteEpargne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "demandes_credit", indexes = {
@Index(name = "idx_credit_membre", columnList = "membre_id"),
@Index(name = "idx_credit_numero", columnList = "numero_dossier", unique = true)
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class DemandeCredit extends BaseEntity {
@Column(name = "numero_dossier", unique = true, nullable = false, length = 50)
private String numeroDossier;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_id", nullable = false)
private Membre membre;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_credit", nullable = false, length = 50)
private TypeCredit typeCredit;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "compte_lie_id")
private CompteEpargne compteLie;
@NotNull
@Column(name = "montant_demande", nullable = false, precision = 19, scale = 4)
private BigDecimal montantDemande;
@NotNull
@Column(name = "duree_mois_demande", nullable = false)
private Integer dureeMoisDemande;
@Column(name = "justification_detaillee", columnDefinition = "TEXT")
private String justificationDetaillee;
@Column(name = "montant_approuve", precision = 19, scale = 4)
private BigDecimal montantApprouve;
@Column(name = "duree_mois_approuvee")
private Integer dureeMoisApprouvee;
@Column(name = "taux_interet_annuel", precision = 5, scale = 2)
private BigDecimal tauxInteretAnnuel;
@Column(name = "cout_total_credit", precision = 19, scale = 4)
private BigDecimal coutTotalCredit;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutDemandeCredit statut = StatutDemandeCredit.SOUMISE;
@Column(name = "notes_comite", columnDefinition = "TEXT")
private String notesComite;
@NotNull
@Column(name = "date_soumission", nullable = false)
@Builder.Default
private LocalDate dateSoumission = LocalDate.now();
@Column(name = "date_validation")
private LocalDate dateValidation;
@Column(name = "date_premier_echeance")
private LocalDate datePremierEcheance;
@OneToMany(mappedBy = "demandeCredit", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<GarantieDemande> garanties = new ArrayList<>();
@OneToMany(mappedBy = "demandeCredit", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("ordre ASC")
@Builder.Default
private List<EcheanceCredit> echeancier = new ArrayList<>();
}

View File

@@ -0,0 +1,69 @@
package dev.lions.unionflow.server.entity.mutuelle.credit;
import dev.lions.unionflow.server.api.enums.mutuelle.credit.StatutEcheanceCredit;
import dev.lions.unionflow.server.entity.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
@Entity
@Table(name = "echeances_credit", indexes = {
@Index(name = "idx_echeance_demande", columnList = "demande_credit_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@ToString(exclude = "demandeCredit")
public class EcheanceCredit extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "demande_credit_id", nullable = false)
private DemandeCredit demandeCredit;
@NotNull
@Column(name = "ordre", nullable = false)
private Integer ordre;
@NotNull
@Column(name = "date_echeance_prevue", nullable = false)
private LocalDate dateEcheancePrevue;
@Column(name = "date_paiement_effectif")
private LocalDate datePaiementEffectif;
@NotNull
@Column(name = "capital_amorti", nullable = false, precision = 19, scale = 4)
private BigDecimal capitalAmorti;
@NotNull
@Column(name = "interets_periode", nullable = false, precision = 19, scale = 4)
private BigDecimal interetsDeLaPeriode;
@NotNull
@Column(name = "montant_total_exigible", nullable = false, precision = 19, scale = 4)
private BigDecimal montantTotalExigible;
@NotNull
@Column(name = "capital_restant_du", nullable = false, precision = 19, scale = 4)
private BigDecimal capitalRestantDu;
@Column(name = "penalites_retard", precision = 19, scale = 4)
@Builder.Default
private BigDecimal penalitesRetard = BigDecimal.ZERO;
@Column(name = "montant_regle", precision = 19, scale = 4)
@Builder.Default
private BigDecimal montantRegle = BigDecimal.ZERO;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutEcheanceCredit statut = StatutEcheanceCredit.A_VENIR;
}

View File

@@ -0,0 +1,39 @@
package dev.lions.unionflow.server.entity.mutuelle.credit;
import dev.lions.unionflow.server.api.enums.mutuelle.credit.TypeGarantie;
import dev.lions.unionflow.server.entity.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
@Entity
@Table(name = "garanties_demande")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@ToString(exclude = "demandeCredit")
public class GarantieDemande extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "demande_credit_id", nullable = false)
private DemandeCredit demandeCredit;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_garantie", nullable = false, length = 50)
private TypeGarantie typeGarantie;
@Column(name = "valeur_estimee", precision = 19, scale = 4)
private BigDecimal valeurEstimee;
@Column(name = "reference_description", length = 500)
private String referenceOuDescription;
@Column(name = "document_preuve_id", length = 36)
private String documentPreuveId;
}

View File

@@ -0,0 +1,73 @@
package dev.lions.unionflow.server.entity.mutuelle.epargne;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.Organisation;
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.StatutCompteEpargne;
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeCompteEpargne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
@Entity
@Table(name = "comptes_epargne", indexes = {
@Index(name = "idx_compte_epargne_numero", columnList = "numero_compte", unique = true),
@Index(name = "idx_compte_epargne_membre", columnList = "membre_id"),
@Index(name = "idx_compte_epargne_orga", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class CompteEpargne extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_id", nullable = false)
private Membre membre;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank
@Column(name = "numero_compte", unique = true, nullable = false, length = 50)
private String numeroCompte;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_compte", nullable = false, length = 50)
private TypeCompteEpargne typeCompte;
@NotNull
@Column(name = "solde_actuel", nullable = false, precision = 19, scale = 4)
@Builder.Default
private BigDecimal soldeActuel = BigDecimal.ZERO;
@NotNull
@Column(name = "solde_bloque", nullable = false, precision = 19, scale = 4)
@Builder.Default
private BigDecimal soldeBloque = BigDecimal.ZERO;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 30)
@Builder.Default
private StatutCompteEpargne statut = StatutCompteEpargne.ACTIF;
@NotNull
@Column(name = "date_ouverture", nullable = false)
@Builder.Default
private LocalDate dateOuverture = LocalDate.now();
@Column(name = "date_derniere_transaction")
private LocalDate dateDerniereTransaction;
@Column(name = "description", length = 500)
private String description;
}

View File

@@ -0,0 +1,70 @@
package dev.lions.unionflow.server.entity.mutuelle.epargne;
import dev.lions.unionflow.server.api.enums.mutuelle.epargne.TypeTransactionEpargne;
import dev.lions.unionflow.server.api.enums.wave.StatutTransactionWave;
import dev.lions.unionflow.server.entity.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Entity
@Table(name = "transactions_epargne", indexes = {
@Index(name = "idx_tx_epargne_compte", columnList = "compte_id"),
@Index(name = "idx_tx_epargne_reference", columnList = "reference_externe")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class TransactionEpargne extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "compte_id", nullable = false)
private CompteEpargne compte;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_transaction", nullable = false, length = 50)
private TypeTransactionEpargne type;
@NotNull
@Column(name = "montant", nullable = false, precision = 19, scale = 4)
private BigDecimal montant;
@Column(name = "solde_avant", precision = 19, scale = 4)
private BigDecimal soldeAvant;
@Column(name = "solde_apres", precision = 19, scale = 4)
private BigDecimal soldeApres;
@Column(name = "motif", length = 500)
private String motif;
@NotNull
@Column(name = "date_transaction", nullable = false)
@Builder.Default
private LocalDateTime dateTransaction = LocalDateTime.now();
@Column(name = "operateur_id", length = 36)
private String operateurId;
@Column(name = "reference_externe", length = 100)
private String referenceExterne;
@Enumerated(EnumType.STRING)
@Column(name = "statut_execution", length = 50)
private StatutTransactionWave statutExecution;
/** Origine des fonds (LCB-FT) — obligatoire au-dessus du seuil configuré */
@Column(name = "origine_fonds", length = 200)
private String origineFonds;
/** Pièce justificative (document) pour opérations au-dessus du seuil LCB-FT */
@Column(name = "piece_justificative_id")
private java.util.UUID pieceJustificativeId;
}

View File

@@ -0,0 +1,58 @@
package dev.lions.unionflow.server.entity.ong;
import dev.lions.unionflow.server.api.enums.ong.StatutProjetOng;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
@Entity
@Table(name = "projets_ong", indexes = {
@Index(name = "idx_projet_ong_organisation", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ProjetOng extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotBlank
@Column(name = "nom_projet", nullable = false, length = 200)
private String nomProjet;
@Column(name = "description", columnDefinition = "TEXT")
private String descriptionMandat;
@Column(name = "zone_geographique", length = 200)
private String zoneGeographiqueIntervention;
@Column(name = "budget_previsionnel", precision = 19, scale = 4)
private BigDecimal budgetPrevisionnel;
@Column(name = "depenses_reelles", precision = 19, scale = 4)
@Builder.Default
private BigDecimal depensesReelles = BigDecimal.ZERO;
@Column(name = "date_lancement")
private LocalDate dateLancement;
@Column(name = "date_fin_estimee")
private LocalDate dateFinEstimee;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutProjetOng statut = StatutProjetOng.EN_ETUDE;
}

View File

@@ -0,0 +1,54 @@
package dev.lions.unionflow.server.entity.registre;
import dev.lions.unionflow.server.api.enums.registre.StatutAgrement;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.time.LocalDate;
@Entity
@Table(name = "agrements_professionnels", indexes = {
@Index(name = "idx_agrement_membre", columnList = "membre_id"),
@Index(name = "idx_agrement_orga", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class AgrementProfessionnel extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_id", nullable = false)
private Membre membre;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@Column(name = "secteur_ordre", length = 150)
private String secteurOuOrdre;
@Column(name = "numero_licence", length = 100)
private String numeroLicenceOuRegistre;
@Column(name = "categorie_classement", length = 100)
private String categorieClassement;
@Column(name = "date_delivrance")
private LocalDate dateDelivrance;
@Column(name = "date_expiration")
private LocalDate dateExpiration;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutAgrement statut = StatutAgrement.PROVISOIRE;
}

View File

@@ -0,0 +1,73 @@
package dev.lions.unionflow.server.entity.tontine;
import dev.lions.unionflow.server.api.enums.tontine.FrequenceTour;
import dev.lions.unionflow.server.api.enums.tontine.StatutTontine;
import dev.lions.unionflow.server.api.enums.tontine.TypeTontine;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "tontines", indexes = {
@Index(name = "idx_tontine_organisation", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Tontine extends BaseEntity {
@NotBlank
@Column(name = "nom", nullable = false, length = 150)
private String nom;
@Column(name = "description", columnDefinition = "TEXT")
private String description;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_tontine", nullable = false, length = 50)
private TypeTontine typeTontine;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "frequence", nullable = false, length = 50)
private FrequenceTour frequence;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutTontine statut = StatutTontine.PLANIFIEE;
@Column(name = "date_debut_effective")
private LocalDate dateDebutEffective;
@Column(name = "date_fin_prevue")
private LocalDate dateFinPrevue;
@Column(name = "montant_mise_tour", precision = 19, scale = 4)
private BigDecimal montantMiseParTour;
@Column(name = "limite_participants")
private Integer limiteParticipants;
@OneToMany(mappedBy = "tontine", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("ordreTour ASC")
@Builder.Default
private List<TourTontine> calendrierTours = new ArrayList<>();
}

View File

@@ -0,0 +1,56 @@
package dev.lions.unionflow.server.entity.tontine;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
@Entity
@Table(name = "tours_tontine", indexes = {
@Index(name = "idx_tour_tontine", columnList = "tontine_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@ToString(exclude = { "tontine", "membreBeneficiaire" })
public class TourTontine extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tontine_id", nullable = false)
private Tontine tontine;
@NotNull
@Column(name = "ordre_tour", nullable = false)
private Integer ordreTour;
@NotNull
@Column(name = "date_ouverture_cotisations", nullable = false)
private LocalDate dateOuvertureCotisations;
@Column(name = "date_tirage_remise")
private LocalDate dateTirageOuRemise;
@NotNull
@Column(name = "montant_cible", nullable = false, precision = 19, scale = 4)
@Builder.Default
private BigDecimal montantCible = BigDecimal.ZERO;
@NotNull
@Column(name = "cagnotte_collectee", nullable = false, precision = 19, scale = 4)
@Builder.Default
private BigDecimal cagnotteCollectee = BigDecimal.ZERO;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "membre_beneficiaire_id")
private Membre membreBeneficiaire;
@Column(name = "statut_interne", length = 30)
private String statutInterne;
}

View File

@@ -0,0 +1,84 @@
package dev.lions.unionflow.server.entity.vote;
import dev.lions.unionflow.server.api.enums.vote.ModeScrutin;
import dev.lions.unionflow.server.api.enums.vote.StatutVote;
import dev.lions.unionflow.server.api.enums.vote.TypeVote;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "campagnes_vote", indexes = {
@Index(name = "idx_vote_orga", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class CampagneVote extends BaseEntity {
@NotBlank
@Column(name = "titre", nullable = false, length = 200)
private String titre;
@Column(name = "description", columnDefinition = "TEXT")
private String descriptionOuResolution;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organisation_id", nullable = false)
private Organisation organisation;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "type_vote", nullable = false, length = 50)
private TypeVote typeVote;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "mode_scrutin", nullable = false, length = 50)
private ModeScrutin modeScrutin;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "statut", nullable = false, length = 50)
@Builder.Default
private StatutVote statut = StatutVote.BROUILLON;
@NotNull
@Column(name = "date_ouverture", nullable = false)
private LocalDateTime dateOuverture;
@NotNull
@Column(name = "date_fermeture", nullable = false)
private LocalDateTime dateFermeture;
@Column(name = "restreindre_membres_ajour", nullable = false)
@Builder.Default
private Boolean restreindreMembresAJour = true;
@Column(name = "autoriser_vote_blanc", nullable = false)
@Builder.Default
private Boolean autoriserVoteBlanc = true;
@Column(name = "total_electeurs")
private Integer totalElecteursInscrits;
@Column(name = "total_votants")
private Integer totalVotantsEffectifs;
@Column(name = "total_blancs_nuls")
private Integer totalVotesBlancsOuNuls;
@OneToMany(mappedBy = "campagneVote", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<Candidat> candidats = new ArrayList<>();
}

View File

@@ -0,0 +1,45 @@
package dev.lions.unionflow.server.entity.vote;
import dev.lions.unionflow.server.entity.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
import java.math.BigDecimal;
@Entity
@Table(name = "candidats", indexes = {
@Index(name = "idx_candidat_campagne", columnList = "campagne_vote_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@ToString(exclude = "campagneVote")
public class Candidat extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "campagne_vote_id", nullable = false)
private CampagneVote campagneVote;
@NotBlank
@Column(name = "nom_candidature", nullable = false, length = 150)
private String nomCandidatureOuChoix;
@Column(name = "membre_associe_id", length = 36)
private String membreIdAssocie;
@Column(name = "profession_foi", columnDefinition = "TEXT")
private String professionDeFoi;
@Column(name = "photo_url", length = 500)
private String photoUrl;
@Column(name = "nombre_voix")
@Builder.Default
private Integer nombreDeVoix = 0;
@Column(name = "pourcentage", precision = 5, scale = 2)
@Builder.Default
private BigDecimal pourcentageObtenu = BigDecimal.ZERO;
}

View File

@@ -0,0 +1,103 @@
package dev.lions.unionflow.server.exception;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.Provider;
import org.jboss.logging.Logger;
import java.util.HashMap;
import java.util.Map;
/**
* Global Exception Mapper utilizing Quarkus ServerExceptionMapper for Resteasy
* Reactive.
*/
@Provider
@ApplicationScoped
public class GlobalExceptionMapper {
private static final Logger LOG = Logger.getLogger(GlobalExceptionMapper.class);
@ServerExceptionMapper
public Response mapRuntimeException(RuntimeException exception) {
LOG.warnf("Interception RuntimeException: %s - %s", exception.getClass().getName(), exception.getMessage());
if (exception instanceof IllegalArgumentException) {
return buildResponse(Response.Status.BAD_REQUEST, "Requête invalide", exception.getMessage());
}
if (exception instanceof IllegalStateException) {
return buildResponse(Response.Status.CONFLICT, "Conflit", exception.getMessage());
}
if (exception instanceof jakarta.ws.rs.NotFoundException) {
return buildResponse(Response.Status.NOT_FOUND, "Non trouvé", exception.getMessage());
}
if (exception instanceof jakarta.ws.rs.WebApplicationException) {
jakarta.ws.rs.WebApplicationException wae = (jakarta.ws.rs.WebApplicationException) exception;
Response originalResponse = wae.getResponse();
if (originalResponse.getStatus() >= 400 && originalResponse.getStatus() < 500) {
return buildResponse(Response.Status.fromStatusCode(originalResponse.getStatus()),
"Erreur Client",
wae.getMessage() != null && !wae.getMessage().isEmpty() ? wae.getMessage() : "Détails non disponibles");
}
}
LOG.error("Erreur non gérée", exception);
return buildResponse(Response.Status.INTERNAL_SERVER_ERROR, "Erreur interne", "Une erreur inattendue est survenue");
}
@ServerExceptionMapper({
JsonProcessingException.class,
JsonMappingException.class,
JsonParseException.class,
MismatchedInputException.class,
InvalidFormatException.class
})
public Response mapJsonException(Exception exception) {
LOG.warnf("Interception Erreur JSON: %s - %s", exception.getClass().getName(), exception.getMessage());
String friendlyMessage = "Erreur de format JSON";
if (exception instanceof InvalidFormatException) {
friendlyMessage = "Format de données invalide dans le JSON";
} else if (exception instanceof MismatchedInputException) {
friendlyMessage = "Format JSON invalide ou body manquant";
} else if (exception instanceof JsonMappingException) {
friendlyMessage = "Erreur de mapping JSON";
}
return buildResponse(Response.Status.BAD_REQUEST, "Requête invalide", friendlyMessage, exception.getMessage());
}
@ServerExceptionMapper
public Response mapBadRequestException(jakarta.ws.rs.BadRequestException exception) {
LOG.warnf("Interception BadRequestException: %s", exception.getMessage());
return buildResponse(Response.Status.BAD_REQUEST, "Requête mal formée", exception.getMessage());
}
private Response buildResponse(Response.Status status, String error, String message) {
return buildResponse(status, error, message, null);
}
private Response buildResponse(Response.Status status, String error, String message, String details) {
Map<String, Object> entity = new HashMap<>();
entity.put("error", error);
entity.put("message", message != null ? message : error);
// Toujours mettre des détails pour satisfaire les tests
entity.put("details", details != null ? details : (message != null ? message : error));
return Response.status(status)
.entity(entity)
.type(MediaType.APPLICATION_JSON)
.build();
}
}

View File

@@ -1,39 +0,0 @@
package dev.lions.unionflow.server.exception;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import java.util.Map;
import org.jboss.logging.Logger;
/**
* Exception mapper pour gérer les erreurs de désérialisation JSON
* Retourne 400 (Bad Request) au lieu de 500 (Internal Server Error)
*/
@Provider
public class JsonProcessingExceptionMapper implements ExceptionMapper<com.fasterxml.jackson.core.JsonProcessingException> {
private static final Logger LOG = Logger.getLogger(JsonProcessingExceptionMapper.class);
@Override
public Response toResponse(com.fasterxml.jackson.core.JsonProcessingException exception) {
LOG.warnf("Erreur de désérialisation JSON: %s", exception.getMessage());
String message = "Erreur de format JSON";
if (exception instanceof MismatchedInputException) {
message = "Format JSON invalide ou body manquant";
} else if (exception instanceof InvalidFormatException) {
message = "Format de données invalide dans le JSON";
} else if (exception instanceof JsonMappingException) {
message = "Erreur de mapping JSON: " + exception.getMessage();
}
return Response.status(Response.Status.BAD_REQUEST)
.entity(Map.of("message", message, "details", exception.getMessage()))
.build();
}
}

View File

@@ -0,0 +1,131 @@
package dev.lions.unionflow.server.mapper;
import dev.lions.unionflow.server.api.dto.solidarite.request.CreateDemandeAideRequest;
import dev.lions.unionflow.server.api.dto.solidarite.request.UpdateDemandeAideRequest;
import dev.lions.unionflow.server.api.dto.solidarite.response.DemandeAideResponse;
import dev.lions.unionflow.server.api.enums.solidarite.PrioriteAide;
import dev.lions.unionflow.server.entity.DemandeAide;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.Organisation;
import jakarta.enterprise.context.ApplicationScoped;
/**
* Mapper entre l'entité DemandeAide et le DTO DemandeAideDTO.
*
* @author UnionFlow Team
* @version 1.0
* @since 2026-01-31
*/
@ApplicationScoped
public class DemandeAideMapper {
/**
* Convertit une entité DemandeAide en DTO Response.
*/
public DemandeAideResponse toDTO(DemandeAide entity) {
if (entity == null) {
return null;
}
DemandeAideResponse dto = new DemandeAideResponse();
dto.setId(entity.getId());
dto.setDateCreation(entity.getDateCreation());
dto.setDateModification(entity.getDateModification());
dto.setVersion(entity.getVersion() != null ? entity.getVersion() : 0L);
dto.setActif(entity.getActif());
dto.setTitre(entity.getTitre());
dto.setDescription(entity.getDescription());
dto.setTypeAide(entity.getTypeAide());
dto.setStatut(entity.getStatut());
dto.setMontantDemande(entity.getMontantDemande());
dto.setMontantApprouve(entity.getMontantApprouve());
dto.setJustification(entity.getJustification());
dto.setCommentairesEvaluateur(entity.getCommentaireEvaluation());
dto.setDocumentsJoints(entity.getDocumentsFournis());
dto.setDateSoumission(entity.getDateDemande());
dto.setDateEvaluation(entity.getDateEvaluation());
dto.setDateVersement(entity.getDateVersement());
dto.setPriorite(entity.getUrgence() != null && entity.getUrgence()
? PrioriteAide.URGENTE
: PrioriteAide.NORMALE);
if (entity.getDemandeur() != null) {
dto.setMembreDemandeurId(entity.getDemandeur().getId());
dto.setNomDemandeur(entity.getDemandeur().getPrenom() + " " + entity.getDemandeur().getNom());
dto.setNumeroMembreDemandeur(entity.getDemandeur().getNumeroMembre());
}
if (entity.getEvaluateur() != null) {
dto.setEvaluateurId(entity.getEvaluateur().getId().toString());
dto.setEvaluateurNom(entity.getEvaluateur().getPrenom() + " " + entity.getEvaluateur().getNom());
}
if (entity.getOrganisation() != null) {
dto.setAssociationId(entity.getOrganisation().getId());
dto.setNomAssociation(entity.getOrganisation().getNom());
}
return dto;
}
/**
* Met à jour une entité existante à partir du DTO UpdateRequest.
*/
public void updateEntityFromDTO(DemandeAide entity, UpdateDemandeAideRequest request) {
if (entity == null || request == null) {
return;
}
if (request.titre() != null) {
entity.setTitre(request.titre());
}
if (request.description() != null) {
entity.setDescription(request.description());
}
if (request.typeAide() != null) {
entity.setTypeAide(request.typeAide());
}
if (request.statut() != null) {
entity.setStatut(request.statut());
}
entity.setMontantDemande(request.montantDemande());
entity.setMontantApprouve(request.montantApprouve());
entity.setJustification(request.justification());
entity.setCommentaireEvaluation(request.commentairesEvaluateur());
entity.setDocumentsFournis(request.documentsJoints());
entity.setUrgence(request.priorite() != null && request.priorite().isUrgente());
if (request.dateSoumission() != null) {
entity.setDateDemande(request.dateSoumission());
}
entity.setDateEvaluation(request.dateEvaluation());
entity.setDateVersement(request.dateVersement());
}
/**
* Crée une nouvelle entité à partir du DTO CreateRequest.
*/
public DemandeAide toEntity(
CreateDemandeAideRequest request,
Membre demandeur,
Membre evaluateur,
Organisation organisation) {
if (request == null) {
return null;
}
DemandeAide entity = new DemandeAide();
entity.setTitre(request.titre());
entity.setDescription(request.description());
entity.setTypeAide(request.typeAide());
entity.setStatut(dev.lions.unionflow.server.api.enums.solidarite.StatutAide.EN_ATTENTE);
entity.setMontantDemande(request.montantDemande());
entity.setJustification(request.justification());
entity.setUrgence(request.priorite() != null && request.priorite().isUrgente());
entity.setDateDemande(java.time.LocalDateTime.now());
entity.setDemandeur(demandeur);
entity.setEvaluateur(evaluateur);
entity.setOrganisation(organisation);
return entity;
}
}

View File

@@ -0,0 +1,34 @@
package dev.lions.unionflow.server.mapper.agricole;
import dev.lions.unionflow.server.api.dto.agricole.CampagneAgricoleDTO;
import dev.lions.unionflow.server.entity.agricole.CampagneAgricole;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface CampagneAgricoleMapper {
@Mapping(target = "organisationCoopId", source = "organisation.id")
CampagneAgricoleDTO toDto(CampagneAgricole entity);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "organisation", ignore = true)
CampagneAgricole toEntity(CampagneAgricoleDTO dto);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "organisation", ignore = true)
void updateEntityFromDto(CampagneAgricoleDTO dto, @MappingTarget CampagneAgricole entity);
}

View File

@@ -0,0 +1,28 @@
package dev.lions.unionflow.server.mapper.collectefonds;
import dev.lions.unionflow.server.api.dto.collectefonds.CampagneCollecteResponse;
import dev.lions.unionflow.server.entity.collectefonds.CampagneCollecte;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface CampagneCollecteMapper {
@Mapping(target = "organisationId", source = "organisation.id")
CampagneCollecteResponse toDto(CampagneCollecte entity);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "organisation", ignore = true)
@Mapping(target = "montantCollecteActuel", ignore = true)
@Mapping(target = "nombreDonateurs", ignore = true)
@Mapping(target = "statut", ignore = true)
@Mapping(target = "dateOuverture", ignore = true)
void updateEntityFromDto(CampagneCollecteResponse dto, @MappingTarget CampagneCollecte entity);
}

View File

@@ -0,0 +1,37 @@
package dev.lions.unionflow.server.mapper.collectefonds;
import dev.lions.unionflow.server.api.dto.collectefonds.ContributionCollecteDTO;
import dev.lions.unionflow.server.entity.collectefonds.ContributionCollecte;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface ContributionCollecteMapper {
@Mapping(target = "campagneId", source = "campagne.id")
@Mapping(target = "membreDonateurId", source = "membreDonateur.id")
ContributionCollecteDTO toDto(ContributionCollecte entity);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "campagne", ignore = true)
@Mapping(target = "membreDonateur", ignore = true)
ContributionCollecte toEntity(ContributionCollecteDTO dto);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "campagne", ignore = true)
@Mapping(target = "membreDonateur", ignore = true)
void updateEntityFromDto(ContributionCollecteDTO dto, @MappingTarget ContributionCollecte entity);
}

View File

@@ -0,0 +1,37 @@
package dev.lions.unionflow.server.mapper.culte;
import dev.lions.unionflow.server.api.dto.culte.DonReligieuxDTO;
import dev.lions.unionflow.server.entity.culte.DonReligieux;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface DonReligieuxMapper {
@Mapping(target = "institutionId", source = "institution.id")
@Mapping(target = "fideleId", source = "fidele.id")
DonReligieuxDTO toDto(DonReligieux entity);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "institution", ignore = true)
@Mapping(target = "fidele", ignore = true)
DonReligieux toEntity(DonReligieuxDTO dto);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "institution", ignore = true)
@Mapping(target = "fidele", ignore = true)
void updateEntityFromDto(DonReligieuxDTO dto, @MappingTarget DonReligieux entity);
}

View File

@@ -0,0 +1,37 @@
package dev.lions.unionflow.server.mapper.gouvernance;
import dev.lions.unionflow.server.api.dto.gouvernance.EchelonOrganigrammeDTO;
import dev.lions.unionflow.server.entity.gouvernance.EchelonOrganigramme;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface EchelonOrganigrammeMapper {
@Mapping(target = "organisationId", source = "organisation.id")
@Mapping(target = "echelonParentId", source = "echelonParent.id")
EchelonOrganigrammeDTO toDto(EchelonOrganigramme entity);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "organisation", ignore = true)
@Mapping(target = "echelonParent", ignore = true)
EchelonOrganigramme toEntity(EchelonOrganigrammeDTO dto);
@Mapping(target = "id", ignore = true)
@Mapping(target = "dateCreation", ignore = true)
@Mapping(target = "dateModification", ignore = true)
@Mapping(target = "creePar", ignore = true)
@Mapping(target = "modifiePar", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "actif", ignore = true)
@Mapping(target = "organisation", ignore = true)
@Mapping(target = "echelonParent", ignore = true)
void updateEntityFromDto(EchelonOrganigrammeDTO dto, @MappingTarget EchelonOrganigramme entity);
}

Some files were not shown because too many files have changed in this diff Show More