package com.its.op.entity.its.vms;

import com.its.op.dto.its.vms.TbVmsFormColrDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * VMS FORM 배경색상 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS FORM 배경색상")
@Entity
@Table(name = "TB_VMS_FORM_COLR")
public class TbVmsFormColr implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS FORM 배경 색상 코드")  // N NUMBER(3)
    @Id
    @Column(name = "VMS_FORM_COLR_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsFormColrCd;

    @ApiModelProperty("VMS FORM 배경 색상 명")  // Y VARCHAR2(60)
    @Column(name = "VMS_FORM_COLR_NM", length = 60)
    private String vmsFormColrNm;

    @ApiModelProperty("VMS FORM 배경 색상 값")  // Y NUMBER(10)
    @Column(name = "VMS_FORM_COLR_VAL", columnDefinition = "NUMBER", length = 10)
    private Long vmsFormColrVal;

    @ApiModelProperty("사용 여부")  // Y CHAR(1)
    @Column(name = "USE_YN", columnDefinition = "CHAR", length = 1)
    private String useYn;

    public TbVmsFormColrDto toDto() {
        return TbVmsFormColrDto.builder()
                .vmsFormColrCd(this.vmsFormColrCd)
                .vmsFormColrNm(this.vmsFormColrNm)
                .vmsFormColrVal(this.vmsFormColrVal)
                .useYn(this.useYn)
                .build();
    }

    public TbVmsFormColr(Long vmsFormBckgHueCd) {
        this.vmsFormColrCd = vmsFormColrCd;
    }

    public void updateInfo(TbVmsFormColrDto.TbVmsFormColrUpdReq req) {
        this.vmsFormColrNm = req.getVmsFormColrNm();
        this.vmsFormColrVal = req.getVmsFormColrVal();
        this.useYn = req.getUseYn();
    }

}
