package com.its.op.entity.its.scrs;

import com.its.op.dto.its.scrs.TbScIxrCmraSttsHsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 카메라 상태 이력 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("카메라 상태 이력")
@Entity
@Table(name = "TB_SC_IXR_CMRA_STTS_HS")
@IdClass(TbScIxrCmraSttsHsKey.class)
public class TbScIxrCmraSttsHs implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("수집 일시")  // N VARCHAR2(14)
    @Id
    @Column(name = "CLCT_DT", nullable = false, length = 14)
    private String clctDt;

    @ApiModelProperty("교차로 ID")  // N VARCHAR2(10)
    @Id
    @Column(name = "IXR_ID", nullable = false, length = 10)
    private String ixrId;

    @ApiModelProperty("카메라 ID")  // N VARCHAR2(10)
    @Id
    @Column(name = "CMRA_ID", nullable = false, length = 10)
    private String cmraId;

    @ApiModelProperty("방향 구분 코드")  // N NUMBER(1)
    @Id
    @Column(name = "DRCT_DVSN_CD", nullable = false, columnDefinition = "NUMBER", length = 1)
    private Integer drctDvsnCd;

    @ApiModelProperty("카메라 상태(0:비정상, 1:정상)")  // Y NUMBER(1)
    @Column(name = "CMRA_STTS", columnDefinition = "NUMBER", length = 1)
    private Integer cmraStts;

    public TbScIxrCmraSttsHsDto toDto() {
        return TbScIxrCmraSttsHsDto.builder()
                .clctDt(this.clctDt)
                .ixrId(this.ixrId)
                .cmraId(this.cmraId)
                .drctDvsnCd(this.drctDvsnCd)
                .cmraStts(this.cmraStts)
                .build();
    }

}
