Restructuration majeure du projet: migration de flutt vers app, ajout de l'API et mise à jour du site web
This commit is contained in:
249
app/lib/core/data/models/amicale_model.dart
Normal file
249
app/lib/core/data/models/amicale_model.dart
Normal file
@@ -0,0 +1,249 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'amicale_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 11)
|
||||
class AmicaleModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final String name;
|
||||
|
||||
@HiveField(2)
|
||||
final String adresse1;
|
||||
|
||||
@HiveField(3)
|
||||
final String adresse2;
|
||||
|
||||
@HiveField(4)
|
||||
final String codePostal;
|
||||
|
||||
@HiveField(5)
|
||||
final String ville;
|
||||
|
||||
@HiveField(6)
|
||||
final int? fkRegion;
|
||||
|
||||
@HiveField(7)
|
||||
final String? libRegion;
|
||||
|
||||
@HiveField(8)
|
||||
final int? fkType;
|
||||
|
||||
@HiveField(9)
|
||||
final String phone;
|
||||
|
||||
@HiveField(10)
|
||||
final String mobile;
|
||||
|
||||
@HiveField(11)
|
||||
final String email;
|
||||
|
||||
@HiveField(12)
|
||||
final String gpsLat;
|
||||
|
||||
@HiveField(13)
|
||||
final String gpsLng;
|
||||
|
||||
@HiveField(14)
|
||||
final String stripeId;
|
||||
|
||||
@HiveField(15)
|
||||
final bool chkDemo;
|
||||
|
||||
@HiveField(16)
|
||||
final bool chkCopieMailRecu;
|
||||
|
||||
@HiveField(17)
|
||||
final bool chkAcceptSms;
|
||||
|
||||
@HiveField(18)
|
||||
final bool chkActive;
|
||||
|
||||
@HiveField(19)
|
||||
final bool chkStripe;
|
||||
|
||||
@HiveField(20)
|
||||
final DateTime? createdAt;
|
||||
|
||||
@HiveField(21)
|
||||
final DateTime? updatedAt;
|
||||
|
||||
AmicaleModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.adresse1 = '',
|
||||
this.adresse2 = '',
|
||||
this.codePostal = '',
|
||||
this.ville = '',
|
||||
this.fkRegion,
|
||||
this.libRegion,
|
||||
this.fkType,
|
||||
this.phone = '',
|
||||
this.mobile = '',
|
||||
this.email = '',
|
||||
this.gpsLat = '',
|
||||
this.gpsLng = '',
|
||||
this.stripeId = '',
|
||||
this.chkDemo = false,
|
||||
this.chkCopieMailRecu = false,
|
||||
this.chkAcceptSms = false,
|
||||
this.chkActive = true,
|
||||
this.chkStripe = false,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory AmicaleModel.fromJson(Map<String, dynamic> json) {
|
||||
// Convertir l'ID en int, qu'il soit déjà int ou string
|
||||
final dynamic rawId = json['id'];
|
||||
final int id = rawId is String ? int.parse(rawId) : rawId as int;
|
||||
|
||||
// Convertir fk_region en int si présent
|
||||
final dynamic rawFkRegion = json['fk_region'];
|
||||
final int? fkRegion = rawFkRegion != null
|
||||
? (rawFkRegion is String ? int.parse(rawFkRegion) : rawFkRegion as int)
|
||||
: null;
|
||||
|
||||
// Convertir fk_type en int si présent
|
||||
final dynamic rawFkType = json['fk_type'];
|
||||
final int? fkType = rawFkType != null
|
||||
? (rawFkType is String ? int.parse(rawFkType) : rawFkType as int)
|
||||
: null;
|
||||
|
||||
// Convertir les booléens
|
||||
final bool chkDemo = json['chk_demo'] == 1 || json['chk_demo'] == true;
|
||||
final bool chkCopieMailRecu =
|
||||
json['chk_copie_mail_recu'] == 1 || json['chk_copie_mail_recu'] == true;
|
||||
final bool chkAcceptSms =
|
||||
json['chk_accept_sms'] == 1 || json['chk_accept_sms'] == true;
|
||||
final bool chkActive =
|
||||
json['chk_active'] == 1 || json['chk_active'] == true;
|
||||
final bool chkStripe =
|
||||
json['chk_stripe'] == 1 || json['chk_stripe'] == true;
|
||||
|
||||
// Traiter les dates si présentes
|
||||
DateTime? createdAt;
|
||||
if (json['created_at'] != null && json['created_at'] != '') {
|
||||
try {
|
||||
createdAt = DateTime.parse(json['created_at']);
|
||||
} catch (e) {
|
||||
createdAt = null;
|
||||
}
|
||||
}
|
||||
|
||||
DateTime? updatedAt;
|
||||
if (json['updated_at'] != null && json['updated_at'] != '') {
|
||||
try {
|
||||
updatedAt = DateTime.parse(json['updated_at']);
|
||||
} catch (e) {
|
||||
updatedAt = null;
|
||||
}
|
||||
}
|
||||
|
||||
return AmicaleModel(
|
||||
id: id,
|
||||
name: json['name'] ?? '',
|
||||
adresse1: json['adresse1'] ?? '',
|
||||
adresse2: json['adresse2'] ?? '',
|
||||
codePostal: json['code_postal'] ?? '',
|
||||
ville: json['ville'] ?? '',
|
||||
fkRegion: fkRegion,
|
||||
libRegion: json['lib_region'],
|
||||
fkType: fkType,
|
||||
phone: json['phone'] ?? '',
|
||||
mobile: json['mobile'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
gpsLat: json['gps_lat'] ?? '',
|
||||
gpsLng: json['gps_lng'] ?? '',
|
||||
stripeId: json['stripe_id'] ?? '',
|
||||
chkDemo: chkDemo,
|
||||
chkCopieMailRecu: chkCopieMailRecu,
|
||||
chkAcceptSms: chkAcceptSms,
|
||||
chkActive: chkActive,
|
||||
chkStripe: chkStripe,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'adresse1': adresse1,
|
||||
'adresse2': adresse2,
|
||||
'code_postal': codePostal,
|
||||
'ville': ville,
|
||||
'fk_region': fkRegion,
|
||||
'lib_region': libRegion,
|
||||
'fk_type': fkType,
|
||||
'phone': phone,
|
||||
'mobile': mobile,
|
||||
'email': email,
|
||||
'gps_lat': gpsLat,
|
||||
'gps_lng': gpsLng,
|
||||
'stripe_id': stripeId,
|
||||
'chk_demo': chkDemo ? 1 : 0,
|
||||
'chk_copie_mail_recu': chkCopieMailRecu ? 1 : 0,
|
||||
'chk_accept_sms': chkAcceptSms ? 1 : 0,
|
||||
'chk_active': chkActive ? 1 : 0,
|
||||
'chk_stripe': chkStripe ? 1 : 0,
|
||||
'created_at': createdAt?.toIso8601String(),
|
||||
'updated_at': updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
AmicaleModel copyWith({
|
||||
String? name,
|
||||
String? adresse1,
|
||||
String? adresse2,
|
||||
String? codePostal,
|
||||
String? ville,
|
||||
int? fkRegion,
|
||||
String? libRegion,
|
||||
int? fkType,
|
||||
String? phone,
|
||||
String? mobile,
|
||||
String? email,
|
||||
String? gpsLat,
|
||||
String? gpsLng,
|
||||
String? stripeId,
|
||||
bool? chkDemo,
|
||||
bool? chkCopieMailRecu,
|
||||
bool? chkAcceptSms,
|
||||
bool? chkActive,
|
||||
bool? chkStripe,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
}) {
|
||||
return AmicaleModel(
|
||||
id: this.id,
|
||||
name: name ?? this.name,
|
||||
adresse1: adresse1 ?? this.adresse1,
|
||||
adresse2: adresse2 ?? this.adresse2,
|
||||
codePostal: codePostal ?? this.codePostal,
|
||||
ville: ville ?? this.ville,
|
||||
fkRegion: fkRegion ?? this.fkRegion,
|
||||
libRegion: libRegion ?? this.libRegion,
|
||||
fkType: fkType ?? this.fkType,
|
||||
phone: phone ?? this.phone,
|
||||
mobile: mobile ?? this.mobile,
|
||||
email: email ?? this.email,
|
||||
gpsLat: gpsLat ?? this.gpsLat,
|
||||
gpsLng: gpsLng ?? this.gpsLng,
|
||||
stripeId: stripeId ?? this.stripeId,
|
||||
chkDemo: chkDemo ?? this.chkDemo,
|
||||
chkCopieMailRecu: chkCopieMailRecu ?? this.chkCopieMailRecu,
|
||||
chkAcceptSms: chkAcceptSms ?? this.chkAcceptSms,
|
||||
chkActive: chkActive ?? this.chkActive,
|
||||
chkStripe: chkStripe ?? this.chkStripe,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
);
|
||||
}
|
||||
}
|
||||
104
app/lib/core/data/models/amicale_model.g.dart
Normal file
104
app/lib/core/data/models/amicale_model.g.dart
Normal file
@@ -0,0 +1,104 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'amicale_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class AmicaleModelAdapter extends TypeAdapter<AmicaleModel> {
|
||||
@override
|
||||
final int typeId = 11;
|
||||
|
||||
@override
|
||||
AmicaleModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return AmicaleModel(
|
||||
id: fields[0] as int,
|
||||
name: fields[1] as String,
|
||||
adresse1: fields[2] as String,
|
||||
adresse2: fields[3] as String,
|
||||
codePostal: fields[4] as String,
|
||||
ville: fields[5] as String,
|
||||
fkRegion: fields[6] as int?,
|
||||
libRegion: fields[7] as String?,
|
||||
fkType: fields[8] as int?,
|
||||
phone: fields[9] as String,
|
||||
mobile: fields[10] as String,
|
||||
email: fields[11] as String,
|
||||
gpsLat: fields[12] as String,
|
||||
gpsLng: fields[13] as String,
|
||||
stripeId: fields[14] as String,
|
||||
chkDemo: fields[15] as bool,
|
||||
chkCopieMailRecu: fields[16] as bool,
|
||||
chkAcceptSms: fields[17] as bool,
|
||||
chkActive: fields[18] as bool,
|
||||
chkStripe: fields[19] as bool,
|
||||
createdAt: fields[20] as DateTime?,
|
||||
updatedAt: fields[21] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, AmicaleModel obj) {
|
||||
writer
|
||||
..writeByte(22)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.name)
|
||||
..writeByte(2)
|
||||
..write(obj.adresse1)
|
||||
..writeByte(3)
|
||||
..write(obj.adresse2)
|
||||
..writeByte(4)
|
||||
..write(obj.codePostal)
|
||||
..writeByte(5)
|
||||
..write(obj.ville)
|
||||
..writeByte(6)
|
||||
..write(obj.fkRegion)
|
||||
..writeByte(7)
|
||||
..write(obj.libRegion)
|
||||
..writeByte(8)
|
||||
..write(obj.fkType)
|
||||
..writeByte(9)
|
||||
..write(obj.phone)
|
||||
..writeByte(10)
|
||||
..write(obj.mobile)
|
||||
..writeByte(11)
|
||||
..write(obj.email)
|
||||
..writeByte(12)
|
||||
..write(obj.gpsLat)
|
||||
..writeByte(13)
|
||||
..write(obj.gpsLng)
|
||||
..writeByte(14)
|
||||
..write(obj.stripeId)
|
||||
..writeByte(15)
|
||||
..write(obj.chkDemo)
|
||||
..writeByte(16)
|
||||
..write(obj.chkCopieMailRecu)
|
||||
..writeByte(17)
|
||||
..write(obj.chkAcceptSms)
|
||||
..writeByte(18)
|
||||
..write(obj.chkActive)
|
||||
..writeByte(19)
|
||||
..write(obj.chkStripe)
|
||||
..writeByte(20)
|
||||
..write(obj.createdAt)
|
||||
..writeByte(21)
|
||||
..write(obj.updatedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is AmicaleModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
200
app/lib/core/data/models/client_model.dart
Normal file
200
app/lib/core/data/models/client_model.dart
Normal file
@@ -0,0 +1,200 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'client_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 10)
|
||||
class ClientModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final String name;
|
||||
|
||||
@HiveField(2)
|
||||
final String? adresse1;
|
||||
|
||||
@HiveField(3)
|
||||
final String? adresse2;
|
||||
|
||||
@HiveField(4)
|
||||
final String? codePostal;
|
||||
|
||||
@HiveField(5)
|
||||
final String? ville;
|
||||
|
||||
@HiveField(6)
|
||||
final int? fkRegion;
|
||||
|
||||
@HiveField(7)
|
||||
final String? libRegion;
|
||||
|
||||
@HiveField(8)
|
||||
final int? fkType;
|
||||
|
||||
@HiveField(9)
|
||||
final String? phone;
|
||||
|
||||
@HiveField(10)
|
||||
final String? mobile;
|
||||
|
||||
@HiveField(11)
|
||||
final String? email;
|
||||
|
||||
@HiveField(12)
|
||||
final String? gpsLat;
|
||||
|
||||
@HiveField(13)
|
||||
final String? gpsLng;
|
||||
|
||||
@HiveField(14)
|
||||
final String? stripeId;
|
||||
|
||||
@HiveField(15)
|
||||
final bool? chkDemo;
|
||||
|
||||
@HiveField(16)
|
||||
final bool? chkCopieMailRecu;
|
||||
|
||||
@HiveField(17)
|
||||
final bool? chkAcceptSms;
|
||||
|
||||
@HiveField(18)
|
||||
final bool? chkActive;
|
||||
|
||||
ClientModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.adresse1,
|
||||
this.adresse2,
|
||||
this.codePostal,
|
||||
this.ville,
|
||||
this.fkRegion,
|
||||
this.libRegion,
|
||||
this.fkType,
|
||||
this.phone,
|
||||
this.mobile,
|
||||
this.email,
|
||||
this.gpsLat,
|
||||
this.gpsLng,
|
||||
this.stripeId,
|
||||
this.chkDemo,
|
||||
this.chkCopieMailRecu,
|
||||
this.chkAcceptSms,
|
||||
this.chkActive,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory ClientModel.fromJson(Map<String, dynamic> json) {
|
||||
// Convertir l'ID en int, qu'il soit déjà int ou string
|
||||
final dynamic rawId = json['id'];
|
||||
final int id = rawId is String ? int.parse(rawId) : rawId as int;
|
||||
|
||||
// Convertir fk_region en int si présent
|
||||
int? fkRegion;
|
||||
if (json['fk_region'] != null) {
|
||||
final dynamic rawFkRegion = json['fk_region'];
|
||||
fkRegion =
|
||||
rawFkRegion is String ? int.parse(rawFkRegion) : rawFkRegion as int;
|
||||
}
|
||||
|
||||
// Convertir fk_type en int si présent
|
||||
int? fkType;
|
||||
if (json['fk_type'] != null) {
|
||||
final dynamic rawFkType = json['fk_type'];
|
||||
fkType = rawFkType is String ? int.parse(rawFkType) : rawFkType as int;
|
||||
}
|
||||
|
||||
return ClientModel(
|
||||
id: id,
|
||||
name: json['name'] ?? '',
|
||||
adresse1: json['adresse1'],
|
||||
adresse2: json['adresse2'],
|
||||
codePostal: json['code_postal'],
|
||||
ville: json['ville'],
|
||||
fkRegion: fkRegion,
|
||||
libRegion: json['lib_region'],
|
||||
fkType: fkType,
|
||||
phone: json['phone'],
|
||||
mobile: json['mobile'],
|
||||
email: json['email'],
|
||||
gpsLat: json['gps_lat'],
|
||||
gpsLng: json['gps_lng'],
|
||||
stripeId: json['stripe_id'],
|
||||
chkDemo: json['chk_demo'] == 1 || json['chk_demo'] == true,
|
||||
chkCopieMailRecu: json['chk_copie_mail_recu'] == 1 ||
|
||||
json['chk_copie_mail_recu'] == true,
|
||||
chkAcceptSms:
|
||||
json['chk_accept_sms'] == 1 || json['chk_accept_sms'] == true,
|
||||
chkActive: json['chk_active'] == 1 || json['chk_active'] == true,
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'adresse1': adresse1,
|
||||
'adresse2': adresse2,
|
||||
'code_postal': codePostal,
|
||||
'ville': ville,
|
||||
'fk_region': fkRegion,
|
||||
'lib_region': libRegion,
|
||||
'fk_type': fkType,
|
||||
'phone': phone,
|
||||
'mobile': mobile,
|
||||
'email': email,
|
||||
'gps_lat': gpsLat,
|
||||
'gps_lng': gpsLng,
|
||||
'stripe_id': stripeId,
|
||||
'chk_demo': chkDemo,
|
||||
'chk_copie_mail_recu': chkCopieMailRecu,
|
||||
'chk_accept_sms': chkAcceptSms,
|
||||
'chk_active': chkActive,
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
ClientModel copyWith({
|
||||
String? name,
|
||||
String? adresse1,
|
||||
String? adresse2,
|
||||
String? codePostal,
|
||||
String? ville,
|
||||
int? fkRegion,
|
||||
String? libRegion,
|
||||
int? fkType,
|
||||
String? phone,
|
||||
String? mobile,
|
||||
String? email,
|
||||
String? gpsLat,
|
||||
String? gpsLng,
|
||||
String? stripeId,
|
||||
bool? chkDemo,
|
||||
bool? chkCopieMailRecu,
|
||||
bool? chkAcceptSms,
|
||||
bool? chkActive,
|
||||
}) {
|
||||
return ClientModel(
|
||||
id: this.id,
|
||||
name: name ?? this.name,
|
||||
adresse1: adresse1 ?? this.adresse1,
|
||||
adresse2: adresse2 ?? this.adresse2,
|
||||
codePostal: codePostal ?? this.codePostal,
|
||||
ville: ville ?? this.ville,
|
||||
fkRegion: fkRegion ?? this.fkRegion,
|
||||
libRegion: libRegion ?? this.libRegion,
|
||||
fkType: fkType ?? this.fkType,
|
||||
phone: phone ?? this.phone,
|
||||
mobile: mobile ?? this.mobile,
|
||||
email: email ?? this.email,
|
||||
gpsLat: gpsLat ?? this.gpsLat,
|
||||
gpsLng: gpsLng ?? this.gpsLng,
|
||||
stripeId: stripeId ?? this.stripeId,
|
||||
chkDemo: chkDemo ?? this.chkDemo,
|
||||
chkCopieMailRecu: chkCopieMailRecu ?? this.chkCopieMailRecu,
|
||||
chkAcceptSms: chkAcceptSms ?? this.chkAcceptSms,
|
||||
chkActive: chkActive ?? this.chkActive,
|
||||
);
|
||||
}
|
||||
}
|
||||
95
app/lib/core/data/models/client_model.g.dart
Normal file
95
app/lib/core/data/models/client_model.g.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'client_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class ClientModelAdapter extends TypeAdapter<ClientModel> {
|
||||
@override
|
||||
final int typeId = 10;
|
||||
|
||||
@override
|
||||
ClientModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ClientModel(
|
||||
id: fields[0] as int,
|
||||
name: fields[1] as String,
|
||||
adresse1: fields[2] as String?,
|
||||
adresse2: fields[3] as String?,
|
||||
codePostal: fields[4] as String?,
|
||||
ville: fields[5] as String?,
|
||||
fkRegion: fields[6] as int?,
|
||||
libRegion: fields[7] as String?,
|
||||
fkType: fields[8] as int?,
|
||||
phone: fields[9] as String?,
|
||||
mobile: fields[10] as String?,
|
||||
email: fields[11] as String?,
|
||||
gpsLat: fields[12] as String?,
|
||||
gpsLng: fields[13] as String?,
|
||||
stripeId: fields[14] as String?,
|
||||
chkDemo: fields[15] as bool?,
|
||||
chkCopieMailRecu: fields[16] as bool?,
|
||||
chkAcceptSms: fields[17] as bool?,
|
||||
chkActive: fields[18] as bool?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ClientModel obj) {
|
||||
writer
|
||||
..writeByte(19)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.name)
|
||||
..writeByte(2)
|
||||
..write(obj.adresse1)
|
||||
..writeByte(3)
|
||||
..write(obj.adresse2)
|
||||
..writeByte(4)
|
||||
..write(obj.codePostal)
|
||||
..writeByte(5)
|
||||
..write(obj.ville)
|
||||
..writeByte(6)
|
||||
..write(obj.fkRegion)
|
||||
..writeByte(7)
|
||||
..write(obj.libRegion)
|
||||
..writeByte(8)
|
||||
..write(obj.fkType)
|
||||
..writeByte(9)
|
||||
..write(obj.phone)
|
||||
..writeByte(10)
|
||||
..write(obj.mobile)
|
||||
..writeByte(11)
|
||||
..write(obj.email)
|
||||
..writeByte(12)
|
||||
..write(obj.gpsLat)
|
||||
..writeByte(13)
|
||||
..write(obj.gpsLng)
|
||||
..writeByte(14)
|
||||
..write(obj.stripeId)
|
||||
..writeByte(15)
|
||||
..write(obj.chkDemo)
|
||||
..writeByte(16)
|
||||
..write(obj.chkCopieMailRecu)
|
||||
..writeByte(17)
|
||||
..write(obj.chkAcceptSms)
|
||||
..writeByte(18)
|
||||
..write(obj.chkActive);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ClientModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
137
app/lib/core/data/models/membre_model.dart
Normal file
137
app/lib/core/data/models/membre_model.dart
Normal file
@@ -0,0 +1,137 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'membre_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 5) // Utilisation d'un typeId unique
|
||||
class MembreModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final int fkRole;
|
||||
|
||||
@HiveField(2)
|
||||
final int fkTitre;
|
||||
|
||||
@HiveField(3)
|
||||
final String firstName;
|
||||
|
||||
@HiveField(4)
|
||||
final String? sectName;
|
||||
|
||||
@HiveField(5)
|
||||
final DateTime? dateNaissance;
|
||||
|
||||
@HiveField(6)
|
||||
final DateTime? dateEmbauche;
|
||||
|
||||
@HiveField(7)
|
||||
final int chkActive;
|
||||
|
||||
@HiveField(8)
|
||||
final String name;
|
||||
|
||||
@HiveField(9)
|
||||
final String username;
|
||||
|
||||
@HiveField(10)
|
||||
final String email;
|
||||
|
||||
MembreModel({
|
||||
required this.id,
|
||||
required this.fkRole,
|
||||
required this.fkTitre,
|
||||
required this.firstName,
|
||||
this.sectName,
|
||||
this.dateNaissance,
|
||||
this.dateEmbauche,
|
||||
required this.chkActive,
|
||||
required this.name,
|
||||
required this.username,
|
||||
required this.email,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory MembreModel.fromJson(Map<String, dynamic> json) {
|
||||
// Convertir l'ID en int, qu'il soit déjà int ou string
|
||||
final dynamic rawId = json['id'];
|
||||
final int id = rawId is String ? int.parse(rawId) : rawId as int;
|
||||
|
||||
// Convertir le rôle en int, qu'il soit déjà int ou string
|
||||
final dynamic rawRole = json['fk_role'];
|
||||
final int fkRole = rawRole is String ? int.parse(rawRole) : rawRole as int;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
|
||||
return MembreModel(
|
||||
id: id,
|
||||
fkRole: fkRole,
|
||||
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,
|
||||
chkActive: chkActive,
|
||||
name: json['name'] ?? '',
|
||||
username: json['username'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'fk_role': fkRole,
|
||||
'fk_titre': fkTitre,
|
||||
'first_name': firstName,
|
||||
'sect_name': sectName,
|
||||
'date_naissance': dateNaissance?.toIso8601String(),
|
||||
'date_embauche': dateEmbauche?.toIso8601String(),
|
||||
'chk_active': chkActive,
|
||||
'name': name,
|
||||
'username': username,
|
||||
'email': email,
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
MembreModel copyWith({
|
||||
int? fkRole,
|
||||
int? fkTitre,
|
||||
String? firstName,
|
||||
String? sectName,
|
||||
DateTime? dateNaissance,
|
||||
DateTime? dateEmbauche,
|
||||
int? chkActive,
|
||||
String? name,
|
||||
String? username,
|
||||
String? email,
|
||||
}) {
|
||||
return MembreModel(
|
||||
id: this.id,
|
||||
fkRole: fkRole ?? this.fkRole,
|
||||
fkTitre: fkTitre ?? this.fkTitre,
|
||||
firstName: firstName ?? this.firstName,
|
||||
sectName: sectName ?? this.sectName,
|
||||
dateNaissance: dateNaissance ?? this.dateNaissance,
|
||||
dateEmbauche: dateEmbauche ?? this.dateEmbauche,
|
||||
chkActive: chkActive ?? this.chkActive,
|
||||
name: name ?? this.name,
|
||||
username: username ?? this.username,
|
||||
email: email ?? this.email,
|
||||
);
|
||||
}
|
||||
}
|
||||
71
app/lib/core/data/models/membre_model.g.dart
Normal file
71
app/lib/core/data/models/membre_model.g.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'membre_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class MembreModelAdapter extends TypeAdapter<MembreModel> {
|
||||
@override
|
||||
final int typeId = 5;
|
||||
|
||||
@override
|
||||
MembreModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return MembreModel(
|
||||
id: fields[0] as int,
|
||||
fkRole: fields[1] as int,
|
||||
fkTitre: fields[2] as int,
|
||||
firstName: fields[3] as String,
|
||||
sectName: fields[4] as String?,
|
||||
dateNaissance: fields[5] as DateTime?,
|
||||
dateEmbauche: fields[6] as DateTime?,
|
||||
chkActive: fields[7] as int,
|
||||
name: fields[8] as String,
|
||||
username: fields[9] as String,
|
||||
email: fields[10] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, MembreModel obj) {
|
||||
writer
|
||||
..writeByte(11)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.fkRole)
|
||||
..writeByte(2)
|
||||
..write(obj.fkTitre)
|
||||
..writeByte(3)
|
||||
..write(obj.firstName)
|
||||
..writeByte(4)
|
||||
..write(obj.sectName)
|
||||
..writeByte(5)
|
||||
..write(obj.dateNaissance)
|
||||
..writeByte(6)
|
||||
..write(obj.dateEmbauche)
|
||||
..writeByte(7)
|
||||
..write(obj.chkActive)
|
||||
..writeByte(8)
|
||||
..write(obj.name)
|
||||
..writeByte(9)
|
||||
..write(obj.username)
|
||||
..writeByte(10)
|
||||
..write(obj.email);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is MembreModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
85
app/lib/core/data/models/operation_model.dart
Normal file
85
app/lib/core/data/models/operation_model.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'operation_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class OperationModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final String name;
|
||||
|
||||
@HiveField(2)
|
||||
final DateTime dateDebut;
|
||||
|
||||
@HiveField(3)
|
||||
final DateTime dateFin;
|
||||
|
||||
@HiveField(4)
|
||||
DateTime lastSyncedAt;
|
||||
|
||||
@HiveField(5)
|
||||
bool isActive;
|
||||
|
||||
@HiveField(6)
|
||||
bool isSynced;
|
||||
|
||||
OperationModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.dateDebut,
|
||||
required this.dateFin,
|
||||
required this.lastSyncedAt,
|
||||
this.isActive = true,
|
||||
this.isSynced = false,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory OperationModel.fromJson(Map<String, dynamic> json) {
|
||||
// Convertir l'ID en int, qu'il soit déjà int ou string
|
||||
final dynamic rawId = json['id'];
|
||||
final int id = rawId is String ? int.parse(rawId) : rawId as int;
|
||||
|
||||
return OperationModel(
|
||||
id: id,
|
||||
name: json['name'],
|
||||
dateDebut: DateTime.parse(json['date_deb']),
|
||||
dateFin: DateTime.parse(json['date_fin']),
|
||||
lastSyncedAt: DateTime.now(),
|
||||
isActive: true,
|
||||
isSynced: true,
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'date_deb': dateDebut.toIso8601String().split('T')[0], // Format YYYY-MM-DD
|
||||
'date_fin': dateFin.toIso8601String().split('T')[0], // Format YYYY-MM-DD
|
||||
'is_active': isActive,
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
OperationModel copyWith({
|
||||
String? name,
|
||||
DateTime? dateDebut,
|
||||
DateTime? dateFin,
|
||||
bool? isActive,
|
||||
bool? isSynced,
|
||||
DateTime? lastSyncedAt,
|
||||
}) {
|
||||
return OperationModel(
|
||||
id: this.id,
|
||||
name: name ?? this.name,
|
||||
dateDebut: dateDebut ?? this.dateDebut,
|
||||
dateFin: dateFin ?? this.dateFin,
|
||||
lastSyncedAt: lastSyncedAt ?? this.lastSyncedAt,
|
||||
isActive: isActive ?? this.isActive,
|
||||
isSynced: isSynced ?? this.isSynced,
|
||||
);
|
||||
}
|
||||
}
|
||||
59
app/lib/core/data/models/operation_model.g.dart
Normal file
59
app/lib/core/data/models/operation_model.g.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'operation_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class OperationModelAdapter extends TypeAdapter<OperationModel> {
|
||||
@override
|
||||
final int typeId = 1;
|
||||
|
||||
@override
|
||||
OperationModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return OperationModel(
|
||||
id: fields[0] as int,
|
||||
name: fields[1] as String,
|
||||
dateDebut: fields[2] as DateTime,
|
||||
dateFin: fields[3] as DateTime,
|
||||
lastSyncedAt: fields[4] as DateTime,
|
||||
isActive: fields[5] as bool,
|
||||
isSynced: fields[6] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, OperationModel obj) {
|
||||
writer
|
||||
..writeByte(7)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.name)
|
||||
..writeByte(2)
|
||||
..write(obj.dateDebut)
|
||||
..writeByte(3)
|
||||
..write(obj.dateFin)
|
||||
..writeByte(4)
|
||||
..write(obj.lastSyncedAt)
|
||||
..writeByte(5)
|
||||
..write(obj.isActive)
|
||||
..writeByte(6)
|
||||
..write(obj.isSynced);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is OperationModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
291
app/lib/core/data/models/passage_model.dart
Normal file
291
app/lib/core/data/models/passage_model.dart
Normal file
@@ -0,0 +1,291 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'passage_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 4)
|
||||
class PassageModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final int fkOperation;
|
||||
|
||||
@HiveField(2)
|
||||
final int fkSector;
|
||||
|
||||
@HiveField(3)
|
||||
final int fkUser;
|
||||
|
||||
@HiveField(4)
|
||||
final int fkType;
|
||||
|
||||
@HiveField(5)
|
||||
final String fkAdresse;
|
||||
|
||||
@HiveField(6)
|
||||
final DateTime passedAt;
|
||||
|
||||
@HiveField(7)
|
||||
final String numero;
|
||||
|
||||
@HiveField(8)
|
||||
final String rue;
|
||||
|
||||
@HiveField(9)
|
||||
final String rueBis;
|
||||
|
||||
@HiveField(10)
|
||||
final String ville;
|
||||
|
||||
@HiveField(11)
|
||||
final String residence;
|
||||
|
||||
@HiveField(12)
|
||||
final int fkHabitat;
|
||||
|
||||
@HiveField(13)
|
||||
final String appt;
|
||||
|
||||
@HiveField(14)
|
||||
final String niveau;
|
||||
|
||||
@HiveField(15)
|
||||
final String gpsLat;
|
||||
|
||||
@HiveField(16)
|
||||
final String gpsLng;
|
||||
|
||||
@HiveField(17)
|
||||
final String nomRecu;
|
||||
|
||||
@HiveField(18)
|
||||
final String remarque;
|
||||
|
||||
@HiveField(19)
|
||||
final String montant;
|
||||
|
||||
@HiveField(20)
|
||||
final int fkTypeReglement;
|
||||
|
||||
@HiveField(21)
|
||||
final String emailErreur;
|
||||
|
||||
@HiveField(22)
|
||||
final int nbPassages;
|
||||
|
||||
@HiveField(23)
|
||||
final String name;
|
||||
|
||||
@HiveField(24)
|
||||
final String email;
|
||||
|
||||
@HiveField(25)
|
||||
final String phone;
|
||||
|
||||
@HiveField(26)
|
||||
DateTime lastSyncedAt;
|
||||
|
||||
@HiveField(27)
|
||||
bool isActive;
|
||||
|
||||
@HiveField(28)
|
||||
bool isSynced;
|
||||
|
||||
PassageModel({
|
||||
required this.id,
|
||||
required this.fkOperation,
|
||||
required this.fkSector,
|
||||
required this.fkUser,
|
||||
required this.fkType,
|
||||
required this.fkAdresse,
|
||||
required this.passedAt,
|
||||
required this.numero,
|
||||
required this.rue,
|
||||
this.rueBis = '',
|
||||
required this.ville,
|
||||
this.residence = '',
|
||||
required this.fkHabitat,
|
||||
this.appt = '',
|
||||
this.niveau = '',
|
||||
required this.gpsLat,
|
||||
required this.gpsLng,
|
||||
this.nomRecu = '',
|
||||
this.remarque = '',
|
||||
required this.montant,
|
||||
required this.fkTypeReglement,
|
||||
this.emailErreur = '',
|
||||
required this.nbPassages,
|
||||
required this.name,
|
||||
this.email = '',
|
||||
this.phone = '',
|
||||
required this.lastSyncedAt,
|
||||
this.isActive = true,
|
||||
this.isSynced = false,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory PassageModel.fromJson(Map<String, dynamic> json) {
|
||||
// Convertir l'ID en int, qu'il soit déjà int ou string
|
||||
final dynamic rawId = json['id'];
|
||||
final int id = rawId is String ? int.parse(rawId) : rawId as int;
|
||||
|
||||
// Convertir les autres champs numériques
|
||||
final dynamic rawFkOperation = json['fk_operation'];
|
||||
final int fkOperation = rawFkOperation is String ? int.parse(rawFkOperation) : rawFkOperation as int;
|
||||
|
||||
final dynamic rawFkSector = json['fk_sector'];
|
||||
final int fkSector = rawFkSector is String ? int.parse(rawFkSector) : rawFkSector as int;
|
||||
|
||||
final dynamic rawFkUser = json['fk_user'];
|
||||
final int fkUser = rawFkUser is String ? int.parse(rawFkUser) : rawFkUser as int;
|
||||
|
||||
final dynamic rawFkType = json['fk_type'];
|
||||
final int fkType = rawFkType is String ? int.parse(rawFkType) : rawFkType as int;
|
||||
|
||||
final dynamic rawFkHabitat = json['fk_habitat'];
|
||||
final int fkHabitat = rawFkHabitat is String ? int.parse(rawFkHabitat) : rawFkHabitat as int;
|
||||
|
||||
final dynamic rawFkTypeReglement = json['fk_type_reglement'];
|
||||
final int fkTypeReglement = rawFkTypeReglement is String ? int.parse(rawFkTypeReglement) : rawFkTypeReglement as int;
|
||||
|
||||
final dynamic rawNbPassages = json['nb_passages'];
|
||||
final int nbPassages = rawNbPassages is String ? int.parse(rawNbPassages) : rawNbPassages as int;
|
||||
|
||||
// Convertir la date
|
||||
final DateTime passedAt = DateTime.parse(json['passed_at']);
|
||||
|
||||
return PassageModel(
|
||||
id: id,
|
||||
fkOperation: fkOperation,
|
||||
fkSector: fkSector,
|
||||
fkUser: fkUser,
|
||||
fkType: fkType,
|
||||
fkAdresse: json['fk_adresse'] as String,
|
||||
passedAt: passedAt,
|
||||
numero: json['numero'] as String,
|
||||
rue: json['rue'] as String,
|
||||
rueBis: json['rue_bis'] as String? ?? '',
|
||||
ville: json['ville'] as String,
|
||||
residence: json['residence'] as String? ?? '',
|
||||
fkHabitat: fkHabitat,
|
||||
appt: json['appt'] as String? ?? '',
|
||||
niveau: json['niveau'] as String? ?? '',
|
||||
gpsLat: json['gps_lat'] as String,
|
||||
gpsLng: json['gps_lng'] as String,
|
||||
nomRecu: json['nom_recu'] as String? ?? '',
|
||||
remarque: json['remarque'] as String? ?? '',
|
||||
montant: json['montant'] as String,
|
||||
fkTypeReglement: fkTypeReglement,
|
||||
emailErreur: json['email_erreur'] as String? ?? '',
|
||||
nbPassages: nbPassages,
|
||||
name: json['name'] as String,
|
||||
email: json['email'] as String? ?? '',
|
||||
phone: json['phone'] as String? ?? '',
|
||||
lastSyncedAt: DateTime.now(),
|
||||
isActive: true,
|
||||
isSynced: true,
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'fk_operation': fkOperation,
|
||||
'fk_sector': fkSector,
|
||||
'fk_user': fkUser,
|
||||
'fk_type': fkType,
|
||||
'fk_adresse': fkAdresse,
|
||||
'passed_at': passedAt.toIso8601String(),
|
||||
'numero': numero,
|
||||
'rue': rue,
|
||||
'rue_bis': rueBis,
|
||||
'ville': ville,
|
||||
'residence': residence,
|
||||
'fk_habitat': fkHabitat,
|
||||
'appt': appt,
|
||||
'niveau': niveau,
|
||||
'gps_lat': gpsLat,
|
||||
'gps_lng': gpsLng,
|
||||
'nom_recu': nomRecu,
|
||||
'remarque': remarque,
|
||||
'montant': montant,
|
||||
'fk_type_reglement': fkTypeReglement,
|
||||
'email_erreur': emailErreur,
|
||||
'nb_passages': nbPassages,
|
||||
'name': name,
|
||||
'email': email,
|
||||
'phone': phone,
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
PassageModel copyWith({
|
||||
int? id,
|
||||
int? fkOperation,
|
||||
int? fkSector,
|
||||
int? fkUser,
|
||||
int? fkType,
|
||||
String? fkAdresse,
|
||||
DateTime? passedAt,
|
||||
String? numero,
|
||||
String? rue,
|
||||
String? rueBis,
|
||||
String? ville,
|
||||
String? residence,
|
||||
int? fkHabitat,
|
||||
String? appt,
|
||||
String? niveau,
|
||||
String? gpsLat,
|
||||
String? gpsLng,
|
||||
String? nomRecu,
|
||||
String? remarque,
|
||||
String? montant,
|
||||
int? fkTypeReglement,
|
||||
String? emailErreur,
|
||||
int? nbPassages,
|
||||
String? name,
|
||||
String? email,
|
||||
String? phone,
|
||||
DateTime? lastSyncedAt,
|
||||
bool? isActive,
|
||||
bool? isSynced,
|
||||
}) {
|
||||
return PassageModel(
|
||||
id: id ?? this.id,
|
||||
fkOperation: fkOperation ?? this.fkOperation,
|
||||
fkSector: fkSector ?? this.fkSector,
|
||||
fkUser: fkUser ?? this.fkUser,
|
||||
fkType: fkType ?? this.fkType,
|
||||
fkAdresse: fkAdresse ?? this.fkAdresse,
|
||||
passedAt: passedAt ?? this.passedAt,
|
||||
numero: numero ?? this.numero,
|
||||
rue: rue ?? this.rue,
|
||||
rueBis: rueBis ?? this.rueBis,
|
||||
ville: ville ?? this.ville,
|
||||
residence: residence ?? this.residence,
|
||||
fkHabitat: fkHabitat ?? this.fkHabitat,
|
||||
appt: appt ?? this.appt,
|
||||
niveau: niveau ?? this.niveau,
|
||||
gpsLat: gpsLat ?? this.gpsLat,
|
||||
gpsLng: gpsLng ?? this.gpsLng,
|
||||
nomRecu: nomRecu ?? this.nomRecu,
|
||||
remarque: remarque ?? this.remarque,
|
||||
montant: montant ?? this.montant,
|
||||
fkTypeReglement: fkTypeReglement ?? this.fkTypeReglement,
|
||||
emailErreur: emailErreur ?? this.emailErreur,
|
||||
nbPassages: nbPassages ?? this.nbPassages,
|
||||
name: name ?? this.name,
|
||||
email: email ?? this.email,
|
||||
phone: phone ?? this.phone,
|
||||
lastSyncedAt: lastSyncedAt ?? this.lastSyncedAt,
|
||||
isActive: isActive ?? this.isActive,
|
||||
isSynced: isSynced ?? this.isSynced,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PassageModel(id: $id, fkOperation: $fkOperation, fkSector: $fkSector, fkUser: $fkUser, fkType: $fkType, adresse: $fkAdresse, ville: $ville, montant: $montant)';
|
||||
}
|
||||
}
|
||||
125
app/lib/core/data/models/passage_model.g.dart
Normal file
125
app/lib/core/data/models/passage_model.g.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'passage_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class PassageModelAdapter extends TypeAdapter<PassageModel> {
|
||||
@override
|
||||
final int typeId = 4;
|
||||
|
||||
@override
|
||||
PassageModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return PassageModel(
|
||||
id: fields[0] as int,
|
||||
fkOperation: fields[1] as int,
|
||||
fkSector: fields[2] as int,
|
||||
fkUser: fields[3] as int,
|
||||
fkType: fields[4] as int,
|
||||
fkAdresse: fields[5] as String,
|
||||
passedAt: fields[6] as DateTime,
|
||||
numero: fields[7] as String,
|
||||
rue: fields[8] as String,
|
||||
rueBis: fields[9] as String,
|
||||
ville: fields[10] as String,
|
||||
residence: fields[11] as String,
|
||||
fkHabitat: fields[12] as int,
|
||||
appt: fields[13] as String,
|
||||
niveau: fields[14] as String,
|
||||
gpsLat: fields[15] as String,
|
||||
gpsLng: fields[16] as String,
|
||||
nomRecu: fields[17] as String,
|
||||
remarque: fields[18] as String,
|
||||
montant: fields[19] as String,
|
||||
fkTypeReglement: fields[20] as int,
|
||||
emailErreur: fields[21] as String,
|
||||
nbPassages: fields[22] as int,
|
||||
name: fields[23] as String,
|
||||
email: fields[24] as String,
|
||||
phone: fields[25] as String,
|
||||
lastSyncedAt: fields[26] as DateTime,
|
||||
isActive: fields[27] as bool,
|
||||
isSynced: fields[28] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, PassageModel obj) {
|
||||
writer
|
||||
..writeByte(29)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.fkOperation)
|
||||
..writeByte(2)
|
||||
..write(obj.fkSector)
|
||||
..writeByte(3)
|
||||
..write(obj.fkUser)
|
||||
..writeByte(4)
|
||||
..write(obj.fkType)
|
||||
..writeByte(5)
|
||||
..write(obj.fkAdresse)
|
||||
..writeByte(6)
|
||||
..write(obj.passedAt)
|
||||
..writeByte(7)
|
||||
..write(obj.numero)
|
||||
..writeByte(8)
|
||||
..write(obj.rue)
|
||||
..writeByte(9)
|
||||
..write(obj.rueBis)
|
||||
..writeByte(10)
|
||||
..write(obj.ville)
|
||||
..writeByte(11)
|
||||
..write(obj.residence)
|
||||
..writeByte(12)
|
||||
..write(obj.fkHabitat)
|
||||
..writeByte(13)
|
||||
..write(obj.appt)
|
||||
..writeByte(14)
|
||||
..write(obj.niveau)
|
||||
..writeByte(15)
|
||||
..write(obj.gpsLat)
|
||||
..writeByte(16)
|
||||
..write(obj.gpsLng)
|
||||
..writeByte(17)
|
||||
..write(obj.nomRecu)
|
||||
..writeByte(18)
|
||||
..write(obj.remarque)
|
||||
..writeByte(19)
|
||||
..write(obj.montant)
|
||||
..writeByte(20)
|
||||
..write(obj.fkTypeReglement)
|
||||
..writeByte(21)
|
||||
..write(obj.emailErreur)
|
||||
..writeByte(22)
|
||||
..write(obj.nbPassages)
|
||||
..writeByte(23)
|
||||
..write(obj.name)
|
||||
..writeByte(24)
|
||||
..write(obj.email)
|
||||
..writeByte(25)
|
||||
..write(obj.phone)
|
||||
..writeByte(26)
|
||||
..write(obj.lastSyncedAt)
|
||||
..writeByte(27)
|
||||
..write(obj.isActive)
|
||||
..writeByte(28)
|
||||
..write(obj.isSynced);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PassageModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
89
app/lib/core/data/models/region_model.dart
Normal file
89
app/lib/core/data/models/region_model.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'region_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 7) // Assurez-vous que cet ID est unique
|
||||
class RegionModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final int fkPays;
|
||||
|
||||
@HiveField(2)
|
||||
final String libelle;
|
||||
|
||||
@HiveField(3)
|
||||
final String? libelleLong;
|
||||
|
||||
@HiveField(4)
|
||||
final String? tableOsm;
|
||||
|
||||
@HiveField(5)
|
||||
final String? departements;
|
||||
|
||||
@HiveField(6)
|
||||
final bool chkActive;
|
||||
|
||||
RegionModel({
|
||||
required this.id,
|
||||
required this.fkPays,
|
||||
required this.libelle,
|
||||
this.libelleLong,
|
||||
this.tableOsm,
|
||||
this.departements,
|
||||
this.chkActive = true,
|
||||
});
|
||||
|
||||
// Constructeur de copie
|
||||
RegionModel copyWith({
|
||||
int? id,
|
||||
int? fkPays,
|
||||
String? libelle,
|
||||
String? libelleLong,
|
||||
String? tableOsm,
|
||||
String? departements,
|
||||
bool? chkActive,
|
||||
}) {
|
||||
return RegionModel(
|
||||
id: id ?? this.id,
|
||||
fkPays: fkPays ?? this.fkPays,
|
||||
libelle: libelle ?? this.libelle,
|
||||
libelleLong: libelleLong ?? this.libelleLong,
|
||||
tableOsm: tableOsm ?? this.tableOsm,
|
||||
departements: departements ?? this.departements,
|
||||
chkActive: chkActive ?? this.chkActive,
|
||||
);
|
||||
}
|
||||
|
||||
// Conversion depuis JSON
|
||||
factory RegionModel.fromJson(Map<String, dynamic> json) {
|
||||
return RegionModel(
|
||||
id: json['id'] as int,
|
||||
fkPays: json['fk_pays'] as int,
|
||||
libelle: json['libelle'] as String,
|
||||
libelleLong: json['libelle_long'] as String?,
|
||||
tableOsm: json['table_osm'] as String?,
|
||||
departements: json['departements'] as String?,
|
||||
chkActive: json['chk_active'] == 1 || json['chk_active'] == true,
|
||||
);
|
||||
}
|
||||
|
||||
// Conversion vers JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'fk_pays': fkPays,
|
||||
'libelle': libelle,
|
||||
'libelle_long': libelleLong,
|
||||
'table_osm': tableOsm,
|
||||
'departements': departements,
|
||||
'chk_active': chkActive ? 1 : 0,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RegionModel(id: $id, libelle: $libelle)';
|
||||
}
|
||||
}
|
||||
59
app/lib/core/data/models/region_model.g.dart
Normal file
59
app/lib/core/data/models/region_model.g.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'region_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class RegionModelAdapter extends TypeAdapter<RegionModel> {
|
||||
@override
|
||||
final int typeId = 7;
|
||||
|
||||
@override
|
||||
RegionModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return RegionModel(
|
||||
id: fields[0] as int,
|
||||
fkPays: fields[1] as int,
|
||||
libelle: fields[2] as String,
|
||||
libelleLong: fields[3] as String?,
|
||||
tableOsm: fields[4] as String?,
|
||||
departements: fields[5] as String?,
|
||||
chkActive: fields[6] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, RegionModel obj) {
|
||||
writer
|
||||
..writeByte(7)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.fkPays)
|
||||
..writeByte(2)
|
||||
..write(obj.libelle)
|
||||
..writeByte(3)
|
||||
..write(obj.libelleLong)
|
||||
..writeByte(4)
|
||||
..write(obj.tableOsm)
|
||||
..writeByte(5)
|
||||
..write(obj.departements)
|
||||
..writeByte(6)
|
||||
..write(obj.chkActive);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is RegionModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
85
app/lib/core/data/models/sector_model.dart
Normal file
85
app/lib/core/data/models/sector_model.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'sector_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 3)
|
||||
class SectorModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final String libelle;
|
||||
|
||||
@HiveField(2)
|
||||
final String color;
|
||||
|
||||
@HiveField(3)
|
||||
final String sector;
|
||||
|
||||
SectorModel({
|
||||
required this.id,
|
||||
required this.libelle,
|
||||
required this.color,
|
||||
required this.sector,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory SectorModel.fromJson(Map<String, dynamic> json) {
|
||||
return SectorModel(
|
||||
id: json['id'] is String ? int.parse(json['id']) : json['id'] as int,
|
||||
libelle: json['libelle'] as String,
|
||||
color: json['color'] as String,
|
||||
sector: json['sector'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'libelle': libelle,
|
||||
'color': color,
|
||||
'sector': sector,
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
SectorModel copyWith({
|
||||
int? id,
|
||||
String? libelle,
|
||||
String? color,
|
||||
String? sector,
|
||||
}) {
|
||||
return SectorModel(
|
||||
id: id ?? this.id,
|
||||
libelle: libelle ?? this.libelle,
|
||||
color: color ?? this.color,
|
||||
sector: sector ?? this.sector,
|
||||
);
|
||||
}
|
||||
|
||||
// Obtenir les coordonnées du secteur sous forme de liste de points
|
||||
List<List<double>> getCoordinates() {
|
||||
final List<List<double>> coordinates = [];
|
||||
|
||||
// Le format est "lat1/lng1#lat2/lng2#lat3/lng3#..."
|
||||
final List<String> points = sector.split('#');
|
||||
|
||||
for (final String point in points) {
|
||||
if (point.isEmpty) continue;
|
||||
|
||||
final List<String> latLng = point.split('/');
|
||||
if (latLng.length == 2) {
|
||||
try {
|
||||
final double lat = double.parse(latLng[0]);
|
||||
final double lng = double.parse(latLng[1]);
|
||||
coordinates.add([lat, lng]);
|
||||
} catch (e) {
|
||||
// Ignorer les points mal formatés
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
}
|
||||
50
app/lib/core/data/models/sector_model.g.dart
Normal file
50
app/lib/core/data/models/sector_model.g.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'sector_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class SectorModelAdapter extends TypeAdapter<SectorModel> {
|
||||
@override
|
||||
final int typeId = 3;
|
||||
|
||||
@override
|
||||
SectorModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return SectorModel(
|
||||
id: fields[0] as int,
|
||||
libelle: fields[1] as String,
|
||||
color: fields[2] as String,
|
||||
sector: fields[3] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, SectorModel obj) {
|
||||
writer
|
||||
..writeByte(4)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.libelle)
|
||||
..writeByte(2)
|
||||
..write(obj.color)
|
||||
..writeByte(3)
|
||||
..write(obj.sector);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is SectorModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
242
app/lib/core/data/models/user_model.dart
Normal file
242
app/lib/core/data/models/user_model.dart
Normal file
@@ -0,0 +1,242 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'user_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 0)
|
||||
class UserModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
|
||||
@HiveField(1)
|
||||
final String email;
|
||||
|
||||
@HiveField(2)
|
||||
String? name;
|
||||
|
||||
@HiveField(11)
|
||||
String? username;
|
||||
|
||||
@HiveField(10)
|
||||
String? firstName;
|
||||
|
||||
@HiveField(3)
|
||||
final int role;
|
||||
|
||||
@HiveField(4)
|
||||
final DateTime createdAt;
|
||||
|
||||
@HiveField(5)
|
||||
DateTime lastSyncedAt;
|
||||
|
||||
@HiveField(6)
|
||||
bool isActive;
|
||||
|
||||
@HiveField(7)
|
||||
bool isSynced;
|
||||
|
||||
@HiveField(8)
|
||||
String? sessionId;
|
||||
|
||||
@HiveField(9)
|
||||
DateTime? sessionExpiry;
|
||||
|
||||
@HiveField(12)
|
||||
String? lastPath;
|
||||
|
||||
@HiveField(13)
|
||||
String? sectName;
|
||||
|
||||
@HiveField(14)
|
||||
int? fkEntite;
|
||||
|
||||
@HiveField(15)
|
||||
int? fkTitre;
|
||||
|
||||
@HiveField(16)
|
||||
String? phone;
|
||||
|
||||
@HiveField(17)
|
||||
String? mobile;
|
||||
|
||||
@HiveField(18)
|
||||
DateTime? dateNaissance;
|
||||
|
||||
@HiveField(19)
|
||||
DateTime? dateEmbauche;
|
||||
|
||||
UserModel({
|
||||
required this.id,
|
||||
required this.email,
|
||||
this.name,
|
||||
this.username,
|
||||
this.firstName,
|
||||
required this.role,
|
||||
required this.createdAt,
|
||||
required this.lastSyncedAt,
|
||||
this.isActive = true,
|
||||
this.isSynced = false,
|
||||
this.sessionId,
|
||||
this.sessionExpiry,
|
||||
this.lastPath,
|
||||
this.sectName,
|
||||
this.fkEntite,
|
||||
this.fkTitre,
|
||||
this.phone,
|
||||
this.mobile,
|
||||
this.dateNaissance,
|
||||
this.dateEmbauche,
|
||||
});
|
||||
|
||||
// Factory pour convertir depuis JSON (API)
|
||||
factory UserModel.fromJson(Map<String, dynamic> json) {
|
||||
// Convertir l'ID en int, qu'il soit déjà int ou string
|
||||
final dynamic rawId = json['id'];
|
||||
final int id = rawId is String ? int.parse(rawId) : rawId as int;
|
||||
|
||||
// Convertir le rôle en int, qu'il soit déjà int ou string
|
||||
final dynamic rawRole = json['role'] ?? json['fk_role'];
|
||||
final int role = rawRole is String ? int.parse(rawRole) : rawRole as int;
|
||||
|
||||
// Convertir fk_entite en int si présent
|
||||
final dynamic rawFkEntite = json['fk_entite'];
|
||||
final int? fkEntite = rawFkEntite != null
|
||||
? (rawFkEntite is String ? int.parse(rawFkEntite) : rawFkEntite as int)
|
||||
: null;
|
||||
|
||||
// Convertir fk_titre en int si présent
|
||||
final dynamic rawFkTitre = json['fk_titre'];
|
||||
final int? fkTitre = rawFkTitre != null
|
||||
? (rawFkTitre is String ? int.parse(rawFkTitre) : rawFkTitre as int)
|
||||
: null;
|
||||
|
||||
// Traiter les dates si présentes
|
||||
DateTime? dateNaissance;
|
||||
if (json['date_naissance'] != null && json['date_naissance'] != '') {
|
||||
try {
|
||||
dateNaissance = DateTime.parse(json['date_naissance']);
|
||||
} catch (e) {
|
||||
dateNaissance = null;
|
||||
}
|
||||
}
|
||||
|
||||
DateTime? dateEmbauche;
|
||||
if (json['date_embauche'] != null && json['date_embauche'] != '') {
|
||||
try {
|
||||
dateEmbauche = DateTime.parse(json['date_embauche']);
|
||||
} catch (e) {
|
||||
dateEmbauche = null;
|
||||
}
|
||||
}
|
||||
|
||||
return UserModel(
|
||||
id: id,
|
||||
email: json['email'] ?? '',
|
||||
name: json['name'],
|
||||
username: json['username'],
|
||||
firstName: json['first_name'],
|
||||
role: role,
|
||||
createdAt: json['created_at'] != null
|
||||
? DateTime.parse(json['created_at'])
|
||||
: DateTime.now(),
|
||||
lastSyncedAt: DateTime.now(),
|
||||
isActive: json['is_active'] ?? true,
|
||||
isSynced: true,
|
||||
sessionId: json['session_id'],
|
||||
sessionExpiry: json['session_expiry'] != null
|
||||
? DateTime.parse(json['session_expiry'])
|
||||
: null,
|
||||
sectName: json['sect_name'],
|
||||
fkEntite: fkEntite,
|
||||
fkTitre: fkTitre,
|
||||
phone: json['phone'],
|
||||
mobile: json['mobile'],
|
||||
dateNaissance: dateNaissance,
|
||||
dateEmbauche: dateEmbauche,
|
||||
);
|
||||
}
|
||||
|
||||
// Convertir en JSON pour l'API
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'email': email,
|
||||
'name': name,
|
||||
'username': username,
|
||||
'first_name': firstName,
|
||||
'role': role,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'is_active': isActive,
|
||||
'session_id': sessionId,
|
||||
'session_expiry': sessionExpiry?.toIso8601String(),
|
||||
'last_path': lastPath,
|
||||
'sect_name': sectName,
|
||||
'fk_entite': fkEntite,
|
||||
'fk_titre': fkTitre,
|
||||
'phone': phone,
|
||||
'mobile': mobile,
|
||||
'date_naissance': dateNaissance?.toIso8601String(),
|
||||
'date_embauche': dateEmbauche?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
// Copier avec de nouvelles valeurs
|
||||
UserModel copyWith({
|
||||
String? email,
|
||||
String? name,
|
||||
String? username,
|
||||
String? firstName,
|
||||
int? role,
|
||||
bool? isActive,
|
||||
bool? isSynced,
|
||||
DateTime? lastSyncedAt,
|
||||
String? sessionId,
|
||||
DateTime? sessionExpiry,
|
||||
String? lastPath,
|
||||
String? sectName,
|
||||
int? fkEntite,
|
||||
int? fkTitre,
|
||||
String? phone,
|
||||
String? mobile,
|
||||
DateTime? dateNaissance,
|
||||
DateTime? dateEmbauche,
|
||||
}) {
|
||||
return UserModel(
|
||||
id: this.id,
|
||||
email: email ?? this.email,
|
||||
name: name ?? this.name,
|
||||
username: username ?? this.username,
|
||||
firstName: firstName ?? this.firstName,
|
||||
role: role ?? this.role,
|
||||
createdAt: this.createdAt,
|
||||
lastSyncedAt: lastSyncedAt ?? this.lastSyncedAt,
|
||||
isActive: isActive ?? this.isActive,
|
||||
isSynced: isSynced ?? this.isSynced,
|
||||
sessionId: sessionId ?? this.sessionId,
|
||||
sessionExpiry: sessionExpiry ?? this.sessionExpiry,
|
||||
lastPath: lastPath ?? this.lastPath,
|
||||
sectName: sectName ?? this.sectName,
|
||||
fkEntite: fkEntite ?? this.fkEntite,
|
||||
fkTitre: fkTitre ?? this.fkTitre,
|
||||
phone: phone ?? this.phone,
|
||||
mobile: mobile ?? this.mobile,
|
||||
dateNaissance: dateNaissance ?? this.dateNaissance,
|
||||
dateEmbauche: dateEmbauche ?? this.dateEmbauche,
|
||||
);
|
||||
}
|
||||
|
||||
// Vérifier si la session est valide
|
||||
bool get hasValidSession {
|
||||
if (sessionId == null || sessionExpiry == null) {
|
||||
return false;
|
||||
}
|
||||
return sessionExpiry!.isAfter(DateTime.now());
|
||||
}
|
||||
|
||||
// Effacer les données de session
|
||||
UserModel clearSession() {
|
||||
return copyWith(
|
||||
sessionId: null,
|
||||
sessionExpiry: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
98
app/lib/core/data/models/user_model.g.dart
Normal file
98
app/lib/core/data/models/user_model.g.dart
Normal file
@@ -0,0 +1,98 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class UserModelAdapter extends TypeAdapter<UserModel> {
|
||||
@override
|
||||
final int typeId = 0;
|
||||
|
||||
@override
|
||||
UserModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return UserModel(
|
||||
id: fields[0] as int,
|
||||
email: fields[1] as String,
|
||||
name: fields[2] as String?,
|
||||
username: fields[11] as String?,
|
||||
firstName: fields[10] as String?,
|
||||
role: fields[3] as int,
|
||||
createdAt: fields[4] as DateTime,
|
||||
lastSyncedAt: fields[5] as DateTime,
|
||||
isActive: fields[6] as bool,
|
||||
isSynced: fields[7] as bool,
|
||||
sessionId: fields[8] as String?,
|
||||
sessionExpiry: fields[9] as DateTime?,
|
||||
lastPath: fields[12] as String?,
|
||||
sectName: fields[13] as String?,
|
||||
fkEntite: fields[14] as int?,
|
||||
fkTitre: fields[15] as int?,
|
||||
phone: fields[16] as String?,
|
||||
mobile: fields[17] as String?,
|
||||
dateNaissance: fields[18] as DateTime?,
|
||||
dateEmbauche: fields[19] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, UserModel obj) {
|
||||
writer
|
||||
..writeByte(20)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.email)
|
||||
..writeByte(2)
|
||||
..write(obj.name)
|
||||
..writeByte(11)
|
||||
..write(obj.username)
|
||||
..writeByte(10)
|
||||
..write(obj.firstName)
|
||||
..writeByte(3)
|
||||
..write(obj.role)
|
||||
..writeByte(4)
|
||||
..write(obj.createdAt)
|
||||
..writeByte(5)
|
||||
..write(obj.lastSyncedAt)
|
||||
..writeByte(6)
|
||||
..write(obj.isActive)
|
||||
..writeByte(7)
|
||||
..write(obj.isSynced)
|
||||
..writeByte(8)
|
||||
..write(obj.sessionId)
|
||||
..writeByte(9)
|
||||
..write(obj.sessionExpiry)
|
||||
..writeByte(12)
|
||||
..write(obj.lastPath)
|
||||
..writeByte(13)
|
||||
..write(obj.sectName)
|
||||
..writeByte(14)
|
||||
..write(obj.fkEntite)
|
||||
..writeByte(15)
|
||||
..write(obj.fkTitre)
|
||||
..writeByte(16)
|
||||
..write(obj.phone)
|
||||
..writeByte(17)
|
||||
..write(obj.mobile)
|
||||
..writeByte(18)
|
||||
..write(obj.dateNaissance)
|
||||
..writeByte(19)
|
||||
..write(obj.dateEmbauche);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is UserModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
80
app/lib/core/data/models/user_sector_model.dart
Normal file
80
app/lib/core/data/models/user_sector_model.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'user_sector_model.g.dart';
|
||||
|
||||
/// Modèle pour stocker les associations entre utilisateurs et secteurs
|
||||
///
|
||||
/// Cette classe représente l'association entre un utilisateur et un secteur,
|
||||
/// telle que reçue de l'API dans la réponse users_sectors.
|
||||
@HiveType(
|
||||
typeId: 7) // Assurez-vous que cet ID est unique parmi vos modèles Hive
|
||||
class UserSectorModel extends HiveObject {
|
||||
@HiveField(0)
|
||||
final int id; // ID de l'utilisateur
|
||||
|
||||
@HiveField(1)
|
||||
final String? firstName;
|
||||
|
||||
@HiveField(2)
|
||||
final String? sectName;
|
||||
|
||||
@HiveField(3)
|
||||
final int fkSector; // ID du secteur
|
||||
|
||||
@HiveField(4)
|
||||
final String? name;
|
||||
|
||||
UserSectorModel({
|
||||
required this.id,
|
||||
this.firstName,
|
||||
this.sectName,
|
||||
required this.fkSector,
|
||||
this.name,
|
||||
});
|
||||
|
||||
/// Crée un modèle UserSectorModel à partir d'un objet JSON
|
||||
factory UserSectorModel.fromJson(Map<String, dynamic> json) {
|
||||
return UserSectorModel(
|
||||
id: json['id'] is String ? int.parse(json['id']) : json['id'],
|
||||
firstName: json['first_name'],
|
||||
sectName: json['sect_name'],
|
||||
fkSector: json['fk_sector'] is String
|
||||
? int.parse(json['fk_sector'])
|
||||
: json['fk_sector'],
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en objet JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'first_name': firstName,
|
||||
'sect_name': sectName,
|
||||
'fk_sector': fkSector,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
|
||||
/// Crée une copie du modèle avec des valeurs potentiellement modifiées
|
||||
UserSectorModel copyWith({
|
||||
int? id,
|
||||
String? firstName,
|
||||
String? sectName,
|
||||
int? fkSector,
|
||||
String? name,
|
||||
}) {
|
||||
return UserSectorModel(
|
||||
id: id ?? this.id,
|
||||
firstName: firstName ?? this.firstName,
|
||||
sectName: sectName ?? this.sectName,
|
||||
fkSector: fkSector ?? this.fkSector,
|
||||
name: name ?? this.name,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserSectorModel(id: $id, firstName: $firstName, sectName: $sectName, fkSector: $fkSector, name: $name)';
|
||||
}
|
||||
}
|
||||
53
app/lib/core/data/models/user_sector_model.g.dart
Normal file
53
app/lib/core/data/models/user_sector_model.g.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_sector_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class UserSectorModelAdapter extends TypeAdapter<UserSectorModel> {
|
||||
@override
|
||||
final int typeId = 7;
|
||||
|
||||
@override
|
||||
UserSectorModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return UserSectorModel(
|
||||
id: fields[0] as int,
|
||||
firstName: fields[1] as String?,
|
||||
sectName: fields[2] as String?,
|
||||
fkSector: fields[3] as int,
|
||||
name: fields[4] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, UserSectorModel obj) {
|
||||
writer
|
||||
..writeByte(5)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.firstName)
|
||||
..writeByte(2)
|
||||
..write(obj.sectName)
|
||||
..writeByte(3)
|
||||
..write(obj.fkSector)
|
||||
..writeByte(4)
|
||||
..write(obj.name);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is UserSectorModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
Reference in New Issue
Block a user