删除弃用代码

pull/951/head
gedoor 4 years ago
parent 0abd259dfe
commit ea31681fd1
  1. 14
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 32
      app/src/main/java/io/legado/app/data/dao/EpubChapterDao.kt
  3. 23
      app/src/main/java/io/legado/app/data/entities/EpubChapter.kt

@ -22,8 +22,8 @@ val appDb by lazy {
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class, RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class,
RuleSub::class, EpubChapter::class], RuleSub::class],
version = 31, version = 32,
exportSchema = true exportSchema = true
) )
abstract class AppDatabase : RoomDatabase() { abstract class AppDatabase : RoomDatabase() {
@ -45,7 +45,6 @@ abstract class AppDatabase : RoomDatabase() {
abstract val httpTTSDao: HttpTTSDao abstract val httpTTSDao: HttpTTSDao
abstract val cacheDao: CacheDao abstract val cacheDao: CacheDao
abstract val ruleSubDao: RuleSubDao abstract val ruleSubDao: RuleSubDao
abstract val epubChapterDao: EpubChapterDao
companion object { companion object {
@ -59,7 +58,8 @@ abstract class AppDatabase : RoomDatabase() {
migration_14_15, migration_15_17, migration_17_18, migration_18_19, migration_14_15, migration_15_17, migration_17_18, migration_18_19,
migration_19_20, migration_20_21, migration_21_22, migration_22_23, migration_19_20, migration_20_21, migration_21_22, migration_22_23,
migration_23_24, migration_24_25, migration_25_26, migration_26_27, migration_23_24, migration_24_25, migration_25_26, migration_26_27,
migration_27_28, migration_28_29, migration_29_30, migration_30_31 migration_27_28, migration_28_29, migration_29_30, migration_30_31,
migration_31_32
) )
.allowMainThreadQueries() .allowMainThreadQueries()
.addCallback(dbCallback) .addCallback(dbCallback)
@ -290,6 +290,12 @@ abstract class AppDatabase : RoomDatabase() {
database.execSQL("insert into readRecord (deviceId, bookName, readTime) select androidId, bookName, readTime from readRecord1") database.execSQL("insert into readRecord (deviceId, bookName, readTime) select androidId, bookName, readTime from readRecord1")
} }
} }
private val migration_31_32 = object : Migration(31, 32) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("DROP TABLE `epubChapters`")
}
}
} }
} }

@ -1,32 +0,0 @@
package io.legado.app.data.dao
import androidx.room.*
import io.legado.app.data.entities.EpubChapter
@Dao
interface EpubChapterDao {
@get:Query("select * from epubChapters")
val all: List<EpubChapter>
@Query("select count(*) from epubChapters Where bookUrl = :bookUrl")
fun getCnt(bookUrl: String): Int
@Query("select * from epubChapters Where bookUrl = :bookUrl and parentHref = :parentHref ")
fun get(bookUrl: String, parentHref: String): List<EpubChapter>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg chapter: EpubChapter)
@Query("delete from epubChapters")
fun clear()
@Query("delete from epubChapters Where bookUrl = :bookUrl")
fun deleteByName(bookUrl: String)
@Delete
fun delete(vararg chapter: EpubChapter)
@Update
fun update(vararg chapter: EpubChapter)
}

@ -1,23 +0,0 @@
package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
@Entity(
tableName = "epubChapters",
primaryKeys = ["bookUrl", "href"],
indices = [(Index(value = ["bookUrl"], unique = false)),
(Index(value = ["bookUrl", "href"], unique = true))],
foreignKeys = [(ForeignKey(
entity = Book::class,
parentColumns = ["bookUrl"],
childColumns = ["bookUrl"],
onDelete = ForeignKey.CASCADE
))]
)
data class EpubChapter(
var bookUrl: String = "",
var href: String = "",
var parentHref: String? = null,
)
Loading…
Cancel
Save