package com.ffii.fpsms.m18.entity

import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.m18.enums.M18DataLogStatus
import com.ffii.fpsms.m18.enums.M18DataLogStatusConverter
import jakarta.persistence.Column
import jakarta.persistence.Convert
import jakarta.persistence.Entity
import jakarta.persistence.Table
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import org.hibernate.annotations.JdbcTypeCode
import org.hibernate.type.SqlTypes
import java.time.LocalDateTime

@Entity
@Table(name = "m18_data_log")
open class M18DataLog : BaseEntity<Long>() {
    @Size(max = 1000)
    @NotNull
    @Column(name = "refType", nullable = false, length = 1000)
    open var refType: String? = null

    @NotNull
    @Column(name = "m18Id", nullable = false)
    open var m18Id: Long? = null

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "dataLog")
    open var dataLog: MutableMap<String, Any?>? = null

    @NotNull
    @Column(name = "status", nullable = false)
    @Convert(converter = M18DataLogStatusConverter::class)
    open var status: M18DataLogStatus? = null

    @NotNull
    @Column(name = "m18LastModifyDate", nullable = false)
    open var m18LastModifyDate: LocalDateTime? = null
}