86 lines
2.4 KiB
Dart
86 lines
2.4 KiB
Dart
class Usuario {
|
|
final int id;
|
|
final String nombre;
|
|
final String iniciales;
|
|
final int nivelAcceso;
|
|
final String pinHash;
|
|
final String? areas;
|
|
final String? fechaInicio;
|
|
final String? fechaFin;
|
|
final bool activo;
|
|
final bool sincronizado;
|
|
final String? fotoPath;
|
|
// Teléfono móvil en formato internacional E.164 para recepción de alertas WhatsApp vía sigma-robot
|
|
final String? telefono;
|
|
|
|
const Usuario({
|
|
required this.id,
|
|
required this.nombre,
|
|
required this.iniciales,
|
|
required this.nivelAcceso,
|
|
required this.pinHash,
|
|
this.areas,
|
|
this.fechaInicio,
|
|
this.fechaFin,
|
|
this.activo = true,
|
|
this.sincronizado = false,
|
|
this.fotoPath,
|
|
this.telefono,
|
|
});
|
|
|
|
factory Usuario.fromMap(Map<String, dynamic> m) => Usuario(
|
|
id: m['id'] as int,
|
|
nombre: m['nombre'] as String,
|
|
iniciales: m['iniciales'] as String,
|
|
nivelAcceso: m['nivel_acceso'] as int,
|
|
pinHash: m['pin_hash'] as String,
|
|
areas: m['areas'] as String?,
|
|
fechaInicio: m['fecha_inicio'] as String?,
|
|
fechaFin: m['fecha_fin'] as String?,
|
|
activo: (m['activo'] as int) == 1,
|
|
sincronizado: (m['sincronizado'] as int) == 1,
|
|
fotoPath: m['foto_path'] as String?,
|
|
// Mapeo del campo telefono desde la base de datos local SQLite
|
|
telefono: m['telefono'] as String?,
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
'id': id,
|
|
'nombre': nombre,
|
|
'iniciales': iniciales,
|
|
'nivel_acceso': nivelAcceso,
|
|
'pin_hash': pinHash,
|
|
'areas': areas,
|
|
'fecha_inicio': fechaInicio,
|
|
'fecha_fin': fechaFin,
|
|
'activo': activo ? 1 : 0,
|
|
'sincronizado': sincronizado ? 1 : 0,
|
|
'foto_path': fotoPath,
|
|
// Persistencia del campo telefono para SQLite
|
|
'telefono': telefono,
|
|
};
|
|
|
|
Usuario copyWith({
|
|
String? nombre,
|
|
String? iniciales,
|
|
String? fotoPath,
|
|
String? telefono,
|
|
bool? sincronizado,
|
|
}) =>
|
|
Usuario(
|
|
id: id,
|
|
nombre: nombre ?? this.nombre,
|
|
iniciales: iniciales ?? this.iniciales,
|
|
nivelAcceso: nivelAcceso,
|
|
pinHash: pinHash,
|
|
areas: areas,
|
|
fechaInicio: fechaInicio,
|
|
fechaFin: fechaFin,
|
|
activo: activo,
|
|
sincronizado: sincronizado ?? this.sincronizado,
|
|
fotoPath: fotoPath ?? this.fotoPath,
|
|
// Preserva o actualiza el teléfono de alertas
|
|
telefono: telefono ?? this.telefono,
|
|
);
|
|
}
|