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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.vms.TbVmsUsagType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * VMS 용도 유형 DTO Class
 */
@Data
@Builder
@ApiModel("TbVmsUsagTypeDto(VMS 용도 유형)")
public class TbVmsUsagTypeDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS 용도 유형 코드")  // N VARCHAR(5)
    @JsonProperty("vms_usag_type_cd")
    private String vmsUsagTypeCd;

    @ApiModelProperty("VMS 용도 유형 명")  // Y VARCHAR(40)
    @JsonProperty("vms_usag_type_nm")
    private String vmsUsagTypeNm;

    @ApiModelProperty("VMS 용도 유형 영문 명")  // Y VARCHAR(40)
    @JsonProperty("vms_usag_type_engl_nm")
    private String vmsUsagTypeEnglNm;

    @ApiModelProperty("사용 여부")  // Y CHAR(1)
    @JsonProperty("use_yn")
    private String useYn;

    // Code Description Field
    @ApiModelProperty("VMS 용도 유형 코드 설명")
    @JsonProperty("vms_usag_type_desc")    // VMS_USAG_TYPE_CD
    private String vmsUsagTypeDesc;


    @ApiModel("TbVmsUsagTypeUpdReq(VMS 용도 유형 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbVmsUsagTypeUpdReq {

        @ApiModelProperty("VMS 용도 유형 코드, Nullable = N, VARCHAR(5)")  // N VARCHAR(5)
        @JsonProperty("vms_usag_type_cd")
        @Size(min=1, max=5)
        private String vmsUsagTypeCd;

        @ApiModelProperty("VMS 용도 유형 명, Nullable = Y, VARCHAR(40)")  // Y VARCHAR(40)
        @JsonProperty("vms_usag_type_nm")
        @Size(min=1, max=40)
        private String vmsUsagTypeNm;

        @ApiModelProperty("VMS 용도 유형 영문 명, Nullable = Y, VARCHAR(40)")  // Y VARCHAR(40)
        @JsonProperty("vms_usag_type_engl_nm")
        @Size(min=1, max=40)
        private String vmsUsagTypeEnglNm;

        @ApiModelProperty("사용 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("use_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String useYn;

        @Builder
        public TbVmsUsagTypeUpdReq(String vms_usag_type_cd, String vms_usag_type_nm, String vms_usag_type_engl_nm, String use_yn) {
            this.vmsUsagTypeCd = vms_usag_type_cd;
            this.vmsUsagTypeNm = vms_usag_type_nm;
            this.vmsUsagTypeEnglNm = vms_usag_type_engl_nm;
            this.useYn = use_yn;
        }

        public TbVmsUsagType toEntity() {
            return TbVmsUsagType.builder()
                    .vmsUsagTypeCd(this.vmsUsagTypeCd)
                    .vmsUsagTypeNm(this.vmsUsagTypeNm)
                    .vmsUsagTypeEnglNm(this.vmsUsagTypeEnglNm)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
