Terepbejárás geometria hang és képi dokumentáció létrehozása. Gradle verzió frissítése
This commit is contained in:
@@ -5,6 +5,8 @@ import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:terepi_seged/enums/note_type.dart';
|
||||
import 'package:terepi_seged/models/note_item.dart';
|
||||
import 'package:terepi_seged/models/note_item_audio.dart';
|
||||
import 'package:terepi_seged/models/note_item_photo.dart';
|
||||
import 'package:terepi_seged/models/track.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import '../models/project.dart';
|
||||
@@ -132,6 +134,36 @@ class AppDatabase {
|
||||
await db
|
||||
.execute('CREATE INDEX idx_notes_project ON note_items(project_id)');
|
||||
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS note_item_photos (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
note_item_id INTEGER NOT NULL REFERENCES note_items(id) ON DELETE CASCADE,
|
||||
local_path TEXT NOT NULL,
|
||||
storage_path TEXT,
|
||||
caption TEXT NOT NULL DEFAULT '',
|
||||
latitude REAL,
|
||||
longitude REAL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
''');
|
||||
await db.execute(
|
||||
'CREATE INDEX idx_photos_note ON note_item_photos(note_item_id)');
|
||||
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS note_item_audios (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
note_item_id INTEGER NOT NULL REFERENCES note_items(id) ON DELETE CASCADE,
|
||||
local_path TEXT NOT NULL,
|
||||
caption TEXT NOT NULL DEFAULT '',
|
||||
duration_seconds INTEGER NOT NULL DEFAULT 0,
|
||||
latitude REAL,
|
||||
longitude REAL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
''');
|
||||
await db.execute(
|
||||
'CREATE INDEX idx_audios_note ON note_item_audios(note_item_id)');
|
||||
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS pending_points (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -459,4 +491,72 @@ class AppDatabase {
|
||||
whereArgs: [projectId],
|
||||
);
|
||||
}
|
||||
|
||||
// -------- NoteItemPhoto
|
||||
|
||||
Future<int> insertNotePhoto(NoteItemPhoto photo) async {
|
||||
final db = await database;
|
||||
return db.insert('note_item_photos', photo.toMap());
|
||||
}
|
||||
|
||||
Future<void> updateNotePhoto(NoteItemPhoto photo) async {
|
||||
final db = await database;
|
||||
await db.update(
|
||||
'note_item_photos',
|
||||
photo.toMap(),
|
||||
where: 'id = ?',
|
||||
whereArgs: [photo.id],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteNotePhoto(int id) async {
|
||||
final db = await database;
|
||||
await db.delete('note_item_photos', where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
|
||||
Future<List<NoteItemPhoto>> listNotePhotos(int noteItemId) async {
|
||||
final db = await database;
|
||||
final rows = await db.query(
|
||||
'note_item_photos',
|
||||
where: 'note_item_id = ?',
|
||||
whereArgs: [noteItemId],
|
||||
orderBy: 'created_at ASC',
|
||||
);
|
||||
return rows.map(NoteItemPhoto.fromMap).toList();
|
||||
}
|
||||
|
||||
Future<void> deleteAllNotePhotos(int noteItemId) async {
|
||||
final db = await database;
|
||||
await db.delete('note_item_photos',
|
||||
where: 'note_item_id = ?', whereArgs: [noteItemId]);
|
||||
}
|
||||
|
||||
// -------------- NoteItemAudio
|
||||
|
||||
Future<int> insertNoteAudio(NoteItemAudio audio) async {
|
||||
final db = await database;
|
||||
return db.insert('note_item_audios', audio.toMap());
|
||||
}
|
||||
|
||||
Future<void> updateNoteAudio(NoteItemAudio audio) async {
|
||||
final db = await database;
|
||||
await db.update('note_item_audios', audio.toMap(),
|
||||
where: 'id = ?', whereArgs: [audio.id]);
|
||||
}
|
||||
|
||||
Future<void> deleteNoteAudio(int id) async {
|
||||
final db = await database;
|
||||
await db.delete('note_item_audios', where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
|
||||
Future<List<NoteItemAudio>> listNoteAudios(int noteItemId) async {
|
||||
final db = await database;
|
||||
final rows = await db.query(
|
||||
'note_item_audios',
|
||||
where: 'note_item_id = ?',
|
||||
whereArgs: [noteItemId],
|
||||
orderBy: 'created_at ASC',
|
||||
);
|
||||
return rows.map(NoteItemAudio.fromMap).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user