feat: création branche singletons - début refactorisation

- Sauvegarde des fichiers critiques
- Préparation transformation ApiService en singleton
- Préparation création CurrentUserService et CurrentAmicaleService
- Objectif: renommer Box users -> user
This commit is contained in:
d6soft
2025-06-05 15:22:29 +02:00
parent 2aa2706179
commit e5ab857913
48 changed files with 131679 additions and 128324 deletions

View File

@@ -37,6 +37,9 @@ class MembreModel extends HiveObject {
@HiveField(10)
final String email;
@HiveField(11)
final int fkEntite;
MembreModel({
required this.id,
required this.fkRole,
@@ -49,6 +52,7 @@ class MembreModel extends HiveObject {
required this.name,
required this.username,
required this.email,
required this.fkEntite,
});
// Factory pour convertir depuis JSON (API)
@@ -63,13 +67,15 @@ class MembreModel extends HiveObject {
// Convertir le titre en int, qu'il soit déjà int ou string
final dynamic rawTitre = json['fk_titre'];
final int fkTitre =
rawTitre is String ? int.parse(rawTitre) : rawTitre as int;
final int fkTitre = rawTitre is String ? int.parse(rawTitre) : rawTitre as int;
// Convertir le chkActive en int, qu'il soit déjà int ou string
final dynamic rawActive = json['chk_active'];
final int chkActive =
rawActive is String ? int.parse(rawActive) : rawActive as int;
final int chkActive = rawActive is String ? int.parse(rawActive) : rawActive as int;
// Convertir le fkEntite en int, qu'il soit déjà int ou string
final dynamic rawEntite = json['fk_entite'];
final int fkEntite = rawEntite is String ? int.parse(rawEntite) : rawEntite as int;
return MembreModel(
id: id,
@@ -77,16 +83,13 @@ class MembreModel extends HiveObject {
fkTitre: fkTitre,
firstName: json['first_name'] ?? '',
sectName: json['sect_name'],
dateNaissance: json['date_naissance'] != null
? DateTime.parse(json['date_naissance'])
: null,
dateEmbauche: json['date_embauche'] != null
? DateTime.parse(json['date_embauche'])
: null,
dateNaissance: json['date_naissance'] != null ? DateTime.parse(json['date_naissance']) : null,
dateEmbauche: json['date_embauche'] != null ? DateTime.parse(json['date_embauche']) : null,
chkActive: chkActive,
name: json['name'] ?? '',
username: json['username'] ?? '',
email: json['email'] ?? '',
fkEntite: fkEntite,
);
}
@@ -104,6 +107,7 @@ class MembreModel extends HiveObject {
'name': name,
'username': username,
'email': email,
'fk_entite': fkEntite,
};
}
@@ -119,9 +123,10 @@ class MembreModel extends HiveObject {
String? name,
String? username,
String? email,
int? fkEntite,
}) {
return MembreModel(
id: this.id,
id: id,
fkRole: fkRole ?? this.fkRole,
fkTitre: fkTitre ?? this.fkTitre,
firstName: firstName ?? this.firstName,
@@ -132,6 +137,7 @@ class MembreModel extends HiveObject {
name: name ?? this.name,
username: username ?? this.username,
email: email ?? this.email,
fkEntite: fkEntite ?? this.fkEntite,
);
}
}

View File

@@ -28,13 +28,14 @@ class MembreModelAdapter extends TypeAdapter<MembreModel> {
name: fields[8] as String,
username: fields[9] as String,
email: fields[10] as String,
fkEntite: fields[11] as int,
);
}
@override
void write(BinaryWriter writer, MembreModel obj) {
writer
..writeByte(11)
..writeByte(12)
..writeByte(0)
..write(obj.id)
..writeByte(1)
@@ -56,7 +57,9 @@ class MembreModelAdapter extends TypeAdapter<MembreModel> {
..writeByte(9)
..write(obj.username)
..writeByte(10)
..write(obj.email);
..write(obj.email)
..writeByte(11)
..write(obj.fkEntite);
}
@override