package com.its.vms.api.dto;

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

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

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

    @ApiModel("CctvControlPtzReq(CCTV PTZ 제어 정보)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvControlPtzReq {

        @ApiModelProperty("제어 명령(tilt-up, tilt-down, pan-left, pan-right, zoom-in, zoom-out, focus-in, focus-out, up-left, up-right, down-left, down-right)")
        @JsonProperty("command")
        private String command;

        @ApiModelProperty("제어 명령 제어(start, stop)")
        @JsonProperty("action")
        private String action;

        @ApiModelProperty("제어속도(0~63)")
        @JsonProperty("speed")
        @PositiveOrZero
        private Integer speed;

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

        @Builder
        public CctvControlPtzReq(String command, String action, Integer speed, String user_id) {
            this.command = command;
            this.action = action;
            this.speed = speed;
            this.userId = user_id;
        }
    }
    @ApiModel("CctvControlPresetReq(CCTV Preset 제어 정보)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvControlPresetReq {

        @ApiModelProperty("제어 명령(preset-default)")
        @JsonProperty("command")
        private String command;

        @ApiModelProperty("제어 명령 제어(call, save, delete)")
        @JsonProperty("action")
        private String action;

        @ApiModelProperty("프리셋 번호(1~255)")
        @JsonProperty("no")
        @Positive
        private Integer no;

        @ApiModelProperty("속도(0~63), save only")
        @JsonProperty("speed")
        @PositiveOrZero
        private Integer speed;

        @ApiModelProperty("프리셋 타임(0~60 sec), save only")
        @JsonProperty("time")
        @PositiveOrZero
        private Integer time;

        @ApiModelProperty("프리셋 명(영문명만, 20 byte) save only, not use.")
        @JsonProperty("name")
        private String name;

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

        @Builder
        public CctvControlPresetReq(String command, String action, Integer no, Integer speed, Integer time, String userId) {
            this.command = command;
            this.action = action;
            this.no = no;
            this.speed = speed;
            this.time = time;
            this.userId = userId;
        }
    }

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

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

        @ApiModelProperty("RESET 유형(0: SW, 1: HW")
        @JsonProperty("reset_type")
        private Integer resetType;

        @Builder
        public CctvControlResetReq(String user_id, Integer reset_type) {
            this.userId = user_id;
            this.resetType = reset_type;
        }
    }

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

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

    @ApiModel("CctvControlRes(CCTV Control 응답)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvControlRes {

        @ApiModelProperty("제어 명령(tilt-up, tilt-down, pan-left, pan-right, zoom-in, zoom-out, focus-in, focus-out, up-left, up-right, down-left, down-right), 프리셋제어(call, save, delete)")
        @JsonProperty("command")
        private String command;

        @ApiModelProperty("제어 명령 제어(start, stop), 프리셋제어(call, save, delete)")
        @JsonProperty("action")
        private String action;

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