package com.its.op.dto.its.wcam;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.wcam.TbWcamCtlrSttsHs;
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("TbWcamCtlrSttsHsDto(웹 카메라 상태 이력)")
public class TbWcamCtlrSttsHsDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("생성 일시")  // N VARCHAR2(14)
    @JsonProperty("crtn_dt")
    private String crtnDt;

    @ApiModelProperty("웹카메라 제어기번호")  // N NUMBER(10)
    @JsonProperty("wcam_ctlr_nmbr")
    private Long wcamCtlrNmbr;

    @ApiModelProperty("통신 상태 코드('CMS')")  // Y VARCHAR2(7)
    @JsonProperty("cmnc_stts_cd")
    private String cmncSttsCd;

    // Code Description Field
    @ApiModelProperty("통신 상태 코드('CMS') 설명")
    @JsonProperty("cmnc_stts_desc")    // CMNC_STTS_CD
    private String cmncSttsDesc;

    @ApiModel("TbWcamCtlrSttsHsUpdReq(웹 카메라 상태 이력 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbWcamCtlrSttsHsUpdReq {

        @ApiModelProperty("생성 일시, Nullable = N, VARCHAR2(14)")  // N VARCHAR2(14)
        @JsonProperty("crtn_dt")
        @Size(min=1, max=14)
        private String crtnDt;

        @ApiModelProperty("웹카메라 제어기번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("wcam_ctlr_nmbr")
        @PositiveOrZero
        private Long wcamCtlrNmbr;

        @ApiModelProperty("통신 상태 코드('CMS'), Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("cmnc_stts_cd")
        @Size(min=1, max=7)
        private String cmncSttsCd;

        @Builder
        public TbWcamCtlrSttsHsUpdReq(String crtn_dt, Long wcam_ctlr_nmbr, String cmnc_stts_cd) {
            this.crtnDt = crtn_dt;
            this.wcamCtlrNmbr = wcam_ctlr_nmbr;
            this.cmncSttsCd = cmnc_stts_cd;
        }

        public TbWcamCtlrSttsHs toEntity() {
            return TbWcamCtlrSttsHs.builder()
                    .crtnDt(this.crtnDt)
                    .wcamCtlrNmbr(this.wcamCtlrNmbr)
                    .cmncSttsCd(this.cmncSttsCd)
                    .build();
        }

    }

}
