pull/32/head
parent
452a3b6768
commit
510aa5b2cc
@ -1,71 +0,0 @@ |
|||||||
package io.legado.app.data.dao |
|
||||||
|
|
||||||
import androidx.paging.DataSource |
|
||||||
import androidx.room.* |
|
||||||
import io.legado.app.data.entities.ExploreSearchUrl |
|
||||||
|
|
||||||
|
|
||||||
@Dao |
|
||||||
interface ExploreSearchUrlDao { |
|
||||||
|
|
||||||
companion object { |
|
||||||
private const val ORDER_DEFAULT = "ORDER BY sourceId ASC, defOrder ASC" |
|
||||||
private const val ORDER_USAGE = "ORDER BY usage DESC, lastUseTime DESC" |
|
||||||
private const val ORDER_TIME = "ORDER BY lastUseTime DESC" |
|
||||||
private const val QUERY_NAME = "name LIKE '%' || :name || '%'" |
|
||||||
private const val QUERY_ENABLED_EXPLORE = "WHERE type = 0 AND isEnabled = 1" |
|
||||||
} |
|
||||||
|
|
||||||
// 用于发现列表,默认排序 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE $ORDER_DEFAULT") |
|
||||||
fun observeExploreUrls(): DataSource.Factory<Int, ExploreSearchUrl> |
|
||||||
|
|
||||||
// 用于发现列表,按使用次数排序 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE $ORDER_USAGE") |
|
||||||
fun observeExploreUrlsByUsage(): DataSource.Factory<Int, ExploreSearchUrl> |
|
||||||
|
|
||||||
// 用于发现列表,按使用时间排序 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE $ORDER_TIME") |
|
||||||
fun observeExploreUrlsByTime(): DataSource.Factory<Int, ExploreSearchUrl> |
|
||||||
|
|
||||||
// 用于搜索时的发现列表,默认排序 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE AND $QUERY_NAME $ORDER_DEFAULT") |
|
||||||
fun observeFilteredExploreUrls(name: String): DataSource.Factory<Int, ExploreSearchUrl> |
|
||||||
|
|
||||||
// 用于搜索时的发现列表,按使用次数排序 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE AND $QUERY_NAME $ORDER_USAGE") |
|
||||||
fun observeFilteredExploreUrlsByUsage(): DataSource.Factory<Int, ExploreSearchUrl> |
|
||||||
|
|
||||||
// 用于搜索时的发现列表,按使用时间排序 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE AND $QUERY_NAME $ORDER_TIME") |
|
||||||
fun observeFilteredExploreUrlsByTime(): DataSource.Factory<Int, ExploreSearchUrl> |
|
||||||
|
|
||||||
// 获取特定书源的发现 |
|
||||||
@Query("SELECT * FROM explore_search_urls $QUERY_ENABLED_EXPLORE AND sourceId = :sourceId") |
|
||||||
fun findExploreUrlsBySourceId(sourceId: Int): List<ExploreSearchUrl> |
|
||||||
|
|
||||||
// 获取特定书源的搜索链接 |
|
||||||
@Query("SELECT * FROM explore_search_urls WHERE type = 1 AND sourceId = :sourceId") |
|
||||||
fun findSearchUrlsBySourceId(sourceId: Int): List<ExploreSearchUrl> |
|
||||||
|
|
||||||
// 所有的搜索链接 |
|
||||||
@get:Query("SELECT * FROM explore_search_urls WHERE type = 1") |
|
||||||
val allSearchUrls: List<ExploreSearchUrl> |
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE) |
|
||||||
fun insert(vararg keywords: ExploreSearchUrl) |
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE) |
|
||||||
fun insert(keyword: ExploreSearchUrl): Long |
|
||||||
|
|
||||||
@Update |
|
||||||
fun update(vararg keywords: ExploreSearchUrl) |
|
||||||
|
|
||||||
@Delete |
|
||||||
fun delete(vararg keywords: ExploreSearchUrl) |
|
||||||
|
|
||||||
// 批量删除特定书源的发现和搜索链接,一般用于更新书源时 |
|
||||||
@Query("DELETE FROM explore_search_urls WHERE sourceId = :sourceId") |
|
||||||
fun deleteBySourceId(sourceId: Int) |
|
||||||
|
|
||||||
} |
|
@ -1,33 +0,0 @@ |
|||||||
package io.legado.app.data.entities |
|
||||||
|
|
||||||
import android.os.Parcelable |
|
||||||
import androidx.room.Entity |
|
||||||
import androidx.room.ForeignKey |
|
||||||
import androidx.room.Index |
|
||||||
import androidx.room.PrimaryKey |
|
||||||
import kotlinx.android.parcel.Parcelize |
|
||||||
|
|
||||||
@Parcelize |
|
||||||
@Entity( |
|
||||||
tableName = "explore_search_urls", |
|
||||||
indices = [(Index(value = ["sourceId", "url"], unique = true))], |
|
||||||
foreignKeys = [(ForeignKey( |
|
||||||
entity = BookSource::class, |
|
||||||
parentColumns = ["sourceId"], |
|
||||||
childColumns = ["sourceId"], |
|
||||||
onDelete = ForeignKey.CASCADE |
|
||||||
))] |
|
||||||
) // 删除书源时自动删除章节 |
|
||||||
data class ExploreSearchUrl( |
|
||||||
@PrimaryKey(autoGenerate = true) |
|
||||||
var esId: Int = 0, // 编号 |
|
||||||
var sourceId: Int = 0, // 书源Id |
|
||||||
var name: String = "", // 发现名称,搜索可以没有 |
|
||||||
var url: String = "", // 地址 |
|
||||||
var type: Int = 0, // 类型,0 为发现,1 为搜索 |
|
||||||
var isEnabled: Boolean = true, // 是否启用 |
|
||||||
var defOrder: Int = 0, // 默认排序,是在编辑书源的时候的顺序 |
|
||||||
var usage: Int = 0, // 使用次数,用于按使用次数排序 |
|
||||||
var lastUseTime: Long = 0L // 最后一次使用的时间 |
|
||||||
) : Parcelable |
|
||||||
|
|
@ -1,15 +1,15 @@ |
|||||||
package io.legado.app.data.entities.rule |
package io.legado.app.data.entities.rule |
||||||
|
|
||||||
data class ExploreRule( |
data class ExploreRule( |
||||||
var url: String? = null, |
var exploreUrl: String? = null, |
||||||
var bookList: String? = null, |
var bookList: String? = null, |
||||||
var name: String? = null, |
var name: String? = null, |
||||||
var author: String? = null, |
var author: String? = null, |
||||||
var intro: String? = null, |
var intro: String? = null, |
||||||
var kind: String? = null, |
var kind: String? = null, |
||||||
var lastChapter: String? = null, |
var lastChapter: String? = null, |
||||||
var updateTime: String? = null, |
var updateTime: String? = null, |
||||||
var bookUrl: String? = null, |
var bookUrl: String? = null, |
||||||
var coverUrl: String? = null, |
var coverUrl: String? = null, |
||||||
var wordCount: String? = null |
var wordCount: String? = null |
||||||
) |
) |
@ -1,15 +1,15 @@ |
|||||||
package io.legado.app.data.entities.rule |
package io.legado.app.data.entities.rule |
||||||
|
|
||||||
data class SearchRule( |
data class SearchRule( |
||||||
var url: String? = null, |
var searchUrl: String? = null, |
||||||
var bookList: String? = null, |
var bookList: String? = null, |
||||||
var name: String? = null, |
var name: String? = null, |
||||||
var author: String? = null, |
var author: String? = null, |
||||||
var intro: String? = null, |
var intro: String? = null, |
||||||
var kind: String? = null, |
var kind: String? = null, |
||||||
var lastChapter: String? = null, |
var lastChapter: String? = null, |
||||||
var updateTime: String? = null, |
var updateTime: String? = null, |
||||||
var bookUrl: String? = null, |
var bookUrl: String? = null, |
||||||
var coverUrl: String? = null, |
var coverUrl: String? = null, |
||||||
var wordCount: String? = null |
var wordCount: String? = null |
||||||
) |
) |
Loading…
Reference in new issue