package com.its.op.dto.its.vms;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.vms.TbVmsForm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;

/**
 * VMS FORM DTO Class
 */
@Data
@Builder
@ApiModel("TbVmsFormDto(VMS FORM)")
public class TbVmsFormDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS FORM ID")  // N NUMBER(5)
    @JsonProperty("vms_form_id")
    private Integer vmsFormId;

    @ApiModelProperty("VMS 유형 코드")  // Y VARCHAR(7)
    @JsonProperty("vms_type_cd")
    private String vmsTypeCd;

    @ApiModelProperty("VMS FORM 유형 코드")  // N NUMBER(3)
    @JsonProperty("vms_form_type_cd")
    private Integer vmsFormTypeCd;

    @ApiModelProperty("VMS 폼 배경 색상 코드")  // N NUMBER(3)
    @JsonProperty("vms_form_colr_cd")
    private Integer vmsFormColrCd;

    @ApiModelProperty("VMS FORM 명")  // Y VARCHAR(60)
    @JsonProperty("vms_form_nm")
    private String vmsFormNm;

    @ApiModelProperty("VMS FORM 설명")  // Y VARCHAR(200)
    @JsonProperty("vms_form_expl")
    private String vmsFormExpl;

    @ApiModelProperty("VMS 메시지 표출 방향 코드")  // Y NUMBER(3)
    @JsonProperty("vms_form_dspl_drct_cd")
    private Integer vmsFormDsplDrctCd;

    @ApiModelProperty("VMS 메시지 표출 방법 코드")  // Y NUMBER(3)
    @JsonProperty("vms_form_dspl_mthd_cd")
    private Integer vmsFormDsplMthdCd;

    @ApiModelProperty("심벌라이브러리 번호")  // Y NUMBER(4)
    @JsonProperty("symb_lib_nmbr")
    private Integer symbLibNmbr;

    @ApiModelProperty("VMS FORM 이미지")  // Y BLOB
    @JsonProperty("vms_form_imag")
    private byte[] vmsFormImag;

    @ApiModelProperty("갱신 일시")  // Y VARCHAR2(14)
    @JsonProperty("updt_dt")
    private String updtDt;

    @ApiModelProperty("폼유효여부")  // Y CHAR(1)
    @JsonProperty("valid_yn")
    private String validYn;

    // Code Description Field
    @ApiModelProperty("VMS 유형 코드 설명")
    @JsonProperty("vms_type_desc")    // VMS_TYPE_CD
    private String vmsTypeDesc;

    @ApiModelProperty("VMS FORM 유형 코드 설명")
    @JsonProperty("vms_form_type_desc")    // VMS_FORM_TYPE_CD
    private Integer vmsFormTypeDesc;

    @ApiModelProperty("VMS 폼 배경 색상 코드 설명")
    @JsonProperty("vms_form_colr_desc")    // VMS_FORM_COLR_CD
    private Integer vmsFormColrDesc;

    @ApiModelProperty("VMS 메시지 표출 방향 코드 설명")
    @JsonProperty("vms_form_dspl_drct_desc")    // VMS_FORM_DSPL_DRCT_CD
    private Integer vmsFormDsplDrctDesc;

    @ApiModelProperty("VMS 메시지 표출 방법 코드 설명")
    @JsonProperty("vms_form_dspl_mthd_desc")    // VMS_FORM_DSPL_MTHD_CD
    private Integer vmsFormDsplMthdDesc;

    @ApiModelProperty("폼유효여부 설명")
    @JsonProperty("valid_desc")    // VALID_YN
    private String validDesc;

    @ApiModelProperty("이미지 형식(bmp, png)")
    @JsonProperty("imag_fmt")
    private String imagFmt;

    @ApiModelProperty("VMS 표출 문자")
    @JsonProperty("vms_dspl_txt")
    private String vmsDsplTxt;

    @ApiModel("TbVmsFormUpdReq(VMS FORM 정보변경)")
    @Getter
    @Setter
    @ToString
    @Builder
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    @AllArgsConstructor
    public static class TbVmsFormUpdReq {

        @ApiModelProperty("VMS FORM ID, Nullable = N, NUMBER(5)")  // N NUMBER(5)
        @JsonProperty("vms_form_id")
        @PositiveOrZero
        private Integer vmsFormId;

        @ApiModelProperty("VMS 유형 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("vms_type_cd")
        @Size(min=1, max=7)
        private String vmsTypeCd;

        @ApiModelProperty("VMS FORM 유형 코드, Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("vms_form_type_cd")
        @PositiveOrZero
        private Integer vmsFormTypeCd;

        @ApiModelProperty("VMS 폼 배경 색상 코드, Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("vms_form_colr_cd")
        @PositiveOrZero
        private Integer vmsFormColrCd;

        @ApiModelProperty("VMS FORM 명, Nullable = Y, VARCHAR(60)")  // Y VARCHAR(60)
        @JsonProperty("vms_form_nm")
        @Size(min=1, max=60)
        private String vmsFormNm;

        @ApiModelProperty("VMS FORM 설명, Nullable = Y, VARCHAR(200)")  // Y VARCHAR(200)
        @JsonProperty("vms_form_expl")
        @Size(max=200)
        @Size(max=200)
        private String vmsFormExpl;

        @ApiModelProperty("VMS 메시지 표출 방향 코드, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("vms_form_dspl_drct_cd")
        @PositiveOrZero
        private Integer vmsFormDsplDrctCd;

        @ApiModelProperty("VMS 메시지 표출 방법 코드, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("vms_form_dspl_mthd_cd")
        @PositiveOrZero
        private Integer vmsFormDsplMthdCd;

        @ApiModelProperty("심벌라이브러리 번호, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("symb_lib_nmbr")
//        @PositiveOrZero
        private Integer symbLibNmbr;

        @ApiModelProperty("VMS FORM 이미지, Nullable = Y, Image Data")  // Y BLOB
        @JsonProperty("vms_form_imag")
        private byte[] vmsFormImag;

        @ApiModelProperty("갱신 일시, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("updt_dt")
        @Size(min=1, max=14)
        private String updtDt;

        @ApiModelProperty("폼유효여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("valid_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String validYn;

        @ApiModelProperty("FORM 객체 목록")
        @JsonProperty("objects")
        private List<TbVmsFormObjectDto.TbVmsFormObjectUpdReq> objects;

        public TbVmsForm toEntity() {
            return TbVmsForm.builder()
                    .vmsFormId(this.vmsFormId)
                    .vmsTypeCd(this.vmsTypeCd)
                    .vmsFormTypeCd(this.vmsFormTypeCd)
                    .vmsFormColrCd(this.vmsFormColrCd)
                    .vmsFormNm(this.vmsFormNm)
                    .vmsFormExpl(this.vmsFormExpl)
                    .vmsFormDsplDrctCd(this.vmsFormDsplDrctCd)
                    .vmsFormDsplMthdCd(this.vmsFormDsplMthdCd)
                    .symbLibNmbr(this.symbLibNmbr)
                    .vmsFormImag(this.vmsFormImag)
                    .updtDt(this.updtDt)
                    .validYn(this.validYn)
                    .build();
        }

    }

    @ApiModel("TbVmsFormCopyReq(VMS FORM 복사 추가)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbVmsFormCopyReq {

        @ApiModelProperty("VMS FORM ID, Nullable = N, NUMBER(5)")  // N NUMBER(5)
        @JsonProperty("vms_form_id")
        @PositiveOrZero
        private Integer vmsFormId;

        @ApiModelProperty("VMS FORM 명, Nullable = Y, VARCHAR(60)")  // Y VARCHAR(60)
        @JsonProperty("vms_form_nm")
        @Size(min=1, max=60)
        private String vmsFormNm;

        @Builder
        public TbVmsFormCopyReq(Integer vms_form_id, String vms_form_nm) {
            this.vmsFormId = vms_form_id;
            this.vmsFormNm = vms_form_nm;
        }

    }

}
