package com.all.pdfreader.pro.app.room.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey

@Entity(
    tableName = "recently_read",
    foreignKeys = [ForeignKey(
        entity = PdfDocumentEntity::class,
        parentColumns = ["filePath"],
        childColumns = ["filePath"],
        onDelete = ForeignKey.CASCADE,
        onUpdate = ForeignKey.CASCADE
    )],
    indices = [Index(value = ["filePath"])]
)
data class RecentReadEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Long = 0,
    
    val filePath: String,            // 关联PdfDocumentEntity的filePath
    val lastOpenedTime: Long,       // 最后打开时间
    val openedCount: Int = 1,       // 打开次数
    val totalReadTime: Long = 0,    // 总阅读时长(毫秒)
    val exitPage: Int = 0           // 退出时的页码
)