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

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

/**
 * 수집 시스템 설정 DTO Class
 */
@Data
@Builder
@ApiModel("TbClctSystStupDto(수집 시스템 설정)")
public class TbClctSystStupDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("수집 시스템 코드")  // N VARCHAR(7)
    @JsonProperty("clct_syst_cd")
    private String clctSystCd;

    @ApiModelProperty("수집 시스템 번호")  // Y NUMBER(2)
    @JsonProperty("clct_syst_nmbr")
    private Short clctSystNmbr;

    @ApiModelProperty("수집 시스템 명")  // N VARCHAR(30)
    @JsonProperty("clct_syst_nm")
    private String clctSystNm;

    @ApiModelProperty("수집 시스템 설명")  // Y VARCHAR(100)
    @JsonProperty("clct_syst_expl")
    private String clctSystExpl;

    @ApiModelProperty("수집 최대 개수")  // Y NUMBER(7)
    @JsonProperty("clct_max_num")
    private Short clctMaxNum;

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

    // Code Description Field
    @ApiModelProperty("수집 시스템 코드 설명")
    @JsonProperty("clct_syst_desc")    // CLCT_SYST_CD
    private String clctSystDesc;

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

    @ApiModel("TbClctSystStupUpdReq(수집 시스템 설정 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbClctSystStupUpdReq {

        @ApiModelProperty("수집 시스템 코드, Nullable = N, VARCHAR(7)")  // N VARCHAR(7)
        @JsonProperty("clct_syst_cd")
        @Size(min=1, max=7)
        private String clctSystCd;

        @ApiModelProperty("수집 시스템 번호, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("clct_syst_nmbr")
        @PositiveOrZero
        private Short clctSystNmbr;

        @ApiModelProperty("수집 시스템 명, Nullable = N, VARCHAR(30)")  // N VARCHAR(30)
        @JsonProperty("clct_syst_nm")
        @Size(min=1, max=30)
        private String clctSystNm;

        @ApiModelProperty("수집 시스템 설명, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("clct_syst_expl")
        @Size(min=1, max=100)
        private String clctSystExpl;

        @ApiModelProperty("수집 최대 개수, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("clct_max_num")
        @PositiveOrZero
        private Short clctMaxNum;

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

        @Builder
        public TbClctSystStupUpdReq(String clct_syst_cd, Short clct_syst_nmbr, String clct_syst_nm, String clct_syst_expl, Short clct_max_num, String use_yn) {
            this.clctSystCd = clct_syst_cd;
            this.clctSystNmbr = clct_syst_nmbr;
            this.clctSystNm = clct_syst_nm;
            this.clctSystExpl = clct_syst_expl;
            this.clctMaxNum = clct_max_num;
            this.useYn = use_yn;
        }

        public TbClctSystStup toEntity() {
            return TbClctSystStup.builder()
                    .clctSystCd(this.clctSystCd)
                    .clctSystNmbr(this.clctSystNmbr)
                    .clctSystNm(this.clctSystNm)
                    .clctSystExpl(this.clctSystExpl)
                    .clctMaxNum(this.clctMaxNum)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
