package com.its.op.dto.its.cctv;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.cctv.TbCctvPset;
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;

/**
 * CCTV 프리셋 DTO Class
 */
@Data
@Builder
@ApiModel("TbCctvPsetDto(CCTV 프리셋)")
public class TbCctvPsetDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("CCTV 관리 번호")  // N NUMBER(10)
    @JsonProperty("cctv_ctlr_nmbr")
    private Long cctvCtlrNmbr;

    @ApiModelProperty("프리셋 번호")  // N VARCHAR2(3)
    @JsonProperty("pset_nmbr")
    private String psetNmbr;

    @ApiModelProperty("팬 값")  // Y NUMBER(5)
    @JsonProperty("pan_val")
    private Integer panVal;

    @ApiModelProperty("틸트 값")  // Y NUMBER(5)
    @JsonProperty("tilt_val")
    private Integer tiltVal;

    @ApiModelProperty("줌 값")  // Y NUMBER(5)
    @JsonProperty("zoom_val")
    private Integer zoomVal;

    @ApiModelProperty("초점 값")  // Y NUMBER(5)
    @JsonProperty("focs_val")
    private Integer focsVal;

    @ApiModelProperty("프리셋 명")  // Y VARCHAR2(100)
    @JsonProperty("pset_nm")
    private String psetNm;

    @ApiModelProperty("디폴트 여부")  // Y CHAR(1)
    @JsonProperty("dflt_yn")
    private String dfltYn;

    // Code Description Field
    @ApiModelProperty("디폴트 여부 설명")
    @JsonProperty("dflt_desc")    // DFLT_YN
    private String dfltDesc;

    // Code Description Field

    @ApiModel("TbCctvPsetUpdReq(CCTV 프리셋 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbCctvPsetUpdReq {

        @ApiModelProperty("CCTV 관리 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("cctv_ctlr_nmbr")
        @PositiveOrZero
        private Long cctvCtlrNmbr;

        @ApiModelProperty("프리셋 번호, Nullable = N, VARCHAR2(3)")  // N VARCHAR2(3)
        @JsonProperty("pset_nmbr")
        @Size(min=1, max=3)
        private String psetNmbr;

        @ApiModelProperty("팬 값, Nullable = Y, NUMBER(5)")  // Y NUMBER(5)
        @JsonProperty("pan_val")
        @PositiveOrZero
        private Integer panVal;

        @ApiModelProperty("틸트 값, Nullable = Y, NUMBER(5)")  // Y NUMBER(5)
        @JsonProperty("tilt_val")
        @PositiveOrZero
        private Integer tiltVal;

        @ApiModelProperty("줌 값, Nullable = Y, NUMBER(5)")  // Y NUMBER(5)
        @JsonProperty("zoom_val")
        @PositiveOrZero
        private Integer zoomVal;

        @ApiModelProperty("초점 값, Nullable = Y, NUMBER(5)")  // Y NUMBER(5)
        @JsonProperty("focs_val")
        @PositiveOrZero
        private Integer focsVal;

        @ApiModelProperty("프리셋 명, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("pset_nm")
        @Size(min=1, max=100)
        private String psetNm;

        @ApiModelProperty("디폴트 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("dflt_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String dfltYn;

        @Builder
        public TbCctvPsetUpdReq(Long cctv_ctlr_nmbr, String pset_nmbr, Integer pan_val, Integer tilt_val, Integer zoom_val, Integer focs_val, String pset_nm, String dflt_yn) {
            this.cctvCtlrNmbr = cctv_ctlr_nmbr;
            this.psetNmbr = pset_nmbr;
            this.panVal = pan_val;
            this.tiltVal = tilt_val;
            this.zoomVal = zoom_val;
            this.focsVal = focs_val;
            this.psetNm = pset_nm;
            this.dfltYn = dflt_yn;
        }

        public TbCctvPset toEntity() {
            return TbCctvPset.builder()
                    .cctvCtlrNmbr(this.cctvCtlrNmbr)
                    .psetNmbr(this.psetNmbr)
                    .panVal(this.panVal)
                    .tiltVal(this.tiltVal)
                    .zoomVal(this.zoomVal)
                    .focsVal(this.focsVal)
                    .psetNm(this.psetNm)
                    .dfltYn(this.dfltYn)
                    .build();
        }

    }

}
