diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index eb44e9381..b5ace94ba 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.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 } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt b/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt new file mode 100644 index 000000000..d0ae20207 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/dao/TxtTocRuleDao.kt @@ -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 + + @get:Query("select * from txtTocRules where enable = 1 order by serialNumber") + val enabled: List + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg rule: TxtTocRule) + + @DELETE + fun delete(vararg rule: TxtTocRule) +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/TxtTocRule.kt b/app/src/main/java/io/legado/app/data/entities/TxtTocRule.kt new file mode 100644 index 000000000..c9cd51d4d --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/TxtTocRule.kt @@ -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 +) \ No newline at end of file