package com.its.op.entity.its.oper;

import com.its.op.dto.its.oper.TbOperSystDto;
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;

/**
 * 운영시스템 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("운영시스템")
@Entity
@Table(name = "TB_OPER_SYST")
public class TbOperSyst implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("운영시스템ID")  // N VARCHAR2(30)
    @Id
    @Column(name = "OPER_SYST_ID", nullable = false, length = 7)
    private String operSystId;

    @ApiModelProperty("운영시스템명칭")  // Y VARCHAR2(50)
    @Column(name = "OPER_SYST_NAME", length = 50)
    private String operSystName;

    @ApiModelProperty("생성 일시")  // Y VARCHAR2(14)
    @Column(name = "CRTN_DT", length = 14)
    private String crtnDt;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @Column(name = "DEL_YN", columnDefinition = "CHAR", length = 1)
    private String delYn;

    public TbOperSystDto toDto() {
        return TbOperSystDto.builder()
                .operSystId(this.operSystId)
                .operSystName(this.operSystName)
                .crtnDt(this.crtnDt)
                .delYn(this.delYn)
                .build();
    }

    public TbOperSyst(String operSystId) {
        this.operSystId = operSystId;
    }

    public void updateInfo(TbOperSystDto.TbOperSystUpdReq req) {
        this.operSystName = req.getOperSystName();
        this.crtnDt = req.getCrtnDt();
        this.delYn = req.getDelYn();
    }

}
