App móvil Flutter para capturar contenido multimedia, etiquetarlo con hashes y enviarlo a backends configurables. Features: - Captura de fotos, audio, video y archivos - Sistema de etiquetas con bibliotecas externas (HST) - Packs de etiquetas predefinidos - Cola de reintentos (hasta 20 contenedores) - Soporte GPS - Hash SHA-256 auto-generado por contenedor - Persistencia SQLite local - Múltiples destinos configurables Stack: Flutter 3.38.5, flutter_bloc, sqflite, dio 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
78 lines
2.2 KiB
Dart
78 lines
2.2 KiB
Dart
import '../datasources/local_database.dart';
|
|
import '../../domain/entities/destino.dart';
|
|
import '../../domain/entities/biblioteca.dart';
|
|
|
|
class ConfigRepository {
|
|
// Destinos
|
|
Future<List<Destino>> getDestinos() async {
|
|
final db = await LocalDatabase.database;
|
|
final results = await db.query('destinos');
|
|
return results.map((m) => Destino.fromMap(m)).toList();
|
|
}
|
|
|
|
Future<Destino?> getDestinoActivo() async {
|
|
final db = await LocalDatabase.database;
|
|
final results = await db.query(
|
|
'destinos',
|
|
where: 'activo = ?',
|
|
whereArgs: [1],
|
|
limit: 1,
|
|
);
|
|
if (results.isEmpty) return null;
|
|
return Destino.fromMap(results.first);
|
|
}
|
|
|
|
Future<int> insertDestino(Destino destino) async {
|
|
final db = await LocalDatabase.database;
|
|
return db.insert('destinos', destino.toMap());
|
|
}
|
|
|
|
Future<void> updateDestino(Destino destino) async {
|
|
final db = await LocalDatabase.database;
|
|
await db.update(
|
|
'destinos',
|
|
destino.toMap(),
|
|
where: 'id = ?',
|
|
whereArgs: [destino.id],
|
|
);
|
|
}
|
|
|
|
Future<void> deleteDestino(int id) async {
|
|
final db = await LocalDatabase.database;
|
|
await db.delete('destinos', where: 'id = ?', whereArgs: [id]);
|
|
}
|
|
|
|
Future<void> setDestinoActivo(int id) async {
|
|
final db = await LocalDatabase.database;
|
|
await db.update('destinos', {'activo': 0});
|
|
await db.update('destinos', {'activo': 1}, where: 'id = ?', whereArgs: [id]);
|
|
}
|
|
|
|
// Bibliotecas
|
|
Future<List<Biblioteca>> getBibliotecas() async {
|
|
final db = await LocalDatabase.database;
|
|
final results = await db.query('bibliotecas');
|
|
return results.map((m) => Biblioteca.fromMap(m)).toList();
|
|
}
|
|
|
|
Future<int> insertBiblioteca(Biblioteca biblioteca) async {
|
|
final db = await LocalDatabase.database;
|
|
return db.insert('bibliotecas', biblioteca.toMap());
|
|
}
|
|
|
|
Future<void> updateBiblioteca(Biblioteca biblioteca) async {
|
|
final db = await LocalDatabase.database;
|
|
await db.update(
|
|
'bibliotecas',
|
|
biblioteca.toMap(),
|
|
where: 'id = ?',
|
|
whereArgs: [biblioteca.id],
|
|
);
|
|
}
|
|
|
|
Future<void> deleteBiblioteca(int id) async {
|
|
final db = await LocalDatabase.database;
|
|
await db.delete('bibliotecas', where: 'id = ?', whereArgs: [id]);
|
|
}
|
|
}
|