From 46a7ab9076b6ce134985c8e0667181f1c60ec616 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 2 Oct 2022 16:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/BookType.kt | 5 +++++ app/src/main/java/io/legado/app/data/dao/BookDao.kt | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/BookType.kt b/app/src/main/java/io/legado/app/constant/BookType.kt index 55b1c442f..4e66053b1 100644 --- a/app/src/main/java/io/legado/app/constant/BookType.kt +++ b/app/src/main/java/io/legado/app/constant/BookType.kt @@ -9,6 +9,11 @@ object BookType { const val file = 3 // 3 只提供下载服务的网站 const val local = "loc_book" + /** + * 书源已webDav::开头的书籍,可以从webDav更新或重新下载 + */ + const val webDav = "webDav::" + @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.SOURCE) @IntDef(default, audio, image, file) diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index 48915f1b0..7c4de7d90 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -12,7 +12,7 @@ interface BookDao { @Query( """ select * from books where type != ${BookType.audio} - and origin != '${BookType.local}' + and origin != '${BookType.local}' and origin not like '${BookType.webDav}%' and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0 and (select show from book_groups where groupId = ${AppConst.bookGroupNetNoneId}) != 1 """ @@ -25,12 +25,12 @@ interface BookDao { @Query("SELECT * FROM books WHERE type = ${BookType.audio}") fun flowAudio(): Flow> - @Query("SELECT * FROM books WHERE origin = '${BookType.local}'") + @Query("SELECT * FROM books WHERE origin = '${BookType.local}' or origin like '${BookType.webDav}%'") fun flowLocal(): Flow> @Query( """ - select * from books where type != ${BookType.audio} and origin != '${BookType.local}' + select * from books where type != ${BookType.audio} and origin != '${BookType.local}' and origin not like '${BookType.webDav}%' and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0 """ ) @@ -38,13 +38,13 @@ interface BookDao { @Query( """ - select * from books where type != ${BookType.audio} and origin = '${BookType.local}' + select * from books where origin = '${BookType.local}' or origin like '${BookType.webDav}%' and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0 """ ) fun flowLocalNoGroup(): Flow> - @Query("SELECT bookUrl FROM books WHERE origin = '${BookType.local}'") + @Query("SELECT bookUrl FROM books WHERE origin = '${BookType.local}' or origin like '${BookType.webDav}%'") fun flowLocalUri(): Flow> @Query("SELECT * FROM books WHERE (`group` & :group) > 0")