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

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

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

/**
 * 운영시스템 DTO Class
 */
@Data
@Builder
@ApiModel("TbOpersystDto(운영시스템)")
public class TbOperSystDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("운영시스템ID")  // N VARCHAR(30)
    @JsonProperty("oper_syst_id")
    private String operSystId;

    @ApiModelProperty("운영시스템명칭")  // Y VARCHAR(20)
    @JsonProperty("oper_syst_name")
    private String operSystName;

    @ApiModelProperty("생성 일시")  // Y VARCHAR(14)
    @JsonProperty("crtn_dt")
    private String crtnDt;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @JsonProperty("del_yn")
    private String delYn;

    // Code Description Field
    @ApiModelProperty("운영시스템 설명")
    @JsonProperty("oper_syst_desc")
    private String operSystDesc;

    @ApiModel("TbOpersystUpdReq(운영시스템 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbOperSystUpdReq {

        @ApiModelProperty("운영시스템ID, Nullable = N, VARCHAR(30)")  // N VARCHAR(30)
        @JsonProperty("oper_syst_id")
        @Size(min=1, max=30)
        private String operSystId;

        @ApiModelProperty("운영시스템명칭, Nullable = Y, VARCHAR(20)")  // Y VARCHAR(20)
        @JsonProperty("oper_syst_name")
        @Size(min=1, max=20)
        private String operSystName;

        @ApiModelProperty("생성 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("crtn_dt")
        @Size(min=1, max=14)
        private String crtnDt;

        @ApiModelProperty("삭제 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("del_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String delYn;

        @ApiModelProperty("운영시스템 설명")
        @JsonProperty("oper_syst_desc")
        private String operSystDesc;

        @Builder
        public TbOperSystUpdReq(String oper_syst_id, String oper_syst_name, String crtn_dt, String del_yn) {
            this.operSystId = oper_syst_id;
            this.operSystName = oper_syst_name;
            this.crtnDt = crtn_dt;
            this.delYn = del_yn;
        }

        public TbOperSyst toEntity() {
            return TbOperSyst.builder()
                    .operSystId(this.operSystId)
                    .operSystName(this.operSystName)
                    .crtnDt(this.crtnDt)
                    .delYn(this.delYn)
                    .build();
        }

    }

}
