feat(unionflow): ajout Spec-Kit, constitution, mission mutuelles
- Config Spec-Kit pour Spec-Driven Development - CONSTITUTION.md + .specify/memory/constitution.md - Commandes Cursor /speckit.*, règles projet - Mission: associations + mutuelles d'épargne et de financement - .gitignore: versionner config spec-kit unionflow Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
library profile_repository;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../members/data/models/membre_complete_model.dart';
|
||||
|
||||
/// Interface du repository de profil
|
||||
abstract class ProfileRepository {
|
||||
Future<MembreCompletModel?> getProfileByEmail(String email);
|
||||
Future<MembreCompletModel> updateProfile(String id, MembreCompletModel membre);
|
||||
}
|
||||
|
||||
/// Implémentation via l'API backend /api/membres
|
||||
class ProfileRepositoryImpl implements ProfileRepository {
|
||||
final Dio _dio;
|
||||
static const String _baseUrl = '/api/membres';
|
||||
|
||||
ProfileRepositoryImpl(this._dio);
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel?> getProfileByEmail(String email) async {
|
||||
try {
|
||||
// Recherche par email via l'endpoint de recherche
|
||||
final response = await _dio.get(
|
||||
'$_baseUrl/recherche',
|
||||
queryParameters: {'q': email, 'page': 0, 'size': 1},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
List<dynamic> list = [];
|
||||
|
||||
if (data is List) {
|
||||
list = data;
|
||||
} else if (data is Map && data.containsKey('content')) {
|
||||
list = data['content'] as List;
|
||||
} else if (data is Map && data.containsKey('membres')) {
|
||||
list = data['membres'] as List;
|
||||
}
|
||||
|
||||
if (list.isNotEmpty) {
|
||||
return MembreCompletModel.fromJson(list.first as Map<String, dynamic>);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404) return null;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MembreCompletModel> updateProfile(String id, MembreCompletModel membre) async {
|
||||
final response = await _dio.put(
|
||||
'$_baseUrl/$id',
|
||||
data: membre.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return MembreCompletModel.fromJson(response.data as Map<String, dynamic>);
|
||||
}
|
||||
throw Exception('Erreur lors de la mise à jour : ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user