package com.its.vds.api.dto;

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

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

/**
 * VDS 제어기 제어정보 DTO Class
 */
@Data
@Builder
@ApiModel("VdsControlDto(VDS 제어 정보")
public class VdsControlDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModel("VdsControlResetReq(VDS 제어기 리셋)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlResetReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @Builder
        public VdsControlResetReq(String user_id) {
            this.userId = user_id;
        }
    }

    @ApiModel("VdsControlTimeSyncReq(VDS 제어기 시간동기)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlTimeSyncReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @Builder
        public VdsControlTimeSyncReq(String user_id) {
            this.userId = user_id;
        }
    }

    @ApiModel("VdsControlResetReq(VDS 제어기 리셋)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlPanlOnOfReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @ApiModelProperty("전광판 OnOff(0: 전원꺼짐, 1: 전원켜짐)")
        @JsonProperty("on_off")
        //@NotEmpty
        //private eVdsReqBoardPower onOff;
        @PositiveOrZero
        private int onOff;

        @Builder
        public VdsControlPanlOnOfReq(String user_id, int on_off) {
            this.userId = user_id;
            this.onOff = on_off;
        }
    }

    @ApiModel("VdsControlBrightReq(VDS 제어기 밝기 제어)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlBrightReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @ApiModelProperty("밝기 제어 구분(0: 주간, 1: 야간, 2: 자동, 3: 수동)")
        @JsonProperty("type")
        //@NotEmpty
        //private eVdsReqBrightControl type;
        @PositiveOrZero
        private int type;

        @ApiModelProperty("제어값")
        @JsonProperty("value")
        @NotEmpty
        private int value;

        @Builder
        public VdsControlBrightReq(String user_id, int type, int value) {
            this.userId = user_id;
            this.type = type;
            this.value = value;
        }
    }

    @ApiModel("VdsControlFanReq(VDS 제어기 FAN 제어)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlFanReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @ApiModelProperty("Fan 제어 구분(0: 꺼짐, 1: 켜짐, 2: 자동)")
        @JsonProperty("type")
        //@ApiModelProperty(dataType = "string", allowableValues = "vds_req_fan_off, vds_req_fan_on, vds_req_fan_auto", value = "Fan 제어 구분")
        //private eVdsReqFanControl type;
        @PositiveOrZero
        private int type;

        @ApiModelProperty("제어값")
        @JsonProperty("value")
        @PositiveOrZero
        private int value;

        @Builder
        public VdsControlFanReq(String user_id, int type, int value) {
            this.userId = user_id;
            this.type = type;
            this.value = value;
        }
    }

    @ApiModel("VdsControlHeaterReq(VDS 제어기 HEATER 제어)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlHeaterReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @ApiModelProperty("Heater 제어 구분(0: 꺼짐, 1: 켜짐, 2: 자동)")
        @JsonProperty("type")
        //private eVdsReqHeaterControl type;
        @PositiveOrZero
        private int type;

        @ApiModelProperty("제어값")
        @JsonProperty("value")
        private int value;

        @Builder
        public VdsControlHeaterReq(String user_id, int type, int value) {
            this.userId = user_id;
            this.type = type;
            this.value = value;
        }
    }

    @ApiModel("VdsControlRunTempReq(VDS 제어기 동작온도 설정)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlRunTempReq {

        @ApiModelProperty("로그인 사용자 ID")
        @JsonProperty("user_id")
        @NotEmpty
        @Size(min=1)
        private String userId;

        @ApiModelProperty("FAN 동작온도값")
        @JsonProperty("fan_run_temp")
        private int fanRunTemp;

        @ApiModelProperty("HEATER 동작온도값")
        @JsonProperty("heater_run_temp")
        private int heaterRunTemp;

        @Builder
        public VdsControlRunTempReq(String user_id, int fan_run_temp, int heaterRunTemp) {
            this.userId = user_id;
            this.fanRunTemp = fan_run_temp;
            this.heaterRunTemp = heaterRunTemp;
        }
    }

    @ApiModel("VdsControlParamReq(VDS 제어기 파라미터설정)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlParamReq {

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

        @ApiModelProperty("Fan 동작 기준온도")
        @JsonProperty("fan_run_tmpr")
        private Integer fanRunTmpr;

        @ApiModelProperty("Heater 동작 기준온도")
        @JsonProperty("hetr_run_tmpr")
        private Integer hetrRunTmpr;

        @ApiModelProperty("ON 시각")
        @JsonProperty("panl_on_time")
        private String panlOnTime;

        @ApiModelProperty("OFF 시각")
        @JsonProperty("panl_off_time")
        private String panlOffTime;

        @Builder
        public VdsControlParamReq(String user_id, Integer fan_run_tmpr, Integer hetr_run_tmpr, String panl_on_time, String panl_off_time) {
            this.userId = user_id;
            this.fanRunTmpr = fan_run_tmpr;
            this.hetrRunTmpr = hetr_run_tmpr;
            this.panlOnTime = panl_on_time;
            this.panlOffTime = panl_off_time;
        }

    }

    @ApiModel("VdsControlRes(VDS 제어기 제어 응답)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlRes {

        @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 VdsControlRes(Integer error, String message) {
            this.error = error;
            this.message = message;
        }
    }

    @ApiModel("VdsControlOnOffTimeReq(VDS 제어기 전광판 ON-OFF 시각 설정 정보)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlOnOffTimeReq {

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

        @ApiModelProperty("ON 시각")
        @JsonProperty("on_time")
        private String onTime;

        @ApiModelProperty("OFF 시각")
        @JsonProperty("off_time")
        private String offTime;

        @Builder
        public VdsControlOnOffTimeReq(String user_id, String on_time, String off_time) {
            this.userId = user_id;
            this.onTime = on_time;
            this.offTime = off_time;
        }
    }

    @ApiModel("VdsControlOprModeReq(VDS 제어기 운영모드 설정 정보)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class VdsControlOprModeReq {

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

        @ApiModelProperty("운영모드(A:자동, F:고정, B:기본)")
        @JsonProperty("opr_mode")
        @Size(min=1, max=1)
        @Pattern(regexp = "[AFB]")
        private String oprMode;

        @Builder
        public VdsControlOprModeReq(String user_id, String opr_mode) {
            this.userId = user_id;
            this.oprMode = opr_mode;
        }
    }

}
