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.PositiveOrZero;
import java.io.Serializable;

/**
 * CCTV 제어기 제어정보 DTO Class
 */
@Data
@Builder
@ApiModel("CctvControlDto(CCTV 제어 정보")
public class CctvPtzControlDto 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("CctvControlRes(CCTV Control 응답)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class CctvPtzControlRes {

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