epub阅读+关联书籍

This commit is contained in:
DelLevin-Home
2026-06-27 18:13:34 +08:00
parent d54e33e4cf
commit bcff4f6c01
15 changed files with 1143 additions and 124 deletions

View File

@@ -72,6 +72,42 @@ class ReaderDao {
);
}
// ─── 关联 books 表 ─────────────────────────────────────────────
/// 关联 EPUB 到 books 表中的书籍
Future<int> linkToBook(String readerBookId, String bookId) async {
final db = await _db.database;
return db.update(
'reader_books',
{'book_id': bookId, 'updated_at': DateTime.now().toIso8601String()},
where: 'id = ?',
whereArgs: [readerBookId],
);
}
/// 取消关联
Future<int> unlinkBook(String readerBookId) async {
final db = await _db.database;
return db.update(
'reader_books',
{'book_id': '', 'updated_at': DateTime.now().toIso8601String()},
where: 'id = ?',
whereArgs: [readerBookId],
);
}
/// 通过 books.id 查找关联的 reader_book
Future<Map<String, dynamic>?> getReaderBookByBookId(String bookId) async {
final db = await _db.database;
final results = await db.query(
'reader_books',
where: 'book_id = ? AND is_deleted = 0',
whereArgs: [bookId],
limit: 1,
);
return results.isNotEmpty ? results.first : null;
}
// ─── book_annotations ─────────────────────────────────────────────
/// 获取某本书的所有批注