- OperadorLoginPage con auth WebControl 2 pasos (empresas → login) - ShellPage: sidebar 220px + IndexedStack + header con estado API - DashboardPage: stat cards, feed alarmas, clientes, incidentes (timer 30s) - ApiAuthService: flujo real con email + paswd + dba → token + apiKey - DB SQLite v1: 7 tablas + 7 DAOs completos - theme.dart: AppColors, appHeadline (Manrope), appLabel (Inter) - Logo app: escudo radar neón (SVG + PNG 512px) en lib/recursos/ - desplegar.sh: build release Linux + upload a siax-system.net - agents.md: estado completo + objetivos futuros documentados Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1009 B
Dart
32 lines
1009 B
Dart
import 'package:sqflite/sqflite.dart';
|
|
import '../database_helper.dart';
|
|
|
|
class CacheClientesDao {
|
|
final _db = DatabaseHelper.instance;
|
|
|
|
Future<List<Map<String, dynamic>>> getTodos() async {
|
|
final db = await _db.db;
|
|
return db.query('cache_clientes', orderBy: 'alarmas_criticas DESC, nombre ASC');
|
|
}
|
|
|
|
Future<Map<String, dynamic>?> getById(int id) async {
|
|
final db = await _db.db;
|
|
final rows = await db.query('cache_clientes', where: 'id = ?', whereArgs: [id]);
|
|
return rows.isEmpty ? null : rows.first;
|
|
}
|
|
|
|
Future<int> contarActivos() async {
|
|
final db = await _db.db;
|
|
final result = await db.rawQuery('SELECT COUNT(*) as c FROM cache_clientes');
|
|
return result.first['c'] as int;
|
|
}
|
|
|
|
Future<void> reemplazarTodos(List<Map<String, dynamic>> clientes) async {
|
|
final db = await _db.db;
|
|
await db.delete('cache_clientes');
|
|
for (final c in clientes) {
|
|
await db.insert('cache_clientes', c, conflictAlgorithm: ConflictAlgorithm.replace);
|
|
}
|
|
}
|
|
}
|