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

import androidx.annotation.NonNull
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.serialization.Serializable

/**
 * 关系(业务)表
 */
@Entity(tableName = "relation")
@Serializable
data class RelationEntity(
    @NonNull
    @PrimaryKey(autoGenerate = false)
    @ColumnInfo(name = "id") val id: String,                        // uuid
    @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 = "group_code") val groupCode: String?,         // 集团代码
    @ColumnInfo(name = "graph_id") val graphId: String?,             // 图id
    @ColumnInfo(name = "graph_code") val graphCode: String?,         // 图编码
    @ColumnInfo(name = "rel_code") val relCode: String?,             // 关系编码
    @ColumnInfo(name = "rel_value") val relValue: String?,           // 关系值
    @ColumnInfo(name = "obj_from") val objFrom: String?,             // 关系源对象
    @ColumnInfo(name = "obj_to") val objTo: String?,                 // 关系目标对象
    @ColumnInfo(name = "create_app") val createApp: String?,         // 创建关系的App
    @ColumnInfo(name = "update_app") val updateApp: String?,         // 更新关系的App
    @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 = "client_id") val clientId: String?,           // 客户端生成id
    @ColumnInfo(name = "client_device") val clientDevice: String?,   // 标识客户端设备
    @ColumnInfo(name = "upload_flag") val uploadFlag: String?,       // app端上传数据标记
    @ColumnInfo(name = "delivery_state") val deliveryState: Int?,    // BDTP交付状态: 1 已交付, 0 待交付
    @ColumnInfo(name = "valid") var valid: Int?,                     // 合法标识: 1 合法, 0 非法
    @ColumnInfo(name = "d2m_state") val d2mState: Int?,              // 逆向数据的数模同步状态(0:未同步;1:已同步)
    @ColumnInfo(name = "state") var state: String? = "0",             // 逆向数据的数模同步状态(0:未同步;1:已同步)

    var objFromLocalId: String?,
    var objToLocalId: String?
)
