代码优化2

This commit is contained in:
DelLevin-Home
2026-06-27 19:20:03 +08:00
parent bcff4f6c01
commit a1fe0a23ef
31 changed files with 285 additions and 162 deletions

View File

@@ -174,6 +174,9 @@ class BookDao {
// 彻底删除书籍
Future<int> permanentDeleteBook(String id) => _wrap('permanentDeleteBook', () async {
final db = await _dbHelper.database;
// 清理子记录,防止孤儿数据
await db.delete('book_reviews', where: 'book_id = ?', whereArgs: [id]);
await db.delete('book_excerpts', where: 'book_id = ?', whereArgs: [id]);
return await db.delete(
'books',
where: 'id = ?',

View File

@@ -67,7 +67,7 @@ class BookExcerptDao {
final db = await _dbHelper.database;
await db.update(
'book_excerpts',
{'is_deleted': 1},
{'is_deleted': 1, 'updated_at': DateTime.now().toUtc().toIso8601String()},
where: 'id = ?',
whereArgs: [id],
);

View File

@@ -67,7 +67,7 @@ class BookReviewDao {
final db = await _dbHelper.database;
await db.update(
'book_reviews',
{'is_deleted': 1},
{'is_deleted': 1, 'updated_at': DateTime.now().toUtc().toIso8601String()},
where: 'id = ?',
whereArgs: [id],
);