package com.fieldlabel.collector.data.local

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.fieldlabel.collector.domain.model.CustomFieldValue

@Entity(tableName = "custom_field_values")
data class CustomFieldValueEntity(
    @PrimaryKey val id: String,
    val fieldDefId: String,
    val locationId: String,
    val specimenId: String?,   // null = 地点全体に紐づく
    val value: String
) {
    fun toDomain() = CustomFieldValue(
        id         = id,
        fieldDefId = fieldDefId,
        locationId = locationId,
        specimenId = specimenId,
        value      = value
    )

    companion object {
        fun fromDomain(v: CustomFieldValue) = CustomFieldValueEntity(
            id         = v.id,
            fieldDefId = v.fieldDefId,
            locationId = v.locationId,
            specimenId = v.specimenId,
            value      = v.value
        )
    }
}
