优化
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import io.legado.app.data.entities.Book
|
|||||||
import io.legado.app.data.entities.BookChapter
|
import io.legado.app.data.entities.BookChapter
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
import io.legado.app.data.entities.BookSource
|
import io.legado.app.data.entities.BookSource
|
||||||
|
import io.legado.app.data.entities.BookSourcePart
|
||||||
import io.legado.app.data.entities.Bookmark
|
import io.legado.app.data.entities.Bookmark
|
||||||
import io.legado.app.data.entities.Cache
|
import io.legado.app.data.entities.Cache
|
||||||
import io.legado.app.data.entities.Cookie
|
import io.legado.app.data.entities.Cookie
|
||||||
@@ -64,13 +65,14 @@ val appDb by lazy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 74,
|
version = 75,
|
||||||
exportSchema = true,
|
exportSchema = true,
|
||||||
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
||||||
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
||||||
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
|
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
|
||||||
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class,
|
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class,
|
||||||
RuleSub::class, DictRule::class, KeyboardAssist::class, Server::class],
|
RuleSub::class, DictRule::class, KeyboardAssist::class, Server::class],
|
||||||
|
views = [BookSourcePart::class],
|
||||||
autoMigrations = [
|
autoMigrations = [
|
||||||
AutoMigration(from = 43, to = 44),
|
AutoMigration(from = 43, to = 44),
|
||||||
AutoMigration(from = 44, to = 45),
|
AutoMigration(from = 44, to = 45),
|
||||||
@@ -103,6 +105,7 @@ val appDb by lazy {
|
|||||||
AutoMigration(from = 71, to = 72),
|
AutoMigration(from = 71, to = 72),
|
||||||
AutoMigration(from = 72, to = 73),
|
AutoMigration(from = 72, to = 73),
|
||||||
AutoMigration(from = 73, to = 74),
|
AutoMigration(from = 73, to = 74),
|
||||||
|
AutoMigration(from = 74, to = 75),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|||||||
@@ -20,22 +20,17 @@ import kotlinx.coroutines.flow.map
|
|||||||
@Dao
|
@Dao
|
||||||
interface BookSourceDao {
|
interface BookSourceDao {
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources order by customOrder asc"""
|
|
||||||
)
|
|
||||||
fun flowAll(): Flow<List<BookSourcePart>>
|
fun flowAll(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select bp.*
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
from book_sources b join book_sources_part bp on b.bookSourceUrl = bp.bookSourceUrl
|
||||||
from book_sources
|
where b.bookSourceName like '%' || :searchKey || '%'
|
||||||
where bookSourceName like '%' || :searchKey || '%'
|
or b.bookSourceGroup like '%' || :searchKey || '%'
|
||||||
or bookSourceGroup like '%' || :searchKey || '%'
|
or b.bookSourceUrl like '%' || :searchKey || '%'
|
||||||
or bookSourceUrl like '%' || :searchKey || '%'
|
or b.bookSourceComment like '%' || :searchKey || '%'
|
||||||
or bookSourceComment like '%' || :searchKey || '%'
|
order by b.customOrder asc"""
|
||||||
order by customOrder asc"""
|
|
||||||
)
|
)
|
||||||
fun flowSearch(searchKey: String): Flow<List<BookSourcePart>>
|
fun flowSearch(searchKey: String): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@@ -50,22 +45,19 @@ interface BookSourceDao {
|
|||||||
fun search(searchKey: String): List<BookSource>
|
fun search(searchKey: String): List<BookSource>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select bp.*
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
from book_sources b join book_sources_part bp on b.bookSourceUrl = bp.bookSourceUrl
|
||||||
from book_sources
|
where b.enabled = 1
|
||||||
where enabled = 1 and
|
and (b.bookSourceName like '%' || :searchKey || '%'
|
||||||
(bookSourceName like '%' || :searchKey || '%'
|
or b.bookSourceGroup like '%' || :searchKey || '%'
|
||||||
or bookSourceGroup like '%' || :searchKey || '%'
|
or b.bookSourceUrl like '%' || :searchKey || '%'
|
||||||
or bookSourceUrl like '%' || :searchKey || '%'
|
or b.bookSourceComment like '%' || :searchKey || '%')
|
||||||
or bookSourceComment like '%' || :searchKey || '%')
|
order by b.customOrder asc"""
|
||||||
order by customOrder asc"""
|
|
||||||
)
|
)
|
||||||
fun flowSearchEnabled(searchKey: String): Flow<List<BookSourcePart>>
|
fun flowSearchEnabled(searchKey: String): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select * from book_sources_part
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources
|
|
||||||
where bookSourceGroup = :searchKey
|
where bookSourceGroup = :searchKey
|
||||||
or bookSourceGroup like :searchKey || ',%'
|
or bookSourceGroup like :searchKey || ',%'
|
||||||
or bookSourceGroup like '%,' || :searchKey
|
or bookSourceGroup like '%,' || :searchKey
|
||||||
@@ -84,63 +76,38 @@ interface BookSourceDao {
|
|||||||
)
|
)
|
||||||
fun groupSearch(searchKey: String): List<BookSource>
|
fun groupSearch(searchKey: String): List<BookSource>
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part where enabled = 1 order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where enabled = 1 order by customOrder asc"""
|
|
||||||
)
|
|
||||||
fun flowEnabled(): Flow<List<BookSourcePart>>
|
fun flowEnabled(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part where enabled = 0 order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where enabled = 0 order by customOrder asc"""
|
|
||||||
)
|
|
||||||
fun flowDisabled(): Flow<List<BookSourcePart>>
|
fun flowDisabled(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select * from book_sources_part
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
where enabledExplore = 1 and hasExploreUrl = 1 order by customOrder asc"""
|
||||||
from book_sources where enabledExplore = 1 and trim(exploreUrl) <> '' order by customOrder asc"""
|
|
||||||
)
|
)
|
||||||
fun flowExplore(): Flow<List<BookSourcePart>>
|
fun flowExplore(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part where hasLoginUrl = 1 order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where loginUrl is not null and loginUrl != ''
|
|
||||||
order by customOrder asc"""
|
|
||||||
)
|
|
||||||
fun flowLogin(): Flow<List<BookSourcePart>>
|
fun flowLogin(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select * from book_sources_part
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'
|
||||||
from book_sources where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'
|
|
||||||
order by customOrder asc"""
|
order by customOrder asc"""
|
||||||
)
|
)
|
||||||
fun flowNoGroup(): Flow<List<BookSourcePart>>
|
fun flowNoGroup(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part where enabledExplore = 1 order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where enabledExplore = 1 order by customOrder asc"""
|
|
||||||
)
|
|
||||||
fun flowEnabledExplore(): Flow<List<BookSourcePart>>
|
fun flowEnabledExplore(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part where enabledExplore = 0 order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where enabledExplore = 0 order by customOrder asc"""
|
|
||||||
)
|
|
||||||
fun flowDisabledExplore(): Flow<List<BookSourcePart>>
|
fun flowDisabledExplore(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select * from book_sources_part
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources
|
|
||||||
where enabledExplore = 1
|
where enabledExplore = 1
|
||||||
and trim(exploreUrl) <> ''
|
and hasExploreUrl = 1
|
||||||
and (bookSourceGroup like '%' || :key || '%'
|
and (bookSourceGroup like '%' || :key || '%'
|
||||||
or bookSourceName like '%' || :key || '%')
|
or bookSourceName like '%' || :key || '%')
|
||||||
order by customOrder asc"""
|
order by customOrder asc"""
|
||||||
@@ -148,11 +115,9 @@ interface BookSourceDao {
|
|||||||
fun flowExplore(key: String): Flow<List<BookSourcePart>>
|
fun flowExplore(key: String): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select * from book_sources_part
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources
|
|
||||||
where enabledExplore = 1
|
where enabledExplore = 1
|
||||||
and trim(exploreUrl) <> ''
|
and hasExploreUrl = 1
|
||||||
and (bookSourceGroup = :key
|
and (bookSourceGroup = :key
|
||||||
or bookSourceGroup like :key || ',%'
|
or bookSourceGroup like :key || ',%'
|
||||||
or bookSourceGroup like '%,' || :key
|
or bookSourceGroup like '%,' || :key
|
||||||
@@ -164,7 +129,10 @@ interface BookSourceDao {
|
|||||||
@Query("select distinct bookSourceGroup from book_sources where trim(bookSourceGroup) <> ''")
|
@Query("select distinct bookSourceGroup from book_sources where trim(bookSourceGroup) <> ''")
|
||||||
fun flowGroupsUnProcessed(): Flow<List<String>>
|
fun flowGroupsUnProcessed(): Flow<List<String>>
|
||||||
|
|
||||||
@Query("select distinct bookSourceGroup from book_sources where enabled = 1 and trim(bookSourceGroup) <> ''")
|
@Query(
|
||||||
|
"""select distinct bookSourceGroup from book_sources
|
||||||
|
where enabled = 1 and trim(bookSourceGroup) <> ''"""
|
||||||
|
)
|
||||||
fun flowEnabledGroupsUnProcessed(): Flow<List<String>>
|
fun flowEnabledGroupsUnProcessed(): Flow<List<String>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
@@ -176,7 +144,10 @@ interface BookSourceDao {
|
|||||||
)
|
)
|
||||||
fun flowExploreGroupsUnProcessed(): Flow<List<String>>
|
fun flowExploreGroupsUnProcessed(): Flow<List<String>>
|
||||||
|
|
||||||
@Query("select * from book_sources where bookSourceGroup like '%' || :group || '%' order by customOrder asc")
|
@Query(
|
||||||
|
"""select * from book_sources
|
||||||
|
where bookSourceGroup like '%' || :group || '%' order by customOrder asc"""
|
||||||
|
)
|
||||||
fun getByGroup(group: String): List<BookSource>
|
fun getByGroup(group: String): List<BookSource>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
@@ -191,9 +162,7 @@ interface BookSourceDao {
|
|||||||
fun getEnabledByGroup(group: String): List<BookSource>
|
fun getEnabledByGroup(group: String): List<BookSource>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select * from book_sources_part
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources
|
|
||||||
where enabled = 1
|
where enabled = 1
|
||||||
and (bookSourceGroup = :group
|
and (bookSourceGroup = :group
|
||||||
or bookSourceGroup like :group || ',%'
|
or bookSourceGroup like :group || ',%'
|
||||||
@@ -203,14 +172,24 @@ interface BookSourceDao {
|
|||||||
)
|
)
|
||||||
fun getEnabledPartByGroup(group: String): List<BookSourcePart>
|
fun getEnabledPartByGroup(group: String): List<BookSourcePart>
|
||||||
|
|
||||||
@Query("select * from book_sources where bookUrlPattern != 'NONE' and bookSourceType = :type order by customOrder asc")
|
@Query(
|
||||||
|
"""select * from book_sources
|
||||||
|
where bookUrlPattern != 'NONE' and bookSourceType = :type order by customOrder asc"""
|
||||||
|
)
|
||||||
fun getEnabledByType(type: Int): List<BookSource>
|
fun getEnabledByType(type: Int): List<BookSource>
|
||||||
|
|
||||||
@Query("select * from book_sources where enabled = 1 and bookSourceUrl = :baseUrl")
|
@Query("select * from book_sources where enabled = 1 and bookSourceUrl = :baseUrl")
|
||||||
fun getBookSourceAddBook(baseUrl: String): BookSource?
|
fun getBookSourceAddBook(baseUrl: String): BookSource?
|
||||||
|
|
||||||
@get:Query("select * from book_sources where enabled = 1 and trim(bookUrlPattern) <> '' and trim(bookUrlPattern) <> 'NONE' order by customOrder")
|
@get:Query(
|
||||||
val hasBookUrlPattern: List<BookSource>
|
"""select bp.*
|
||||||
|
from book_sources b join book_sources_part bp on b.bookSourceUrl = bp.bookSourceUrl
|
||||||
|
where b.enabled = 1
|
||||||
|
and trim(b.bookUrlPattern) <> ''
|
||||||
|
and trim(b.bookUrlPattern) <> 'NONE'
|
||||||
|
order by b.customOrder"""
|
||||||
|
)
|
||||||
|
val hasBookUrlPattern: List<BookSourcePart>
|
||||||
|
|
||||||
@get:Query("select * from book_sources where bookSourceGroup is null or bookSourceGroup = ''")
|
@get:Query("select * from book_sources where bookSourceGroup is null or bookSourceGroup = ''")
|
||||||
val noGroup: List<BookSource>
|
val noGroup: List<BookSource>
|
||||||
@@ -218,27 +197,22 @@ interface BookSourceDao {
|
|||||||
@get:Query("select * from book_sources order by customOrder asc")
|
@get:Query("select * from book_sources order by customOrder asc")
|
||||||
val all: List<BookSource>
|
val all: List<BookSource>
|
||||||
|
|
||||||
@get:Query(
|
@get:Query("select * from book_sources_part order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources order by customOrder asc"""
|
|
||||||
)
|
|
||||||
val allPart: List<BookSourcePart>
|
val allPart: List<BookSourcePart>
|
||||||
|
|
||||||
@get:Query("select * from book_sources where enabled = 1 order by customOrder")
|
@get:Query("select * from book_sources where enabled = 1 order by customOrder")
|
||||||
val allEnabled: List<BookSource>
|
val allEnabled: List<BookSource>
|
||||||
|
|
||||||
@get:Query(
|
@get:Query("select * from book_sources_part where enabled = 1 order by customOrder asc")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where enabled = 1 order by customOrder asc"""
|
|
||||||
)
|
|
||||||
val allEnabledPart: List<BookSourcePart>
|
val allEnabledPart: List<BookSourcePart>
|
||||||
|
|
||||||
@get:Query("select * from book_sources where enabled = 0 order by customOrder")
|
@get:Query("select * from book_sources where enabled = 0 order by customOrder")
|
||||||
val allDisabled: List<BookSource>
|
val allDisabled: List<BookSource>
|
||||||
|
|
||||||
@get:Query("select * from book_sources where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'")
|
@get:Query(
|
||||||
|
"""select * from book_sources
|
||||||
|
where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'"""
|
||||||
|
)
|
||||||
val allNoGroup: List<BookSource>
|
val allNoGroup: List<BookSource>
|
||||||
|
|
||||||
@get:Query("select * from book_sources where enabledExplore = 1 order by customOrder")
|
@get:Query("select * from book_sources where enabledExplore = 1 order by customOrder")
|
||||||
@@ -251,26 +225,28 @@ interface BookSourceDao {
|
|||||||
val allLogin: List<BookSource>
|
val allLogin: List<BookSource>
|
||||||
|
|
||||||
@get:Query(
|
@get:Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select bp.*
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
from book_sources b join book_sources_part bp on b.bookSourceUrl = bp.bookSourceUrl
|
||||||
from book_sources where enabled = 1 and bookSourceType = 0 order by customOrder"""
|
where b.enabled = 1 and b.bookSourceType = 0 order by b.customOrder"""
|
||||||
)
|
)
|
||||||
val allTextEnabledPart: List<BookSourcePart>
|
val allTextEnabledPart: List<BookSourcePart>
|
||||||
|
|
||||||
@get:Query("select distinct bookSourceGroup from book_sources where trim(bookSourceGroup) <> ''")
|
@get:Query(
|
||||||
|
"""select distinct bookSourceGroup from book_sources
|
||||||
|
where trim(bookSourceGroup) <> ''"""
|
||||||
|
)
|
||||||
val allGroupsUnProcessed: List<String>
|
val allGroupsUnProcessed: List<String>
|
||||||
|
|
||||||
@get:Query("select distinct bookSourceGroup from book_sources where enabled = 1 and trim(bookSourceGroup) <> ''")
|
@get:Query(
|
||||||
|
"""select distinct bookSourceGroup from book_sources
|
||||||
|
where enabled = 1 and trim(bookSourceGroup) <> ''"""
|
||||||
|
)
|
||||||
val allEnabledGroupsUnProcessed: List<String>
|
val allEnabledGroupsUnProcessed: List<String>
|
||||||
|
|
||||||
@Query("select * from book_sources where bookSourceUrl = :key")
|
@Query("select * from book_sources where bookSourceUrl = :key")
|
||||||
fun getBookSource(key: String): BookSource?
|
fun getBookSource(key: String): BookSource?
|
||||||
|
|
||||||
@Query(
|
@Query("select * from book_sources_part where bookSourceUrl = :key")
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
|
||||||
from book_sources where bookSourceUrl = :key"""
|
|
||||||
)
|
|
||||||
fun getBookSourcePart(key: String): BookSourcePart?
|
fun getBookSourcePart(key: String): BookSourcePart?
|
||||||
|
|
||||||
@Query("select count(*) from book_sources")
|
@Query("select count(*) from book_sources")
|
||||||
@@ -324,7 +300,10 @@ interface BookSourceDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("update book_sources set customOrder = :customOrder where bookSourceUrl = :bookSourceUrl")
|
@Query(
|
||||||
|
"""update book_sources
|
||||||
|
set customOrder = :customOrder where bookSourceUrl = :bookSourceUrl"""
|
||||||
|
)
|
||||||
fun upOrder(bookSourceUrl: String, customOrder: Int)
|
fun upOrder(bookSourceUrl: String, customOrder: Int)
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
@@ -338,7 +317,10 @@ interface BookSourceDao {
|
|||||||
upOrder(bookSource.bookSourceUrl, bookSource.customOrder)
|
upOrder(bookSource.bookSourceUrl, bookSource.customOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query("update book_sources set bookSourceGroup = :bookSourceGroup where bookSourceUrl = :bookSourceUrl")
|
@Query(
|
||||||
|
"""update book_sources
|
||||||
|
set bookSourceGroup = :bookSourceGroup where bookSourceUrl = :bookSourceUrl"""
|
||||||
|
)
|
||||||
fun upGroup(bookSourceUrl: String, bookSourceGroup: String)
|
fun upGroup(bookSourceUrl: String, bookSourceGroup: String)
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
package io.legado.app.data.entities
|
package io.legado.app.data.entities
|
||||||
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import androidx.room.DatabaseView
|
||||||
import io.legado.app.constant.AppPattern
|
import io.legado.app.constant.AppPattern
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.utils.splitNotBlank
|
import io.legado.app.utils.splitNotBlank
|
||||||
|
|
||||||
|
|
||||||
|
@DatabaseView(
|
||||||
|
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
||||||
|
(loginUrl is not null and trim(loginUrl) <> '') hasLoginUrl, lastUpdateTime, respondTime, weight,
|
||||||
|
(exploreUrl is not null and trim(exploreUrl) <> '') hasExploreUrl
|
||||||
|
from book_sources""",
|
||||||
|
viewName = "book_sources_part"
|
||||||
|
)
|
||||||
data class BookSourcePart(
|
data class BookSourcePart(
|
||||||
// 地址,包括 http/https
|
// 地址,包括 http/https
|
||||||
var bookSourceUrl: String = "",
|
var bookSourceUrl: String = "",
|
||||||
|
|||||||
@@ -128,8 +128,9 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe
|
|||||||
}
|
}
|
||||||
appDb.bookSourceDao.hasBookUrlPattern.forEach { source ->
|
appDb.bookSourceDao.hasBookUrlPattern.forEach { source ->
|
||||||
try {
|
try {
|
||||||
if (bookUrl.matches(source.bookUrlPattern!!.toRegex())) {
|
val bs = source.getBookSource()!!
|
||||||
getBookInfo(bookUrl, source)?.let { book ->
|
if (bookUrl.matches(bs.bookUrlPattern!!.toRegex())) {
|
||||||
|
getBookInfo(bookUrl, bs)?.let { book ->
|
||||||
return@execute book
|
return@execute book
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.legado.app.base.BaseViewModel
|
|||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookSource
|
import io.legado.app.data.entities.BookSourcePart
|
||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
import io.legado.app.help.http.newCallResponseBody
|
import io.legado.app.help.http.newCallResponseBody
|
||||||
@@ -35,7 +35,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
|
|||||||
fun addBookByUrl(bookUrls: String) {
|
fun addBookByUrl(bookUrls: String) {
|
||||||
var successCount = 0
|
var successCount = 0
|
||||||
addBookJob = execute {
|
addBookJob = execute {
|
||||||
val hasBookUrlPattern: List<BookSource> by lazy {
|
val hasBookUrlPattern: List<BookSourcePart> by lazy {
|
||||||
appDb.bookSourceDao.hasBookUrlPattern
|
appDb.bookSourceDao.hasBookUrlPattern
|
||||||
}
|
}
|
||||||
val urls = bookUrls.split("\n")
|
val urls = bookUrls.split("\n")
|
||||||
@@ -51,8 +51,9 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
|
|||||||
if (source == null) {
|
if (source == null) {
|
||||||
for (bookSource in hasBookUrlPattern) {
|
for (bookSource in hasBookUrlPattern) {
|
||||||
try {
|
try {
|
||||||
if (bookUrl.matches(bookSource.bookUrlPattern!!.toRegex())) {
|
val bs = bookSource.getBookSource()!!
|
||||||
source = bookSource
|
if (bookUrl.matches(bs.bookUrlPattern!!.toRegex())) {
|
||||||
|
source = bs
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user