package com.its.op.entity.its.rse;

import com.its.op.dto.its.rse.TbRseObuClctPnstDto;
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.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * RSE OBU 수집 이력 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("RSE OBU 수집 이력")
@Entity
@Table(name = "TB_RSE_OBU_CLCT_PNST")
public class TbRseObuClctPnst implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("RSE 제어기 번호")  // N NUMBER(10)
    @Id
    @Column(name = "RSE_CTLR_NMBR", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long rseCtlrNmbr;

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

    @ApiModelProperty("OBU 인식 번호")  // N VARCHAR2(200)
    @Column(name = "OBU_IDNT_NMBR", nullable = false, length = 200)
    private String obuIdntNmbr;

    @ApiModelProperty("차종")  // Y VARCHAR2(7)
    @Column(name = "CTYP", length = 7)
    private String ctyp;

    @ApiModelProperty("OBU 종류")  // Y VARCHAR2(7)
    @Column(name = "OBU_KIND", length = 7)
    private String obuKind;

    public TbRseObuClctPnstDto toDto() {
        return TbRseObuClctPnstDto.builder()
                .rseCtlrNmbr(this.rseCtlrNmbr)
                .clctDt(this.clctDt)
                .obuIdntNmbr(this.obuIdntNmbr)
                .ctyp(this.ctyp)
                .obuKind(this.obuKind)
                .build();
    }

    public TbRseObuClctPnst(Long rseCtlrNmbr) {
        this.rseCtlrNmbr = rseCtlrNmbr;
    }

    public void updateInfo(TbRseObuClctPnstDto.TbRseObuClctPnstUpdReq req) {
        this.clctDt = req.getClctDt();
        this.obuIdntNmbr = req.getObuIdntNmbr();
        this.ctyp = req.getCtyp();
        this.obuKind = req.getObuKind();
    }

}
