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

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

/**
 * CCTV 제어기 프리셋제어 DTO Class
 */
@Data
@Builder
@ApiModel("CctvParamControlDto(CCTV 파라미터설정 정보")
public class CctvParamControlDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModel("CctvParamControlReq(CCTV 파라미터설정 정보)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvParamControlReq {

        @ApiModelProperty("FAN ON 설정 온도")
        @JsonProperty("fan_on_tmpr")
        @PositiveOrZero
        private Integer fanOnTmpr;

        @ApiModelProperty("FAN OFF 설정 온도")
        @JsonProperty("fan_off_tmpr")
        @PositiveOrZero
        private Integer fanOffTmpr;

        @ApiModelProperty("Heater ON 설정 온도")
        @JsonProperty("hetr_on_tmpr")
        @PositiveOrZero
        private Integer hetrOnTmpr;

        @ApiModelProperty("Heater OFF 설정 온도")
        @JsonProperty("hetr_off_tmpr")
        @PositiveOrZero
        private Integer hetrOffTmpr;

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        private String userId;

        @Builder
        public CctvParamControlReq(Integer fan_on_tmpr, Integer fan_off_tmpr, Integer hetr_on_tmpr, Integer hetr_off_tmpr, String user_id) {
            this.fanOnTmpr = fan_on_tmpr;
            this.fanOffTmpr = fan_off_tmpr;
            this.hetrOnTmpr = hetr_on_tmpr;
            this.hetrOffTmpr = hetr_off_tmpr;
            this.userId = user_id;
        }
    }

    @ApiModel("CctvParamControlRes(CCTV 파라미터설정 응답)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvParamControlRes {

        @ApiModelProperty("제어결과(0: 성공, 기타: 오류")
        @JsonProperty("error")
        private Integer error;

        @ApiModelProperty("제어결과메시지")
        @JsonProperty("message")
        private String message;

        public void setResult(Integer error, String message) {
            this.error = error;
            this.message = message;
        }
        @Builder
        public CctvParamControlRes(Integer error, String message) {
            this.error = error;
            this.message = message;
        }
    }

    @ApiModel("CctvParamValueRes(CCTV 파라미터설정 정보)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvParamValueRes {

        @ApiModelProperty("제어결과(0: 성공, 기타: 오류")
        @JsonProperty("error")
        private Integer error;

        @ApiModelProperty("제어결과메시지")
        @JsonProperty("message")
        private String message;

        @ApiModelProperty("FAN ON 설정 온도")
        @JsonProperty("fan_on_tmpr")
        @PositiveOrZero
        private Integer fanOnTmpr;

        @ApiModelProperty("FAN OFF 설정 온도")
        @JsonProperty("fan_off_tmpr")
        @PositiveOrZero
        private Integer fanOffTmpr;

        @ApiModelProperty("Heater ON 설정 온도")
        @JsonProperty("hetr_on_tmpr")
        @PositiveOrZero
        private Integer hetrOnTmpr;

        @ApiModelProperty("Heater OFF 설정 온도")
        @JsonProperty("hetr_off_tmpr")
        @PositiveOrZero
        private Integer hetrOffTmpr;

        public CctvParamValueRes(Integer error, String message) {
            this.error = error;
            this.message = message;
            this.fanOnTmpr = 0;
            this.fanOffTmpr = 0;
            this.hetrOnTmpr = 0;
            this.hetrOffTmpr = 0;
        }

        public void setResult(Integer error, String message) {
            this.error = error;
            this.message = message;
        }

        public void setValue(Integer fanOnTmpr, Integer fanOffTmpr, Integer hetrOnTmpr, Integer hetrOffTmpr) {
            this.fanOnTmpr = fanOnTmpr;
            this.fanOffTmpr = fanOffTmpr;
            this.hetrOnTmpr = hetrOnTmpr;
            this.hetrOffTmpr = hetrOffTmpr;
        }
    }

}
