package com.its.op.dto.its.unit;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.unit.TbUnitSyst;
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("TbUnitSystDto(단위 시스템)")
public class TbUnitSystDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시스템 ID")  // N VARCHAR(30)
    @JsonProperty("syst_id")
    private String systId;

    @ApiModelProperty("시스템 유형")  // Y VARCHAR(7)
    @JsonProperty("syst_type")
    private String systType;

    @ApiModelProperty("시스템 번호")  // Y NUMBER(3)
    @JsonProperty("syst_nmbr")
    private Integer systNmbr;

    @ApiModelProperty("시스템 명")  // Y VARCHAR(100)
    @JsonProperty("syst_nm")
    private String systNm;

    @ApiModelProperty("시스템 IP_1")  // Y VARCHAR(20)
    @JsonProperty("syst_ip_1")
    private String systIp1;

    @ApiModelProperty("시스템 IP_2")  // Y VARCHAR(20)
    @JsonProperty("syst_ip_2")
    private String systIp2;

    @ApiModelProperty("프로그램 포트")  // Y VARCHAR(5)
    @JsonProperty("prgm_port")
    private String prgmPort;

    @ApiModelProperty("호스트 명")  // Y VARCHAR(100)
    @JsonProperty("host_nm")
    private String hostNm;

    @ApiModelProperty("운영체제 명")  // Y VARCHAR(100)
    @JsonProperty("os_nm")
    private String osNm;

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

    @ApiModelProperty("상태 표출 여부")  // Y CHAR(1)
    @JsonProperty("stts_dspl_yn")
    private String sttsDsplYn;

    // Code Description Field
    @ApiModelProperty("시스템 설명")  // N VARCHAR(30)
    @JsonProperty("syst_desc")
    private String systDesc;

    @ApiModel("TbUnitSystUpdReq(단위 시스템 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbUnitSystUpdReq {

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

        @ApiModelProperty("시스템 유형, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("syst_type")
        //@Size(min=1, max=7)
        @Size(max=7)
        private String systType;

        @ApiModelProperty("시스템 번호, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("syst_nmbr")
        //@PositiveOrZero
        private Integer systNmbr;

        @ApiModelProperty("시스템 명, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("syst_nm")
        @Size(min=1, max=100)
        private String systNm;

        @ApiModelProperty("시스템 IP_1, Nullable = Y, VARCHAR(20)")  // Y VARCHAR(20)
        @JsonProperty("syst_ip_1")
        @Size(min=1, max=20)
        private String systIp1;

        @ApiModelProperty("시스템 IP_2, Nullable = Y, VARCHAR(20)")  // Y VARCHAR(20)
        @JsonProperty("syst_ip_2")
        //@Size(min=1, max=20)
        @Size(max=20)
        private String systIp2;

        @ApiModelProperty("프로그램 포트, Nullable = Y, VARCHAR(5)")  // Y VARCHAR(5)
        @JsonProperty("prgm_port")
        @Size(min=1, max=5)
        private String prgmPort;

        @ApiModelProperty("호스트 명, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("host_nm")
        @Size(min=1, max=100)
        private String hostNm;

        @ApiModelProperty("운영체제 명, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("os_nm")
        @Size(min=1, max=100)
        private String osNm;

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

        @ApiModelProperty("상태 표출 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("stts_dspl_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String sttsDsplYn;

        @Builder
        public TbUnitSystUpdReq(String syst_id, String syst_type, Integer syst_nmbr, String syst_nm, String syst_ip_1, String syst_ip_2, String prgm_port, String host_nm, String os_nm, String del_yn, String stts_dspl_yn) {
            this.systId = syst_id;
            this.systType = syst_type;
            this.systNmbr = syst_nmbr;
            this.systNm = syst_nm;
            this.systIp1 = syst_ip_1;
            this.systIp2 = syst_ip_2;
            this.prgmPort = prgm_port;
            this.hostNm = host_nm;
            this.osNm = os_nm;
            this.delYn = del_yn;
            this.sttsDsplYn = stts_dspl_yn;
        }

        public TbUnitSyst toEntity() {
            return TbUnitSyst.builder()
                    .systId(this.systId)
                    .systType(this.systType)
                    .systNmbr(this.systNmbr)
                    .systNm(this.systNm)
                    .systIp1(this.systIp1)
                    .systIp2(this.systIp2)
                    .prgmPort(this.prgmPort)
                    .hostNm(this.hostNm)
                    .osNm(this.osNm)
                    .delYn(this.delYn)
                    .sttsDsplYn(this.sttsDsplYn)
                    .build();
        }

    }

}
