pull/84/head
kunfei 5 years ago
parent 0ed336ed8d
commit 864b61ccba
  1. 3
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 24
      app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt
  3. 14
      app/src/main/java/io/legado/app/data/entities/TxtTocRule.kt

@ -16,7 +16,7 @@ import kotlinx.coroutines.launch
@Database(
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
RssSource::class, Bookmark::class, RssArticle::class, RssStar::class],
RssSource::class, Bookmark::class, RssArticle::class, RssStar::class, TxtTocRule::class],
version = 6,
exportSchema = true
)
@ -50,4 +50,5 @@ abstract class AppDatabase : RoomDatabase() {
abstract fun rssArticleDao(): RssArticleDao
abstract fun rssStarDao(): RssStarDao
abstract fun cookieDao(): CookieDao
abstract fun txtTocRule(): TxtTocRuleDao
}

@ -0,0 +1,24 @@
package io.legado.app.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.legado.app.data.entities.TxtTocRule
import retrofit2.http.DELETE
@Dao
interface TxtTocRuleDao {
@get:Query("select * from txtTocRules order by serialNumber")
val all: List<TxtTocRule>
@get:Query("select * from txtTocRules where enable = 1 order by serialNumber")
val enabled: List<TxtTocRule>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg rule: TxtTocRule)
@DELETE
fun delete(vararg rule: TxtTocRule)
}

@ -0,0 +1,14 @@
package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "txtTocRules")
data class TxtTocRule(
@PrimaryKey
var name: String = "",
var rule: String = "",
var serialNumber: Int,
var enable: Boolean = true
)
Loading…
Cancel
Save