package com.ffii.fpsms.modules.stock.entity

import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.stock.enums.EscalationLogStatus
import com.ffii.fpsms.modules.stock.enums.EscalationLogStatusConverter
import com.ffii.fpsms.modules.user.entity.User
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.time.LocalDateTime

@Entity
@Table(name = "escalation_log")
open class EscalationLog : BaseEntity<Long>() {
    @NotNull
    @ManyToOne
    @JoinColumn(name = "handlerId", nullable = false, referencedColumnName = "id")
    open var handler: User? = null

    @Size(max = 100)
    @Column(name = "type", nullable = false, length = 100)
    open var type: String? = null

    @ManyToOne
    @JoinColumn(name = "stockInLineId")
    open var stockInLine: StockInLine? = null

    @ManyToOne
    @JoinColumn(name = "stockOutLineId")
    open var stockOutLine: StockOutLine? = null

    @Column(name = "recordDate")
    open var recordDate: LocalDateTime? = null

    @NotNull
    @Convert(converter = EscalationLogStatusConverter::class)
    @Column(name = "status", nullable = false, length = 100)
    open var status: EscalationLogStatus? = null

    @Size(max = 500)
    @NotNull
    @Column(name = "reason", nullable = false, length = 500)
    open var reason: String? = null

    @Column(name = "qcTotalCount")
    open var qcTotalCount: Int? = null

    @Column(name = "qcFailCount")
    open var qcFailCount: Int? = null
}