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