package com.its.op.dto.its.scrs;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.scrs.TbScIxrCmraMngm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

/**
 * 카메라 관리 DTO Class
 */
@Data
@Builder
@ApiModel("TbScIxrCmraMngmDto(카메라 관리)")
public class TbScIxrCmraMngmDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("교차로 ID")  // N VARCHAR2(10)
    @JsonProperty("ixr_id")
    private String ixrId;

    @ApiModelProperty("카메라 ID")  // N VARCHAR2(10)
    @JsonProperty("cmra_id")
    private String cmraId;

    @ApiModelProperty("방향 구분 코드")  // N NUMBER(1)
    @JsonProperty("drct_dvsn_cd")
    private Integer drctDvsnCd;

    @ApiModelProperty("설치 위치")  // Y VARCHAR2(40)
    @JsonProperty("istl_lctn")
    private String istlLctn;

    @ApiModelProperty("카메라 IP")  // Y VARCHAR2(16)
    @JsonProperty("cmra_ip")
    private String cmraIp;

    @ApiModelProperty("카메라 PORT")  // Y VARCHAR2(4)
    @JsonProperty("cmra_port")
    private String cmraPort;

    @ApiModelProperty("사용 유무")  // Y NUMBER(1)
    @JsonProperty("use_en")
    private Integer useEn;

    @ApiModelProperty("카메라 로그인 ID")  // Y VARCHAR2(16)
    @JsonProperty("cmra_logn_id")
    private String cmraLognId;

    @ApiModelProperty("카메라 로그인 비밀번호")  // Y VARCHAR2(16)
    @JsonProperty("cmra_logn_pw")
    private String cmraLognPw;

    @ApiModelProperty("카메라 HTTP PORT")  // Y NUMBER(2)
    @JsonProperty("cmra_http_port")
    private Integer cmraHttpPort;

    @ApiModelProperty("스트림 URL")  // Y VARCHAR2(32)
    @JsonProperty("stre_url")
    private String streUrl;

    @ApiModelProperty("카메라 URL")  // Y VARCHAR2(100)
    @JsonProperty("cmra_url")
    private String cmraUrl;

    @ApiModelProperty("카메라 유형")  // Y NUMBER(1)
    @JsonProperty("cmra_type")
    private Integer cmraType;

    @ApiModelProperty("카메라 X 좌표")  // Y VARCHAR2(20)
    @JsonProperty("cmra_x_crdn")
    private String cmraXCrdn;

    @ApiModelProperty("카메라 Y 좌표")  // Y VARCHAR2(20)
    @JsonProperty("cmra_y_crdn")
    private String cmraYCrdn;

    @ApiModelProperty("카메라 각도")  // Y NUMBER(3)
    @JsonProperty("cmra_angl")
    private Integer cmraAngl;

    @ApiModelProperty("홈페이지 표출 유무")  // Y NUMBER(1)
    @JsonProperty("hmpg_dspl_en")
    private Integer hmpgDsplEn;

    @ApiModelProperty("버스 전용 차로 유무")  // Y NUMBER(1)
    @JsonProperty("bus_dvrs_lane_en")
    private Integer busDvrsLaneEn;

    @ApiModelProperty("서비스 분석 유무")  // Y NUMBER(1)
    @JsonProperty("srvc_anly_en")
    private Integer srvcAnlyEn;

    @ApiModelProperty("차선수")  // Y NUMBER(2)
    @JsonProperty("lane_cnt")
    private Integer laneCnt;

    // Code Description Field
    @ApiModelProperty("방향 구분 코드 설명")
    @JsonProperty("drct_dvsn_desc")    // DRCT_DVSN_CD
    private String drctDvsnDesc;

    @ApiModel("TbScIxrCmraMngmUpdReq(카메라 관리 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbScIxrCmraMngmUpdReq {

        @ApiModelProperty("교차로 ID, Nullable = N, VARCHAR2(10)")  // N VARCHAR2(10)
        @JsonProperty("ixr_id")
        @Size(min=1, max=10)
        private String ixrId;

        @ApiModelProperty("카메라 ID, Nullable = N, VARCHAR2(10)")  // N VARCHAR2(10)
        @JsonProperty("cmra_id")
        @Size(min=1, max=10)
        private String cmraId;

        @ApiModelProperty("방향 구분 코드, Nullable = N, NUMBER(1)")  // N NUMBER(1)
        @JsonProperty("drct_dvsn_cd")
        @PositiveOrZero
        private Integer drctDvsnCd;

        @ApiModelProperty("설치 위치, Nullable = Y, VARCHAR2(40)")  // Y VARCHAR2(40)
        @JsonProperty("istl_lctn")
        @Size(min=1, max=40)
        private String istlLctn;

        @ApiModelProperty("카메라 IP, Nullable = Y, VARCHAR2(16)")  // Y VARCHAR2(16)
        @JsonProperty("cmra_ip")
        @Size(min=1, max=16)
        private String cmraIp;

        @ApiModelProperty("카메라 PORT, Nullable = Y, VARCHAR2(4)")  // Y VARCHAR2(4)
        @JsonProperty("cmra_port")
        @Size(min=1, max=4)
        private String cmraPort;

        @ApiModelProperty("사용 유무, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("use_en")
        @PositiveOrZero
        private Integer useEn;

        @ApiModelProperty("카메라 로그인 ID, Nullable = Y, VARCHAR2(16)")  // Y VARCHAR2(16)
        @JsonProperty("cmra_logn_id")
        @Size(min=1, max=16)
        private String cmraLognId;

        @ApiModelProperty("카메라 로그인 비밀번호, Nullable = Y, VARCHAR2(16)")  // Y VARCHAR2(16)
        @JsonProperty("cmra_logn_pw")
        @Size(min=1, max=16)
        private String cmraLognPw;

        @ApiModelProperty("카메라 HTTP PORT, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("cmra_http_port")
        @PositiveOrZero
        private Integer cmraHttpPort;

        @ApiModelProperty("스트림 URL, Nullable = Y, VARCHAR2(32)")  // Y VARCHAR2(32)
        @JsonProperty("stre_url")
        @Size(min=1, max=32)
        private String streUrl;

        @ApiModelProperty("카메라 URL, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("cmra_url")
        @Size(min=1, max=100)
        private String cmraUrl;

        @ApiModelProperty("카메라 유형, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("cmra_type")
        @PositiveOrZero
        private Integer cmraType;

        @ApiModelProperty("카메라 X 좌표, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("cmra_x_crdn")
        @Size(min=1, max=20)
        private String cmraXCrdn;

        @ApiModelProperty("카메라 Y 좌표, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("cmra_y_crdn")
        @Size(min=1, max=20)
        private String cmraYCrdn;

        @ApiModelProperty("카메라 각도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("cmra_angl")
        @PositiveOrZero
        private Integer cmraAngl;

        @ApiModelProperty("홈페이지 표출 유무, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("hmpg_dspl_en")
        @PositiveOrZero
        private Integer hmpgDsplEn;

        @ApiModelProperty("버스 전용 차로 유무, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("bus_dvrs_lane_en")
        @PositiveOrZero
        private Integer busDvrsLaneEn;

        @ApiModelProperty("서비스 분석 유무, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("srvc_anly_en")
        @PositiveOrZero
        private Integer srvcAnlyEn;

        @ApiModelProperty("차선수, Nullable = Y, NUMBER(2)")  // Y NUMBER(3)
        @JsonProperty("lane_cnt")
        @PositiveOrZero
        private Integer laneCnt;

        @Builder
        public TbScIxrCmraMngmUpdReq(String ixr_id, String cmra_id, Integer drct_dvsn_cd, String istl_lctn, String cmra_ip, String cmra_port, Integer use_en, String cmra_logn_id, String cmra_logn_pw, Integer cmra_http_port, String stre_url, String cmra_url, Integer cmra_type, String cmra_x_crdn, String cmra_y_crdn, Integer cmra_angl, Integer hmpg_dspl_en, Integer bus_dvrs_lane_en, Integer srvc_anly_en, Integer lane_cnt) {
            this.ixrId = ixr_id;
            this.cmraId = cmra_id;
            this.drctDvsnCd = drct_dvsn_cd;
            this.istlLctn = istl_lctn;
            this.cmraIp = cmra_ip;
            this.cmraPort = cmra_port;
            this.useEn = use_en;
            this.cmraLognId = cmra_logn_id;
            this.cmraLognPw = cmra_logn_pw;
            this.cmraHttpPort = cmra_http_port;
            this.streUrl = stre_url;
            this.cmraUrl = cmra_url;
            this.cmraType = cmra_type;
            this.cmraXCrdn = cmra_x_crdn;
            this.cmraYCrdn = cmra_y_crdn;
            this.cmraAngl = cmra_angl;
            this.hmpgDsplEn = hmpg_dspl_en;
            this.busDvrsLaneEn = bus_dvrs_lane_en;
            this.srvcAnlyEn = srvc_anly_en;
            this.laneCnt = lane_cnt;
        }

        public TbScIxrCmraMngm toEntity() {
            return TbScIxrCmraMngm.builder()
                    .ixrId(this.ixrId)
                    .cmraId(this.cmraId)
                    .drctDvsnCd(this.drctDvsnCd)
                    .istlLctn(this.istlLctn)
                    .cmraIp(this.cmraIp)
                    .cmraPort(this.cmraPort)
                    .useEn(this.useEn)
                    .cmraLognId(this.cmraLognId)
                    .cmraLognPw(this.cmraLognPw)
                    .cmraHttpPort(this.cmraHttpPort)
                    .streUrl(this.streUrl)
                    .cmraUrl(this.cmraUrl)
                    .cmraType(this.cmraType)
                    .cmraXCrdn(this.cmraXCrdn)
                    .cmraYCrdn(this.cmraYCrdn)
                    .cmraAngl(this.cmraAngl)
                    .hmpgDsplEn(this.hmpgDsplEn)
                    .busDvrsLaneEn(this.busDvrsLaneEn)
                    .srvcAnlyEn(this.srvcAnlyEn)
                    .laneCnt(this.laneCnt)
                    .build();
        }

    }

}
