generated from dellevin/template
windows版本搜索功能优化
This commit is contained in:
@@ -16,13 +16,13 @@ class BookDao {
|
||||
}
|
||||
|
||||
// 获取所有未删除的书籍记录
|
||||
Future<List<Book>> getAllBooks() => _wrap('getAllBooks', () async {
|
||||
Future<List<Book>> getAllBooks({int sortMode = 0}) => _wrap('getAllBooks', () async {
|
||||
final db = await _dbHelper.database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
'books',
|
||||
where: 'is_deleted = ?',
|
||||
whereArgs: [0],
|
||||
orderBy: 'created_at DESC',
|
||||
orderBy: _buildBookOrderBy(sortMode),
|
||||
);
|
||||
return List.generate(maps.length, (i) => Book.fromJson(maps[i]));
|
||||
});
|
||||
@@ -45,7 +45,7 @@ class BookDao {
|
||||
switch (sortMode) {
|
||||
case 1: return 'created_at DESC';
|
||||
case 2: return 'rating DESC NULLS LAST, updated_at DESC';
|
||||
default: return 'created_at DESC';
|
||||
default: return 'updated_at DESC';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ class GameDao {
|
||||
}
|
||||
|
||||
// 获取所有游戏记录(未删除的)
|
||||
Future<List<Game>> getAllGames() => _wrap('getAllGames', () async {
|
||||
Future<List<Game>> getAllGames({int sortMode = 0}) => _wrap('getAllGames', () async {
|
||||
final db = await _dbHelper.database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
'games',
|
||||
where: 'is_deleted = ?',
|
||||
whereArgs: [0],
|
||||
orderBy: 'created_at DESC',
|
||||
orderBy: _buildGameOrderBy(sortMode),
|
||||
);
|
||||
return List.generate(maps.length, (i) => Game.fromJson(maps[i]));
|
||||
});
|
||||
@@ -45,7 +45,7 @@ class GameDao {
|
||||
switch (sortMode) {
|
||||
case 1: return 'created_at DESC';
|
||||
case 2: return 'rating DESC NULLS LAST, updated_at DESC';
|
||||
default: return 'created_at DESC';
|
||||
default: return 'updated_at DESC';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ class MovieDao {
|
||||
}
|
||||
|
||||
// 获取所有影视记录(未删除的)
|
||||
Future<List<Movie>> getAllMovies() => _wrap('getAllMovies', () async {
|
||||
Future<List<Movie>> getAllMovies({int sortMode = 0}) => _wrap('getAllMovies', () async {
|
||||
final db = await _dbHelper.database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
'movies',
|
||||
where: 'is_deleted = ?',
|
||||
whereArgs: [0],
|
||||
orderBy: 'created_at DESC',
|
||||
orderBy: _buildMovieOrderBy(sortMode),
|
||||
);
|
||||
return List.generate(maps.length, (i) => Movie.fromJson(maps[i]));
|
||||
});
|
||||
@@ -49,7 +49,7 @@ class MovieDao {
|
||||
switch (sortMode) {
|
||||
case 1: return 'created_at DESC';
|
||||
case 2: return 'rating DESC NULLS LAST, updated_at DESC';
|
||||
default: return 'created_at DESC';
|
||||
default: return 'updated_at DESC';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class NoteDao {
|
||||
switch (sortMode) {
|
||||
case 1: return 'is_pinned DESC, created_at DESC';
|
||||
case 2: return 'is_pinned DESC, title COLLATE NOCASE ASC';
|
||||
default: return 'is_pinned DESC, created_at DESC';
|
||||
default: return 'is_pinned DESC, updated_at DESC';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user