127 lines
5.4 KiB
Dart
127 lines
5.4 KiB
Dart
// ── USER ──────────────────────────────────────────────────────────────────
|
|
class UserModel {
|
|
final int? id;
|
|
final String nombre;
|
|
final String email;
|
|
final String password;
|
|
final String rol; // CIUDADANO | CONDUCTOR | ADMINISTRADOR
|
|
|
|
UserModel({this.id, required this.nombre, required this.email,
|
|
required this.password, required this.rol});
|
|
|
|
Map<String, dynamic> toMap() =>
|
|
{'id': id, 'nombre': nombre, 'email': email, 'password': password, 'rol': rol};
|
|
|
|
factory UserModel.fromMap(Map<String, dynamic> m) => UserModel(
|
|
id: m['id'], nombre: m['nombre'], email: m['email'],
|
|
password: m['password'], rol: m['rol']);
|
|
}
|
|
|
|
// ── DOMICILIO (citizen) ───────────────────────────────────────────────────
|
|
class DomicilioModel {
|
|
final int? id;
|
|
final int userId;
|
|
final String calle;
|
|
final String colonia;
|
|
final String routeId;
|
|
final String horarioEstimado;
|
|
final bool isPrimary;
|
|
|
|
DomicilioModel({this.id, required this.userId, required this.calle,
|
|
required this.colonia, required this.routeId,
|
|
required this.horarioEstimado, this.isPrimary = true});
|
|
|
|
Map<String, dynamic> toMap() => {'id': id, 'user_id': userId, 'calle': calle,
|
|
'colonia': colonia, 'route_id': routeId,
|
|
'horario_estimado': horarioEstimado, 'is_primary': isPrimary ? 1 : 0};
|
|
|
|
factory DomicilioModel.fromMap(Map<String, dynamic> m) => DomicilioModel(
|
|
id: m['id'], userId: m['user_id'], calle: m['calle'],
|
|
colonia: m['colonia'], routeId: m['route_id'],
|
|
horarioEstimado: m['horario_estimado'], isPrimary: m['is_primary'] == 1);
|
|
}
|
|
|
|
// ── ASSIGNMENT (driver schedule) ──────────────────────────────────────────
|
|
class AssignmentModel {
|
|
final int? id;
|
|
final int conductorId;
|
|
final String routeId;
|
|
final String diaSemana;
|
|
final String turno; // MATUTINO | VESPERTINO | NOCTURNO
|
|
|
|
AssignmentModel({this.id, required this.conductorId, required this.routeId,
|
|
required this.diaSemana, required this.turno});
|
|
|
|
Map<String, dynamic> toMap() => {'id': id, 'conductor_id': conductorId,
|
|
'route_id': routeId, 'dia_semana': diaSemana, 'turno': turno};
|
|
|
|
factory AssignmentModel.fromMap(Map<String, dynamic> m) => AssignmentModel(
|
|
id: m['id'], conductorId: m['conductor_id'], routeId: m['route_id'],
|
|
diaSemana: m['dia_semana'], turno: m['turno']);
|
|
}
|
|
|
|
// ── ROUTE STATUS ──────────────────────────────────────────────────────────
|
|
class RouteStatusModel {
|
|
final String routeId;
|
|
final String status;
|
|
final String? mensaje;
|
|
final String updatedAt;
|
|
|
|
RouteStatusModel({required this.routeId, required this.status,
|
|
this.mensaje, required this.updatedAt});
|
|
|
|
Map<String, dynamic> toMap() => {'route_id': routeId, 'status': status,
|
|
'mensaje': mensaje, 'updated_at': updatedAt};
|
|
|
|
factory RouteStatusModel.fromMap(Map<String, dynamic> m) => RouteStatusModel(
|
|
routeId: m['route_id'], status: m['status'],
|
|
mensaje: m['mensaje'], updatedAt: m['updated_at']);
|
|
}
|
|
|
|
// ── ALERTA ────────────────────────────────────────────────────────────────
|
|
class AlertaModel {
|
|
final int? id;
|
|
final String tipo; // GPS_PERDIDO | CAMION_DETENIDO | FALLA_MECANICA
|
|
final String routeId;
|
|
final String mensaje;
|
|
final String fecha;
|
|
final bool resuelta;
|
|
|
|
AlertaModel({this.id, required this.tipo, required this.routeId,
|
|
required this.mensaje, required this.fecha, this.resuelta = false});
|
|
|
|
Map<String, dynamic> toMap() => {'id': id, 'tipo': tipo, 'route_id': routeId,
|
|
'mensaje': mensaje, 'fecha': fecha, 'resuelta': resuelta ? 1 : 0};
|
|
|
|
factory AlertaModel.fromMap(Map<String, dynamic> m) => AlertaModel(
|
|
id: m['id'], tipo: m['tipo'], routeId: m['route_id'],
|
|
mensaje: m['mensaje'], fecha: m['fecha'], resuelta: m['resuelta'] == 1);
|
|
}
|
|
|
|
// ── REPORTE ───────────────────────────────────────────────────────────────
|
|
class ReporteModel {
|
|
final int? id;
|
|
final int userId;
|
|
final String tipo;
|
|
final String descripcion;
|
|
final String colonia;
|
|
final String routeId;
|
|
final String fecha;
|
|
final String estado;
|
|
final int calificacion;
|
|
|
|
ReporteModel({this.id, required this.userId, required this.tipo,
|
|
required this.descripcion, required this.colonia, required this.routeId,
|
|
required this.fecha, this.estado = 'PENDIENTE', this.calificacion = 5});
|
|
|
|
Map<String, dynamic> toMap() => {'id': id, 'user_id': userId, 'tipo': tipo,
|
|
'descripcion': descripcion, 'colonia': colonia, 'route_id': routeId,
|
|
'fecha': fecha, 'estado': estado, 'calificacion': calificacion};
|
|
|
|
factory ReporteModel.fromMap(Map<String, dynamic> m) => ReporteModel(
|
|
id: m['id'], userId: m['user_id'], tipo: m['tipo'],
|
|
descripcion: m['descripcion'], colonia: m['colonia'],
|
|
routeId: m['route_id'] ?? '', fecha: m['fecha'],
|
|
estado: m['estado'], calificacion: m['calificacion'] ?? 5);
|
|
}
|