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

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

import javax.persistence.*;
import java.io.Serializable;

/**
 * VMS OBJECT 유형 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS OBJECT 유형")
@Entity
@Table(name = "TB_VMS_FORM_OBJECT_TYPE")
@IdClass(TbVmsFormObjectTypeKey.class)
public class TbVmsFormObjectType implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS FORM 유형")  // N NUMBER(3)
    @Id
    @Column(name = "VMS_FORM_TYPE_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsFormTypeCd;

    @ApiModelProperty("VMS FORM OBJECT 유형 코드")  // N NUMBER(3)
    @Id
    @Column(name = "VMS_FORM_OBJECT_TYPE_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsFormObjectTypeCd;

    @ApiModelProperty("VMS FORM OBJECT 유형 명")  // Y VARCHAR2(60)
    @Column(name = "VMS_FORM_OBJECT_TYPE_NM", length = 60)
    private String vmsFormObjectTypeNm;

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

    public TbVmsFormObjectTypeDto toDto() {
        TbVmsFormObjectTypeDto dto = TbVmsFormObjectTypeDto.builder()
                .vmsFormTypeCd(this.vmsFormTypeCd)
                .vmsFormObjectTypeCd(this.vmsFormObjectTypeCd)
                .vmsFormObjectTypeNm(this.vmsFormObjectTypeNm)
                .useYn(this.useYn)
                .build();

        dto.setVmsFormObjectTypeDesc("[" + dto.getVmsFormObjectTypeCd() + "] " + dto.getVmsFormObjectTypeNm());
        return dto;
    }

}
