|
|
@ -4,18 +4,21 @@ import android.os.Parcelable |
|
|
|
import androidx.room.Entity |
|
|
|
import androidx.room.Entity |
|
|
|
import androidx.room.ForeignKey |
|
|
|
import androidx.room.ForeignKey |
|
|
|
import androidx.room.Index |
|
|
|
import androidx.room.Index |
|
|
|
import androidx.room.PrimaryKey |
|
|
|
|
|
|
|
import kotlinx.android.parcel.Parcelize |
|
|
|
import kotlinx.android.parcel.Parcelize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Parcelize |
|
|
|
@Parcelize |
|
|
|
@Entity(tableName = "chapters", |
|
|
|
@Entity( |
|
|
|
|
|
|
|
tableName = "chapters", |
|
|
|
primaryKeys = ["url", "bookUrl"], |
|
|
|
primaryKeys = ["url", "bookUrl"], |
|
|
|
indices = [(Index(value = ["url"], unique = true)), (Index(value = ["bookUrl", "index"], unique = true))], |
|
|
|
indices = [(Index(value = ["url"], unique = true)), (Index(value = ["bookUrl", "index"], unique = true))], |
|
|
|
foreignKeys = [(ForeignKey(entity = Book::class, |
|
|
|
foreignKeys = [(ForeignKey( |
|
|
|
|
|
|
|
entity = Book::class, |
|
|
|
parentColumns = ["descUrl"], |
|
|
|
parentColumns = ["descUrl"], |
|
|
|
childColumns = ["bookUrl"], |
|
|
|
childColumns = ["bookUrl"], |
|
|
|
onDelete = ForeignKey.CASCADE))]) // 删除书籍时自动删除章节 |
|
|
|
onDelete = ForeignKey.CASCADE |
|
|
|
|
|
|
|
))] |
|
|
|
|
|
|
|
) // 删除书籍时自动删除章节 |
|
|
|
data class Chapter( |
|
|
|
data class Chapter( |
|
|
|
var url: String = "", // 章节地址 |
|
|
|
var url: String = "", // 章节地址 |
|
|
|
var title: String = "", // 章节标题 |
|
|
|
var title: String = "", // 章节标题 |
|
|
|