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 = "notes",
    foreignKeys = [ForeignKey(
        entity = PdfDocumentEntity::class,
        parentColumns = ["filePath"],
        childColumns = ["filePath"],
        onDelete = ForeignKey.CASCADE,
        onUpdate = ForeignKey.CASCADE
    )],
    indices = [Index(value = ["filePath"])]
)
data class NoteEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Long = 0,
    
    val filePath: String,           // 关联PdfDocumentEntity的 filePath
    val pageNumber: Int,            // 页码(从0开始)
    val noteType: String,           // 注释类型: HIGHLIGHT, TEXT_NOTE, DRAWING
    val content: String,            // 注释内容(文本或序列化的绘制数据)
    val positionX: Float,           // 页面内X位置
    val positionY: Float,           // 页面内Y位置
    val width: Float = 0f,          // 注释宽度
    val height: Float = 0f,         // 注释高度
    val color: Int,                 // 注释颜色
    val createTime: Long = System.currentTimeMillis(),
    val updateTime: Long = System.currentTimeMillis()
)