package com.its.api.its.model.entity.vms;

import com.its.api.its.model.dto.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 VARCHAR(60)
    @Column(name = "VMS_FORM_OBJECT_TYPE_NM", length = 60)
    private String vmsFormObjectTypeNm;

    @ApiModelProperty("편집 코드")  // Y VARCHAR(7)
    @Column(name = "EDTN_CD", length = 7)
    private String edtnCd;

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

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

}
