pull/46/head
kunfei 5 years ago
parent 3e7f38e584
commit aa4f7512d0
  1. 5
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 3
      app/src/main/java/io/legado/app/data/dao/CookieDao.kt
  3. 12
      app/src/main/java/io/legado/app/data/dao/SourceCookieDao.kt
  4. 5
      app/src/main/java/io/legado/app/data/entities/Cookie.kt
  5. 12
      app/src/main/java/io/legado/app/data/entities/SourceCookie.kt
  6. 2
      app/src/main/java/io/legado/app/help/http/CookieStore.kt

@ -12,8 +12,8 @@ import io.legado.app.data.entities.*
@Database(
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class, ReplaceRule::class,
SearchBook::class, SearchKeyword::class, SourceCookie::class, RssSource::class, Bookmark::class,
RssArticle::class, Cookie::class],
SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class,
RssArticle::class],
version = 1,
exportSchema = true
)
@ -56,7 +56,6 @@ abstract class AppDatabase : RoomDatabase() {
abstract fun replaceRuleDao(): ReplaceRuleDao
abstract fun searchBookDao(): SearchBookDao
abstract fun searchKeywordDao(): SearchKeywordDao
abstract fun sourceCookieDao(): SourceCookieDao
abstract fun rssSourceDao(): RssSourceDao
abstract fun bookmarkDao(): BookmarkDao
abstract fun rssArticleDao(): RssArticleDao

@ -6,10 +6,9 @@ import io.legado.app.data.entities.Cookie
@Dao
interface CookieDao {
@Query("select * from cookies where url = :url")
@Query("SELECT * FROM cookies Where url = :url")
fun get(url: String): Cookie?
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg cookie: Cookie)

@ -1,12 +0,0 @@
package io.legado.app.data.dao
import androidx.room.Dao
import androidx.room.Query
@Dao
interface SourceCookieDao {
@Query("SELECT cookie FROM cookies Where url = :url")
fun getCookieByUrl(url: String): String?
}

@ -1,11 +1,12 @@
package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(tableName = "cookies")
@Entity(tableName = "cookies", indices = [(Index(value = ["url"], unique = true))])
data class Cookie(
@PrimaryKey
var url: String = "",
var cookie: String? = null
var cookie: String = ""
)

@ -1,12 +0,0 @@
package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(tableName = "cookies", indices = [(Index(value = ["url"], unique = true))])
data class SourceCookie(
@PrimaryKey
var url: String = "",
var cookie: String = ""
)

@ -9,7 +9,7 @@ object CookieStore {
fun setCookie(url: String, cookie: String?) {
try {
val cookieBean = Cookie(url, cookie)
val cookieBean = Cookie(url, cookie ?: "")
App.db.cookieDao().insert(cookieBean)
} catch (ignore: Exception) {
}

Loading…
Cancel
Save