Clean project: remove test files, debug logs, and add documentation
This commit is contained in:
@@ -0,0 +1,329 @@
|
||||
/// Modèle complet de données pour un membre
|
||||
/// Aligné avec le backend MembreDTO
|
||||
library membre_complete_model;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'membre_complete_model.g.dart';
|
||||
|
||||
/// Énumération des genres
|
||||
enum Genre {
|
||||
@JsonValue('HOMME')
|
||||
homme,
|
||||
@JsonValue('FEMME')
|
||||
femme,
|
||||
@JsonValue('AUTRE')
|
||||
autre,
|
||||
}
|
||||
|
||||
/// Énumération des statuts de membre
|
||||
enum StatutMembre {
|
||||
@JsonValue('ACTIF')
|
||||
actif,
|
||||
@JsonValue('INACTIF')
|
||||
inactif,
|
||||
@JsonValue('SUSPENDU')
|
||||
suspendu,
|
||||
@JsonValue('EN_ATTENTE')
|
||||
enAttente,
|
||||
}
|
||||
|
||||
/// Modèle complet d'un membre
|
||||
@JsonSerializable()
|
||||
class MembreCompletModel extends Equatable {
|
||||
/// Identifiant unique
|
||||
final String? id;
|
||||
|
||||
/// Nom de famille
|
||||
final String nom;
|
||||
|
||||
/// Prénom
|
||||
final String prenom;
|
||||
|
||||
/// Email (unique)
|
||||
final String email;
|
||||
|
||||
/// Téléphone
|
||||
final String? telephone;
|
||||
|
||||
/// Date de naissance
|
||||
@JsonKey(name: 'dateNaissance')
|
||||
final DateTime? dateNaissance;
|
||||
|
||||
/// Genre
|
||||
final Genre? genre;
|
||||
|
||||
/// Adresse complète
|
||||
final String? adresse;
|
||||
|
||||
/// Ville
|
||||
final String? ville;
|
||||
|
||||
/// Code postal
|
||||
@JsonKey(name: 'codePostal')
|
||||
final String? codePostal;
|
||||
|
||||
/// Région
|
||||
final String? region;
|
||||
|
||||
/// Pays
|
||||
final String? pays;
|
||||
|
||||
/// Profession
|
||||
final String? profession;
|
||||
|
||||
/// Nationalité
|
||||
final String? nationalite;
|
||||
|
||||
/// URL de la photo
|
||||
final String? photo;
|
||||
|
||||
/// Statut du membre
|
||||
final StatutMembre statut;
|
||||
|
||||
/// Rôle dans l'organisation
|
||||
final String? role;
|
||||
|
||||
/// ID de l'organisation
|
||||
@JsonKey(name: 'organisationId')
|
||||
final String? organisationId;
|
||||
|
||||
/// Nom de l'organisation (pour affichage)
|
||||
@JsonKey(name: 'organisationNom')
|
||||
final String? organisationNom;
|
||||
|
||||
/// Date d'adhésion
|
||||
@JsonKey(name: 'dateAdhesion')
|
||||
final DateTime? dateAdhesion;
|
||||
|
||||
/// Date de fin d'adhésion
|
||||
@JsonKey(name: 'dateFinAdhesion')
|
||||
final DateTime? dateFinAdhesion;
|
||||
|
||||
/// Membre du bureau
|
||||
@JsonKey(name: 'membreBureau')
|
||||
final bool membreBureau;
|
||||
|
||||
/// Est responsable
|
||||
final bool responsable;
|
||||
|
||||
/// Fonction au bureau
|
||||
@JsonKey(name: 'fonctionBureau')
|
||||
final String? fonctionBureau;
|
||||
|
||||
/// Numéro de membre (unique)
|
||||
@JsonKey(name: 'numeroMembre')
|
||||
final String? numeroMembre;
|
||||
|
||||
/// Cotisation à jour
|
||||
@JsonKey(name: 'cotisationAJour')
|
||||
final bool cotisationAJour;
|
||||
|
||||
/// Nombre d'événements participés
|
||||
@JsonKey(name: 'nombreEvenementsParticipes')
|
||||
final int nombreEvenementsParticipes;
|
||||
|
||||
/// Dernière activité
|
||||
@JsonKey(name: 'derniereActivite')
|
||||
final DateTime? derniereActivite;
|
||||
|
||||
/// Notes internes
|
||||
final String? notes;
|
||||
|
||||
/// Date de création
|
||||
@JsonKey(name: 'dateCreation')
|
||||
final DateTime? dateCreation;
|
||||
|
||||
/// Date de modification
|
||||
@JsonKey(name: 'dateModification')
|
||||
final DateTime? dateModification;
|
||||
|
||||
/// Actif
|
||||
final bool actif;
|
||||
|
||||
const MembreCompletModel({
|
||||
this.id,
|
||||
required this.nom,
|
||||
required this.prenom,
|
||||
required this.email,
|
||||
this.telephone,
|
||||
this.dateNaissance,
|
||||
this.genre,
|
||||
this.adresse,
|
||||
this.ville,
|
||||
this.codePostal,
|
||||
this.region,
|
||||
this.pays,
|
||||
this.profession,
|
||||
this.nationalite,
|
||||
this.photo,
|
||||
this.statut = StatutMembre.actif,
|
||||
this.role,
|
||||
this.organisationId,
|
||||
this.organisationNom,
|
||||
this.dateAdhesion,
|
||||
this.dateFinAdhesion,
|
||||
this.membreBureau = false,
|
||||
this.responsable = false,
|
||||
this.fonctionBureau,
|
||||
this.numeroMembre,
|
||||
this.cotisationAJour = false,
|
||||
this.nombreEvenementsParticipes = 0,
|
||||
this.derniereActivite,
|
||||
this.notes,
|
||||
this.dateCreation,
|
||||
this.dateModification,
|
||||
this.actif = true,
|
||||
});
|
||||
|
||||
/// Création depuis JSON
|
||||
factory MembreCompletModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$MembreCompletModelFromJson(json);
|
||||
|
||||
/// Conversion vers JSON
|
||||
Map<String, dynamic> toJson() => _$MembreCompletModelToJson(this);
|
||||
|
||||
/// Copie avec modifications
|
||||
MembreCompletModel copyWith({
|
||||
String? id,
|
||||
String? nom,
|
||||
String? prenom,
|
||||
String? email,
|
||||
String? telephone,
|
||||
DateTime? dateNaissance,
|
||||
Genre? genre,
|
||||
String? adresse,
|
||||
String? ville,
|
||||
String? codePostal,
|
||||
String? region,
|
||||
String? pays,
|
||||
String? profession,
|
||||
String? nationalite,
|
||||
String? photo,
|
||||
StatutMembre? statut,
|
||||
String? role,
|
||||
String? organisationId,
|
||||
String? organisationNom,
|
||||
DateTime? dateAdhesion,
|
||||
DateTime? dateFinAdhesion,
|
||||
bool? membreBureau,
|
||||
bool? responsable,
|
||||
String? fonctionBureau,
|
||||
String? numeroMembre,
|
||||
bool? cotisationAJour,
|
||||
int? nombreEvenementsParticipes,
|
||||
DateTime? derniereActivite,
|
||||
String? notes,
|
||||
DateTime? dateCreation,
|
||||
DateTime? dateModification,
|
||||
bool? actif,
|
||||
}) {
|
||||
return MembreCompletModel(
|
||||
id: id ?? this.id,
|
||||
nom: nom ?? this.nom,
|
||||
prenom: prenom ?? this.prenom,
|
||||
email: email ?? this.email,
|
||||
telephone: telephone ?? this.telephone,
|
||||
dateNaissance: dateNaissance ?? this.dateNaissance,
|
||||
genre: genre ?? this.genre,
|
||||
adresse: adresse ?? this.adresse,
|
||||
ville: ville ?? this.ville,
|
||||
codePostal: codePostal ?? this.codePostal,
|
||||
region: region ?? this.region,
|
||||
pays: pays ?? this.pays,
|
||||
profession: profession ?? this.profession,
|
||||
nationalite: nationalite ?? this.nationalite,
|
||||
photo: photo ?? this.photo,
|
||||
statut: statut ?? this.statut,
|
||||
role: role ?? this.role,
|
||||
organisationId: organisationId ?? this.organisationId,
|
||||
organisationNom: organisationNom ?? this.organisationNom,
|
||||
dateAdhesion: dateAdhesion ?? this.dateAdhesion,
|
||||
dateFinAdhesion: dateFinAdhesion ?? this.dateFinAdhesion,
|
||||
membreBureau: membreBureau ?? this.membreBureau,
|
||||
responsable: responsable ?? this.responsable,
|
||||
fonctionBureau: fonctionBureau ?? this.fonctionBureau,
|
||||
numeroMembre: numeroMembre ?? this.numeroMembre,
|
||||
cotisationAJour: cotisationAJour ?? this.cotisationAJour,
|
||||
nombreEvenementsParticipes: nombreEvenementsParticipes ?? this.nombreEvenementsParticipes,
|
||||
derniereActivite: derniereActivite ?? this.derniereActivite,
|
||||
notes: notes ?? this.notes,
|
||||
dateCreation: dateCreation ?? this.dateCreation,
|
||||
dateModification: dateModification ?? this.dateModification,
|
||||
actif: actif ?? this.actif,
|
||||
);
|
||||
}
|
||||
|
||||
/// Nom complet
|
||||
String get nomComplet => '$prenom $nom';
|
||||
|
||||
/// Initiales
|
||||
String get initiales {
|
||||
final p = prenom.isNotEmpty ? prenom[0].toUpperCase() : '';
|
||||
final n = nom.isNotEmpty ? nom[0].toUpperCase() : '';
|
||||
return '$p$n';
|
||||
}
|
||||
|
||||
/// Âge calculé
|
||||
int? get age {
|
||||
if (dateNaissance == null) return null;
|
||||
final now = DateTime.now();
|
||||
int age = now.year - dateNaissance!.year;
|
||||
if (now.month < dateNaissance!.month ||
|
||||
(now.month == dateNaissance!.month && now.day < dateNaissance!.day)) {
|
||||
age--;
|
||||
}
|
||||
return age;
|
||||
}
|
||||
|
||||
/// Ancienneté en jours
|
||||
int? get ancienneteJours {
|
||||
if (dateAdhesion == null) return null;
|
||||
return DateTime.now().difference(dateAdhesion!).inDays;
|
||||
}
|
||||
|
||||
/// Est actif et cotisation à jour
|
||||
bool get estActifEtAJour => actif && statut == StatutMembre.actif && cotisationAJour;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
nom,
|
||||
prenom,
|
||||
email,
|
||||
telephone,
|
||||
dateNaissance,
|
||||
genre,
|
||||
adresse,
|
||||
ville,
|
||||
codePostal,
|
||||
region,
|
||||
pays,
|
||||
profession,
|
||||
nationalite,
|
||||
photo,
|
||||
statut,
|
||||
role,
|
||||
organisationId,
|
||||
organisationNom,
|
||||
dateAdhesion,
|
||||
dateFinAdhesion,
|
||||
membreBureau,
|
||||
responsable,
|
||||
fonctionBureau,
|
||||
numeroMembre,
|
||||
cotisationAJour,
|
||||
nombreEvenementsParticipes,
|
||||
derniereActivite,
|
||||
notes,
|
||||
dateCreation,
|
||||
dateModification,
|
||||
actif,
|
||||
];
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'MembreCompletModel(id: $id, nom: $nomComplet, email: $email, statut: $statut)';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'membre_complete_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MembreCompletModel _$MembreCompletModelFromJson(Map<String, dynamic> json) =>
|
||||
MembreCompletModel(
|
||||
id: json['id'] as String?,
|
||||
nom: json['nom'] as String,
|
||||
prenom: json['prenom'] as String,
|
||||
email: json['email'] as String,
|
||||
telephone: json['telephone'] as String?,
|
||||
dateNaissance: json['dateNaissance'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateNaissance'] as String),
|
||||
genre: $enumDecodeNullable(_$GenreEnumMap, json['genre']),
|
||||
adresse: json['adresse'] as String?,
|
||||
ville: json['ville'] as String?,
|
||||
codePostal: json['codePostal'] as String?,
|
||||
region: json['region'] as String?,
|
||||
pays: json['pays'] as String?,
|
||||
profession: json['profession'] as String?,
|
||||
nationalite: json['nationalite'] as String?,
|
||||
photo: json['photo'] as String?,
|
||||
statut: $enumDecodeNullable(_$StatutMembreEnumMap, json['statut']) ??
|
||||
StatutMembre.actif,
|
||||
role: json['role'] as String?,
|
||||
organisationId: json['organisationId'] as String?,
|
||||
organisationNom: json['organisationNom'] as String?,
|
||||
dateAdhesion: json['dateAdhesion'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateAdhesion'] as String),
|
||||
dateFinAdhesion: json['dateFinAdhesion'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateFinAdhesion'] as String),
|
||||
membreBureau: json['membreBureau'] as bool? ?? false,
|
||||
responsable: json['responsable'] as bool? ?? false,
|
||||
fonctionBureau: json['fonctionBureau'] as String?,
|
||||
numeroMembre: json['numeroMembre'] as String?,
|
||||
cotisationAJour: json['cotisationAJour'] as bool? ?? false,
|
||||
nombreEvenementsParticipes:
|
||||
(json['nombreEvenementsParticipes'] as num?)?.toInt() ?? 0,
|
||||
derniereActivite: json['derniereActivite'] == null
|
||||
? null
|
||||
: DateTime.parse(json['derniereActivite'] as String),
|
||||
notes: json['notes'] as String?,
|
||||
dateCreation: json['dateCreation'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: json['dateModification'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateModification'] as String),
|
||||
actif: json['actif'] as bool? ?? true,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MembreCompletModelToJson(MembreCompletModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'nom': instance.nom,
|
||||
'prenom': instance.prenom,
|
||||
'email': instance.email,
|
||||
'telephone': instance.telephone,
|
||||
'dateNaissance': instance.dateNaissance?.toIso8601String(),
|
||||
'genre': _$GenreEnumMap[instance.genre],
|
||||
'adresse': instance.adresse,
|
||||
'ville': instance.ville,
|
||||
'codePostal': instance.codePostal,
|
||||
'region': instance.region,
|
||||
'pays': instance.pays,
|
||||
'profession': instance.profession,
|
||||
'nationalite': instance.nationalite,
|
||||
'photo': instance.photo,
|
||||
'statut': _$StatutMembreEnumMap[instance.statut]!,
|
||||
'role': instance.role,
|
||||
'organisationId': instance.organisationId,
|
||||
'organisationNom': instance.organisationNom,
|
||||
'dateAdhesion': instance.dateAdhesion?.toIso8601String(),
|
||||
'dateFinAdhesion': instance.dateFinAdhesion?.toIso8601String(),
|
||||
'membreBureau': instance.membreBureau,
|
||||
'responsable': instance.responsable,
|
||||
'fonctionBureau': instance.fonctionBureau,
|
||||
'numeroMembre': instance.numeroMembre,
|
||||
'cotisationAJour': instance.cotisationAJour,
|
||||
'nombreEvenementsParticipes': instance.nombreEvenementsParticipes,
|
||||
'derniereActivite': instance.derniereActivite?.toIso8601String(),
|
||||
'notes': instance.notes,
|
||||
'dateCreation': instance.dateCreation?.toIso8601String(),
|
||||
'dateModification': instance.dateModification?.toIso8601String(),
|
||||
'actif': instance.actif,
|
||||
};
|
||||
|
||||
const _$GenreEnumMap = {
|
||||
Genre.homme: 'HOMME',
|
||||
Genre.femme: 'FEMME',
|
||||
Genre.autre: 'AUTRE',
|
||||
};
|
||||
|
||||
const _$StatutMembreEnumMap = {
|
||||
StatutMembre.actif: 'ACTIF',
|
||||
StatutMembre.inactif: 'INACTIF',
|
||||
StatutMembre.suspendu: 'SUSPENDU',
|
||||
StatutMembre.enAttente: 'EN_ATTENTE',
|
||||
};
|
||||
@@ -0,0 +1,320 @@
|
||||
/// Repository pour la gestion des membres
|
||||
/// Interface avec l'API backend MembreResource
|
||||
library membre_repository;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import '../models/membre_complete_model.dart';
|
||||
import '../../../../core/models/membre_search_result.dart';
|
||||
import '../../../../core/models/membre_search_criteria.dart';
|
||||
|
||||
/// Interface du repository des membres
|
||||
abstract class MembreRepository {
|
||||
/// Récupère la liste des membres avec pagination
|
||||
Future<MembreSearchResult> getMembres({
|
||||
int page = 0,
|
||||
int size = 20,
|
||||
String? recherche,
|
||||
});
|
||||
|
||||
/// Récupère un membre par son ID
|
||||
Future<MembreCompletModel?> getMembreById(String id);
|
||||
|
||||
/// Crée un nouveau membre
|
||||
Future<MembreCompletModel> createMembre(MembreCompletModel membre);
|
||||
|
||||
/// Met à jour un membre
|
||||
Future<MembreCompletModel> updateMembre(String id, MembreCompletModel membre);
|
||||
|
||||
/// Supprime un membre
|
||||
Future<void> deleteMembre(String id);
|
||||
|
||||
/// Active un membre
|
||||
Future<MembreCompletModel> activateMembre(String id);
|
||||
|
||||
/// Désactive un membre
|
||||
Future<MembreCompletModel> deactivateMembre(String id);
|
||||
|
||||
/// Recherche avancée de membres
|
||||
Future<MembreSearchResult> searchMembres({
|
||||
required MembreSearchCriteria criteria,
|
||||
int page = 0,
|
||||
int size = 20,
|
||||
});
|
||||
|
||||
/// Récupère les membres actifs
|
||||
Future<MembreSearchResult> getActiveMembers({int page = 0, int size = 20});
|
||||
|
||||
/// Récupère les membres du bureau
|
||||
Future<MembreSearchResult> getBureauMembers({int page = 0, int size = 20});
|
||||
|
||||
/// Récupère les statistiques des membres
|
||||
Future<Map<String, dynamic>> getMembresStats();
|
||||
}
|
||||
|
||||
/// Implémentation du repository des membres
|
||||
class MembreRepositoryImpl implements MembreRepository {
|
||||
final Dio _dio;
|
||||
static const String _baseUrl = '/api/membres';
|
||||
|
||||
MembreRepositoryImpl(this._dio);
|
||||
|
||||
@override
|
||||
Future<MembreSearchResult> getMembres({
|
||||
int page = 0,
|
||||
int size = 20,
|
||||
String? recherche,
|
||||
}) async {
|
||||
try {
|
||||
// Si une recherche est fournie, utiliser l'endpoint de recherche
|
||||
if (recherche?.isNotEmpty == true) {
|
||||
final response = await _dio.get(
|
||||
'$_baseUrl/recherche',
|
||||
queryParameters: {
|
||||
'q': recherche,
|
||||
'page': page,
|
||||
'size': size,
|
||||
},
|
||||
);
|
||||
|
||||
return _parseMembreSearchResult(response, page, size, MembreSearchCriteria(query: recherche));
|
||||
}
|
||||
|
||||
// Sinon, récupérer tous les membres
|
||||
final response = await _dio.get(
|
||||
_baseUrl,
|
||||
queryParameters: {
|
||||
'page': page,
|
||||
'size': size,
|
||||
},
|
||||
);
|
||||
|
||||
return _parseMembreSearchResult(response, page, size, const MembreSearchCriteria());
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la récupération des membres: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la récupération des membres: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse la réponse API et retourne un MembreSearchResult
|
||||
/// Gère les deux formats possibles : List (simple) ou Map (paginé)
|
||||
MembreSearchResult _parseMembreSearchResult(
|
||||
Response response,
|
||||
int page,
|
||||
int size,
|
||||
MembreSearchCriteria criteria,
|
||||
) {
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('Erreur HTTP: ${response.statusCode}');
|
||||
}
|
||||
|
||||
// Format simple : liste directe de membres
|
||||
if (response.data is List) {
|
||||
final List<dynamic> listData = response.data as List<dynamic>;
|
||||
final membres = listData
|
||||
.map((e) => MembreCompletModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
|
||||
return MembreSearchResult(
|
||||
membres: membres,
|
||||
totalElements: membres.length,
|
||||
totalPages: 1,
|
||||
currentPage: page,
|
||||
pageSize: membres.length,
|
||||
numberOfElements: membres.length,
|
||||
hasNext: false,
|
||||
hasPrevious: false,
|
||||
isFirst: true,
|
||||
isLast: true,
|
||||
criteria: criteria,
|
||||
executionTimeMs: 0,
|
||||
);
|
||||
}
|
||||
|
||||
// Format paginé : objet avec métadonnées
|
||||
return MembreSearchResult.fromJson(response.data as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel?> getMembreById(String id) async {
|
||||
try {
|
||||
final response = await _dio.get('$_baseUrl/$id');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return MembreCompletModel.fromJson(response.data as Map<String, dynamic>);
|
||||
} else if (response.statusCode == 404) {
|
||||
return null;
|
||||
} else {
|
||||
throw Exception('Erreur lors de la récupération du membre: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404) {
|
||||
return null;
|
||||
}
|
||||
throw Exception('Erreur réseau lors de la récupération du membre: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la récupération du membre: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel> createMembre(MembreCompletModel membre) async {
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
_baseUrl,
|
||||
data: membre.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return MembreCompletModel.fromJson(response.data as Map<String, dynamic>);
|
||||
} else {
|
||||
throw Exception('Erreur lors de la création du membre: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la création du membre: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la création du membre: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel> updateMembre(String id, MembreCompletModel membre) async {
|
||||
try {
|
||||
final response = await _dio.put(
|
||||
'$_baseUrl/$id',
|
||||
data: membre.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return MembreCompletModel.fromJson(response.data as Map<String, dynamic>);
|
||||
} else {
|
||||
throw Exception('Erreur lors de la mise à jour du membre: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la mise à jour du membre: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la mise à jour du membre: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteMembre(String id) async {
|
||||
try {
|
||||
final response = await _dio.delete('$_baseUrl/$id');
|
||||
|
||||
if (response.statusCode != 204 && response.statusCode != 200) {
|
||||
throw Exception('Erreur lors de la suppression du membre: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la suppression du membre: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la suppression du membre: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel> activateMembre(String id) async {
|
||||
try {
|
||||
final response = await _dio.post('$_baseUrl/$id/activer');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return MembreCompletModel.fromJson(response.data as Map<String, dynamic>);
|
||||
} else {
|
||||
throw Exception('Erreur lors de l\'activation du membre: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de l\'activation du membre: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de l\'activation du membre: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel> deactivateMembre(String id) async {
|
||||
try {
|
||||
final response = await _dio.post('$_baseUrl/$id/desactiver');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return MembreCompletModel.fromJson(response.data as Map<String, dynamic>);
|
||||
} else {
|
||||
throw Exception('Erreur lors de la désactivation du membre: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la désactivation du membre: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la désactivation du membre: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreSearchResult> searchMembres({
|
||||
required MembreSearchCriteria criteria,
|
||||
int page = 0,
|
||||
int size = 20,
|
||||
}) async {
|
||||
try {
|
||||
// Les paramètres de pagination vont dans queryParameters
|
||||
// Les critères de recherche vont directement dans le body
|
||||
final response = await _dio.post(
|
||||
'$_baseUrl/search/advanced',
|
||||
queryParameters: {
|
||||
'page': page,
|
||||
'size': size,
|
||||
},
|
||||
data: criteria.toJson(),
|
||||
);
|
||||
|
||||
return _parseMembreSearchResult(response, page, size, criteria);
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la recherche de membres: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la recherche de membres: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreSearchResult> getActiveMembers({int page = 0, int size = 20}) async {
|
||||
// Utiliser la recherche avancée avec le critère statut=ACTIF
|
||||
return searchMembres(
|
||||
criteria: const MembreSearchCriteria(
|
||||
statut: 'ACTIF',
|
||||
includeInactifs: false,
|
||||
),
|
||||
page: page,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreSearchResult> getBureauMembers({int page = 0, int size = 20}) async {
|
||||
// Utiliser la recherche avancée avec le critère membreBureau=true
|
||||
return searchMembres(
|
||||
criteria: const MembreSearchCriteria(
|
||||
membreBureau: true,
|
||||
statut: 'ACTIF',
|
||||
),
|
||||
page: page,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getMembresStats() async {
|
||||
try {
|
||||
final response = await _dio.get('$_baseUrl/statistiques');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.data as Map<String, dynamic>;
|
||||
} else {
|
||||
throw Exception('Erreur lors de la récupération des statistiques: ${response.statusCode}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Erreur réseau lors de la récupération des statistiques: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Erreur inattendue lors de la récupération des statistiques: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ class MembreSearchService {
|
||||
if (criteria.dateAdhesionMin != null || criteria.dateAdhesionMax != null) complexityScore += 1;
|
||||
|
||||
// Temps de base + complexité
|
||||
final baseTime = 100; // 100ms de base
|
||||
const baseTime = 100; // 100ms de base
|
||||
final additionalTime = complexityScore * 50; // 50ms par critère
|
||||
|
||||
return Duration(milliseconds: baseTime + additionalTime);
|
||||
|
||||
Reference in New Issue
Block a user