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

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

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

/**
 * 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 FORM 배경 색상 코드")  // N NUMBER(10)
    @JsonProperty("vms_form_bckg_hue_cd")
    private Long vmsFormBckgHueCd;

    @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_msg_dspl_drct_cd")
    private Integer vmsMsgDsplDrctCd;

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

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

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

    @ApiModelProperty("CCTV 관리 번호")  // Y NUMBER(10)
    @JsonProperty("cctv_mngm_nmbr")
    private Long cctvMngmNmbr;

    // 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 FORM 배경 색상 코드 설명")
    @JsonProperty("vms_form_bckg_hue_desc")    // VMS_FORM_BCKG_HUE_CD
    private Long vmsFormBckgHueDesc;

    @ApiModelProperty("VMS 메시지 표출 방향 코드 설명")
    @JsonProperty("vms_msg_dspl_drct_desc")    // VMS_MSG_DSPL_DRCT_CD
    private Integer vmsMsgDsplDrctDesc;

    @ApiModelProperty("VMS 메시지 표출 방법 코드 설명")
    @JsonProperty("vms_msg_dspl_mthd_desc")    // VMS_MSG_DSPL_MTHD_CD
    private Integer vmsMsgDsplMthdDesc;

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

    @ApiModel("TbVmsFormUpdReq(VMS FORM 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    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 FORM 배경 색상 코드, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("vms_form_bckg_hue_cd")
        @PositiveOrZero
        private Long vmsFormBckgHueCd;

        @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(min=1, max=200)
        private String vmsFormExpl;

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

        @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("VMS 메시지 표출 방법 코드, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("vms_msg_dspl_mthd_cd")
        @PositiveOrZero
        private Integer vmsMsgDsplMthdCd;

        @ApiModelProperty("CCTV 관리 번호, Nullable = Y, NUMBER(10)")  // Y NUMBER(10)
        @JsonProperty("cctv_mngm_nmbr")
        @PositiveOrZero
        private Long cctvMngmNmbr;

        @Builder
        public TbVmsFormUpdReq(Integer vms_form_id, String vms_type_cd, Integer vms_form_type_cd, Long vms_form_bckg_hue_cd, String vms_form_nm, String vms_form_expl, Integer vms_msg_dspl_drct_cd, Integer symb_lib_nmbr, byte[] vms_form_imag, Integer vms_msg_dspl_mthd_cd, Long cctv_mngm_nmbr) {
            this.vmsFormId = vms_form_id;
            this.vmsTypeCd = vms_type_cd;
            this.vmsFormTypeCd = vms_form_type_cd;
            this.vmsFormBckgHueCd = vms_form_bckg_hue_cd;
            this.vmsFormNm = vms_form_nm;
            this.vmsFormExpl = vms_form_expl;
            this.vmsMsgDsplDrctCd = vms_msg_dspl_drct_cd;
            this.symbLibNmbr = symb_lib_nmbr;
            this.vmsFormImag = vms_form_imag;
            this.vmsMsgDsplMthdCd = vms_msg_dspl_mthd_cd;
            this.cctvMngmNmbr = cctv_mngm_nmbr;
        }

        public TbVmsForm toEntity() {
            return TbVmsForm.builder()
                    .vmsFormId(this.vmsFormId)
                    .vmsTypeCd(this.vmsTypeCd)
                    .vmsFormTypeCd(this.vmsFormTypeCd)
                    .vmsFormBckgHueCd(this.vmsFormBckgHueCd)
                    .vmsFormNm(this.vmsFormNm)
                    .vmsFormExpl(this.vmsFormExpl)
                    .vmsMsgDsplDrctCd(this.vmsMsgDsplDrctCd)
                    .symbLibNmbr(this.symbLibNmbr)
                    .vmsFormImag(this.vmsFormImag)
                    .vmsMsgDsplMthdCd(this.vmsMsgDsplMthdCd)
                    .cctvMngmNmbr(this.cctvMngmNmbr)
                    .build();
        }

    }

}
