package com.framework.mvvm.model.db.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import org.json.JSONObject
import javax.persistence.Column

/**
 * 工作空间表
 */
@Entity(tableName = "space")
@Serializable
data class SpaceEntity(
    @PrimaryKey val id: String,
    @ColumnInfo(name = "space_id") val spaceId: String,              // 空间id
    @ColumnInfo(name = "work_id") val workId: String?,                // 交付工作流程id
    @ColumnInfo(name = "space_type") val spaceType: String?,          // 任务空间类型(base|sub)
    @ColumnInfo(name = "parent_space_id") val parentSpaceId: String?, // 父级空间id(空间类型为sub时)
    @ColumnInfo(name = "arch_state") var archState: Int?,             // 建筑结构核查任务状态(0:待核查;1:核查中;2:核查完毕)
    @ColumnInfo(name = "equip_state") var equipState: Int?,           // 设备勘测任务状态(0:待勘测;1:勘测中;2:勘测完毕)
    @ColumnInfo(name = "project_id") val projectId: String?,          // 项目id
    @ColumnInfo(name = "building_id") val buildingId: String?,        // 建筑id
    @ColumnInfo(name = "floor_id") val floorId: String?,              // 楼层id
    @ColumnInfo(name = "creator") val creator: String?,               // 创建人
    @ColumnInfo(name = "creation_time") val creationTime: String?,    // 创建时间
    @ColumnInfo(name = "modifier") val modifier: String?,             // 修改人
    @ColumnInfo(name = "modified_time") var modifiedTime: String?,    // 修改时间
    @ColumnInfo(name = "valid") val valid: Int?,                      // 合法标识
    @ColumnInfo(name = "upload_flag") val uploadFlag: String?,           // app端上传数据标记
    @ColumnInfo(name = "outline")
    @Contextual
    val outline: JSONObject?,               // 空间边界，模型更新空间变化时，用来做匹配计算
    @ColumnInfo(name = "strOutline") val strOutline: String?,         // 空间边界，模型更新空间变化时，用来做匹配计算
    @ColumnInfo(name = "state") var state: String? = "0"               // 数据状态：0：未处理，1：已处理过 2：已上传
)

/*
// 后期优化
@Entity(tableName = "outline")
data class OutLineEntity(
    @PrimaryKey(autoGenerate = true) val id: Int,
    @ColumnInfo(name = "x") val x: Double,
    @ColumnInfo(name = "y") val y: Double,
    @ColumnInfo(name = "z") val z: Double
)*/
