|
|
@ -3,6 +3,7 @@ package io.legado.app.data.dao |
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
import androidx.room.* |
|
|
|
import androidx.room.* |
|
|
|
import io.legado.app.data.entities.RssArticle |
|
|
|
import io.legado.app.data.entities.RssArticle |
|
|
|
|
|
|
|
import io.legado.app.data.entities.RssReadRecord |
|
|
|
|
|
|
|
|
|
|
|
@Dao |
|
|
|
@Dao |
|
|
|
interface RssArticleDao { |
|
|
|
interface RssArticleDao { |
|
|
@ -10,7 +11,11 @@ interface RssArticleDao { |
|
|
|
@Query("select * from rssArticles where origin = :origin and link = :link") |
|
|
|
@Query("select * from rssArticles where origin = :origin and link = :link") |
|
|
|
fun get(origin: String, link: String): RssArticle? |
|
|
|
fun get(origin: String, link: String): RssArticle? |
|
|
|
|
|
|
|
|
|
|
|
@Query("select * from rssArticles where origin = :origin order by `order` desc") |
|
|
|
@Query( |
|
|
|
|
|
|
|
"""select t1.link, t1.origin, t1.`order`, t1.title, t1.content, t1.description, t1.image, t1.pubDate, ifNull(t2.read, 0) as read |
|
|
|
|
|
|
|
from rssArticles as t1 left join rssReadRecords as t2 |
|
|
|
|
|
|
|
on t1.link = t2.record where origin = :origin order by `order` desc""" |
|
|
|
|
|
|
|
) |
|
|
|
fun liveByOrigin(origin: String): LiveData<List<RssArticle>> |
|
|
|
fun liveByOrigin(origin: String): LiveData<List<RssArticle>> |
|
|
|
|
|
|
|
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE) |
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE) |
|
|
@ -24,4 +29,7 @@ interface RssArticleDao { |
|
|
|
|
|
|
|
|
|
|
|
@Query("delete from rssArticles where origin = :origin") |
|
|
|
@Query("delete from rssArticles where origin = :origin") |
|
|
|
fun delete(origin: String) |
|
|
|
fun delete(origin: String) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Insert(onConflict = OnConflictStrategy.IGNORE) |
|
|
|
|
|
|
|
fun insertRecord(vararg rssReadRecord: RssReadRecord) |
|
|
|
} |
|
|
|
} |