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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.vms.TbVmsType;
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;

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

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

    @ApiModelProperty("VMS 유형 명")  // Y VARCHAR(40)
    @JsonProperty("vms_type_nm")
    private String vmsTypeNm;

    @ApiModelProperty("VMS 너비")  // Y NUMBER(4)
    @JsonProperty("vms_wdth")
    private Integer vmsWdth;

    @ApiModelProperty("VMS 높이")  // Y NUMBER(4)
    @JsonProperty("vms_hght")
    private Integer vmsHght;

    @ApiModelProperty("행 개수")  // Y NUMBER(3)
    @JsonProperty("row_num")
    private Integer rowNum;

    @ApiModelProperty("열 개수")  // Y NUMBER(3)
    @JsonProperty("col_num")
    private Integer colNum;

    @ApiModelProperty("모듈 행 개수")  // Y NUMBER(3)
    @JsonProperty("modl_row_num")
    private Integer modlRowNum;

    @ApiModelProperty("모듈 열 개수")  // Y NUMBER(3)
    @JsonProperty("modl_col_num")
    private Integer modlColNum;

    @ApiModelProperty("전원모듈 행 개수")  // Y NUMBER(3)
    @JsonProperty("powr_row_num")
    private Integer powrRowNum;

    @ApiModelProperty("전원모듈 열 개수")  // Y NUMBER(3)
    @JsonProperty("powr_col_num")
    private Integer powrColNum;

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

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

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

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

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

        @ApiModelProperty("VMS 너비, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("vms_wdth")
        @PositiveOrZero
        private Integer vmsWdth;

        @ApiModelProperty("VMS 높이, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("vms_hght")
        @PositiveOrZero
        private Integer vmsHght;

        @ApiModelProperty("행 개수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("row_num")
        @PositiveOrZero
        private Integer rowNum;

        @ApiModelProperty("열 개수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("col_num")
        @PositiveOrZero
        private Integer colNum;

        @ApiModelProperty("모듈 행 개수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("modl_row_num")
        @PositiveOrZero
        private Integer modlRowNum;

        @ApiModelProperty("모듈 열 개수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("modl_col_num")
        @PositiveOrZero
        private Integer modlColNum;

        @ApiModelProperty("전원모듈 행 개수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("powr_row_num")
        @PositiveOrZero
        private Integer powrRowNum;

        @ApiModelProperty("전원모듈 열 개수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("powr_col_num")
        @PositiveOrZero
        private Integer powrColNum;

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

        @Builder
        public TbVmsTypeUpdReq(String vms_type_cd, String vms_type_nm, Integer vms_wdth, Integer vms_hght, Integer row_num, Integer col_num, Integer modl_row_num, Integer modl_col_num, Integer powr_row_num, Integer powr_col_num, String use_yn) {
            this.vmsTypeCd = vms_type_cd;
            this.vmsTypeNm = vms_type_nm;
            this.vmsWdth = vms_wdth;
            this.vmsHght = vms_hght;
            this.rowNum = row_num;
            this.colNum = col_num;
            this.modlRowNum = modl_row_num;
            this.modlColNum = modl_col_num;
            this.powrRowNum = powr_row_num;
            this.powrColNum = powr_col_num;
            this.useYn = use_yn;
        }

        public TbVmsType toEntity() {
            return TbVmsType.builder()
                    .vmsTypeCd(this.vmsTypeCd)
                    .vmsTypeNm(this.vmsTypeNm)
                    .vmsWdth(this.vmsWdth)
                    .vmsHght(this.vmsHght)
                    .rowNum(this.rowNum)
                    .colNum(this.colNum)
                    .modlRowNum(this.modlRowNum)
                    .modlColNum(this.modlColNum)
                    .powrRowNum(this.powrRowNum)
                    .powrColNum(this.powrColNum)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
