diff --git a/app/src/main/java/io/legado/app/data/entities/Chapter.kt b/app/src/main/java/io/legado/app/data/entities/Chapter.kt index f69bb4ac0..fa359a582 100644 --- a/app/src/main/java/io/legado/app/data/entities/Chapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/Chapter.kt @@ -10,14 +10,19 @@ import kotlinx.android.parcel.Parcelize @Parcelize @Entity(tableName = "chapters", - indices = [(Index(value = ["feedId", "feedLink"], unique = true))]) + indices = [(Index(value = ["url"], unique = true)), (Index(value = ["bookUrl", "index"], unique = true))], + foreignKeys = [(ForeignKey(entity = Book::class, + parentColumns = ["descUrl"], + childColumns = ["bookUrl"], + onDelete = ForeignKey.CASCADE))]) // 删除书籍时自动删除章节 data class Chapter(@PrimaryKey - var name: String = "", - var bookUrl: String = "", - var index: Int = 0, - var resourceUrl: String? = null, - var tag: String? = null, - var start: Long? = null, - var end: Long? = null + var url: String = "", // 章节地址 + var name: String = "", // 章节标题 + var bookUrl: String = "", // 书籍地址 + var index: Int = 0, // 章节序号 + var resourceUrl: String? = null, // 音频真实URL + var tag: String? = null, // + var start: Long? = null, // 章节起始地址 + var end: Long? = null // 章节终止地址 ) : Parcelable