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

import com.its.op.dto.its.rse.TbRseCtrlHsDto;
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 제어 이력 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("RSE 제어 이력")
@Entity
@Table(name = "TB_RSE_CTRL_HS")
public class TbRseCtrlHs implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("RSE 제어 일련번호")  // N NUMBER(10)
    @Id
    @Column(name = "CTRL_SEQ", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long ctrlSeq;

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

    @ApiModelProperty("제어 일시")  // N VARCHAR2(14)
    @Column(name = "CNTL_DT", nullable = false, length = 14)
    private String cntlDt;

    @ApiModelProperty("장치 유형")  // N VARCHAR2(7)
    @Column(name = "DEVC_TYPE", nullable = false, length = 7)
    private String devcType;

    @ApiModelProperty("제어 유형")  // Y VARCHAR2(7)
    @Column(name = "CNTL_TYPE", length = 7)
    private String cntlType;

    @ApiModelProperty("응답 유형")  // Y VARCHAR2(7)
    @Column(name = "RSPS_TYPE", length = 7)
    private String rspsType;

    @ApiModelProperty("제어한 사용자ID")  // Y VARCHAR2(20)
    @Column(name = "USER_ID", length = 20)
    private String userId;

    public void setResult(String rspsType) {
        this.rspsType = rspsType;
    }
    public TbRseCtrlHsDto toDto() {
        return TbRseCtrlHsDto.builder()
                .ctrlSeq(this.ctrlSeq)
                .rseCtlrNmbr(this.rseCtlrNmbr)
                .cntlDt(this.cntlDt)
                .devcType(this.devcType)
                .cntlType(this.cntlType)
                .rspsType(this.rspsType)
                .userId(this.userId)
                .build();
    }

    public TbRseCtrlHs(Long ctrlSeq) {
        this.ctrlSeq = ctrlSeq;
    }

}
