package com.its.op.entity.its.wcam;

import com.its.op.dto.its.wcam.TbWcamCtlrSttsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 웹 카메라 상태 Entity Class
 */
@Getter
@Setter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("웹 카메라 상태")
@Entity
@Table(name = "TB_WCAM_CTLR_STTS")
public class TbWcamCtlrStts implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("웹카메라 제어기번호")  // N NUMBER(10)
    @Id
    @Column(name = "WCAM_CTLR_NMBR", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long wcamCtlrNmbr;

    @ApiModelProperty("갱신 일시")  // Y VARCHAR2(14)
    @Column(name = "UPDT_DT", length = 14)
    private String updtDt;

    @ApiModelProperty("통신 상태(네트워크) 코드('CMS')")  // Y VARCHAR2(7)
    @Column(name = "CMNC_STTS_CD", length = 7)
    private String cmncSttsCd;

    public TbWcamCtlrSttsDto toDto() {
        return TbWcamCtlrSttsDto.builder()
                .wcamCtlrNmbr(this.wcamCtlrNmbr)
                .updtDt(this.updtDt)
                .cmncSttsCd(this.cmncSttsCd)
                .build();
    }

    public TbWcamCtlrStts(Long wcamCtlrNmbr) {
        this.wcamCtlrNmbr = wcamCtlrNmbr;
    }

    public void updateInfo(TbWcamCtlrSttsDto.TbWcamCtlrSttsUpdReq req) {
        this.updtDt = req.getUpdtDt();
        this.cmncSttsCd = req.getCmncSttsCd();
    }

}
