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

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.cctv.TbCctvMonitoring;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.PositiveOrZero;
import java.io.Serializable;

/**
 * 웹카메라 모니터링 화면 DTO Class
 */
@Data
@Builder
@ApiModel("TbCctvMonitoringDto(웹카메라 모니터링 화면)")
public class TbCctvMonitoringDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("모니터링유형(1:예비,2,예비,3,영상,4:예비)")  // N NUMBER(3)
    @JsonProperty("monitoring_type")
    private Integer monitoringType;

    @ApiModelProperty("모니터링명칭")  // N VARCHAR(40)
    @JsonProperty("monitoring_nm")
    private String monitoringNm;

    @ApiModelProperty("모니터링순서")  // N NUMBER(3)
    @JsonProperty("monitoring_seq")
    private Integer monitoringSeq;

    @ApiModelProperty("웹카메라 제어기번호")  // N NUMBER(10)
    @JsonProperty("cctv_ctlr_nmbr")
    private Long cctvCtlrNmbr;

    //@ApiModelProperty("화면에 보여지는 방식(0:기본,1:화면맞춤))")  // Y NUMBER(1)
    //@JsonProperty("view_mode")
    @JsonIgnore
    private Integer viewMode;

    // Code Description Field
    @ApiModelProperty("CCTV 제어기 ID")  // Y VARCHAR(30)
    @JsonProperty("cctv_ctlr_id")
    private String cctvCtlrId;

    @ApiModelProperty("설치 위치 명")  // Y VARCHAR(40)
    @JsonProperty("istl_lctn_nm")
    private String istlLctnNm;

    @ApiModelProperty("스트리밍 RTMP 주소")  // Y VARCHAR(200)
    @JsonProperty("strm_rtmp_addr")
    private String strmRtmpAddr;

    @ApiModel("TbCctvMonitoringUpdReq(웹카메라 모니터링 화면 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbCctvMonitoringUpdReq {

        /*@ApiModelProperty("모니터링유형(1:예비,2,예비,3,영상,4:예비), Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("monitoring_type")
        @PositiveOrZero*/
        @JsonIgnore
        private Integer monitoringType;

        /*@ApiModelProperty("모니터링명칭, Nullable = N, VARCHAR(40)")  // N VARCHAR(40)
        @JsonProperty("monitoring_nm")
        @Size(min=1, max=40)*/
        @JsonIgnore
        private String monitoringNm;

        @ApiModelProperty("모니터링순서, Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("monitoring_seq")
        @PositiveOrZero
        private Integer monitoringSeq;

        @ApiModelProperty("웹카메라 제어기번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("cctv_ctlr_nmbr")
        @PositiveOrZero
        private Long cctvCtlrNmbr;

        //@ApiModelProperty("화면에 보여지는 방식(0:기본,1:화면맞춤)), Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        //@JsonProperty("view_mode")
        //@PositiveOrZero
        @JsonIgnore
        private Integer viewMode = 0;

        @Builder
        public TbCctvMonitoringUpdReq(Integer monitoring_type, String monitoring_nm, Integer monitoring_seq, Long cctv_ctlr_nmbr, Integer view_mode) {
            this.monitoringType = monitoring_type;
            this.monitoringNm = monitoring_nm;
            this.monitoringSeq = monitoring_seq;
            this.cctvCtlrNmbr = cctv_ctlr_nmbr;
            this.viewMode = 0;//view_mode;
        }

        public TbCctvMonitoring toEntity(Integer monitoringType, String monitoringNm) {
            return TbCctvMonitoring.builder()
                    .monitoringType(monitoringType)
                    .monitoringNm(monitoringNm)
                    .monitoringSeq(this.monitoringSeq)
                    .cctvCtlrNmbr(this.cctvCtlrNmbr)
                    .viewMode(this.viewMode)
                    .build();
        }

    }

}
