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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.vms.TbVmsFormColr;
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 FORM 배경색상 DTO Class
 */
@Data
@Builder
@ApiModel("TbVmsFormColrDto(VMS FORM 배경색상)")
public class TbVmsFormColrDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("VMS FORM 배경 색상 명")  // Y VARCHAR2(60)
    @JsonProperty("vms_form_colr_nm")
    private String vmsFormColrNm;

    @ApiModelProperty("VMS FORM 배경 색상 값")  // Y NUMBER(10)
    @JsonProperty("vms_form_colr_val")
    private Long vmsFormColrVal;

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

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

    @ApiModelProperty("사용 여부 설명")
    @JsonProperty("use_desc")    // USE_YN
    private String useDesc;

    @ApiModel("TbVmsFormBckghueUpdReq(VMS FORM 배경색상 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbVmsFormColrUpdReq {

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

        @ApiModelProperty("VMS FORM 배경 색상 명, Nullable = Y, VARCHAR2(60)")  // Y VARCHAR2(60)
        @JsonProperty("vms_form_colr_nm")
        @Size(min=1, max=60)
        private String vmsFormColrNm;

        @ApiModelProperty("VMS FORM 배경 색상 값, Nullable = Y, NUMBER(10)")  // Y NUMBER(10)
        @JsonProperty("vms_form_colr_val")
        @PositiveOrZero
        private Long vmsFormColrVal;

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

        @Builder
        public TbVmsFormColrUpdReq(Integer vms_form_colr_cd, String vms_form_colr_nm, Long vms_form_colr_val, String use_yn) {
            this.vmsFormColrCd = vms_form_colr_cd;
            this.vmsFormColrNm = vms_form_colr_nm;
            this.vmsFormColrVal = vms_form_colr_val;
            this.useYn = use_yn;
        }

        public TbVmsFormColr toEntity() {
            return TbVmsFormColr.builder()
                    .vmsFormColrCd(this.vmsFormColrCd)
                    .vmsFormColrNm(this.vmsFormColrNm)
                    .vmsFormColrVal(this.vmsFormColrVal)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
