package com.its.api.its.model.entity.database;

import com.its.api.its.model.dto.database.TbDbSvrSttsDto;
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;

/**
 * DB 서버 상태 Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("DB 서버 상태")
@Entity
@Table(name = "TB_DB_SVR_STTS")
public class TbDbSvrStts implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("DB 서버 ID")  // N VARCHAR(30)
    @Id
    @Column(name = "DB_SVR_ID", nullable = false, length = 30)
    private String dbSvrId;

    @ApiModelProperty("DB 서버 명")  // Y VARCHAR(50)
    @Column(name = "DB_SVR_NM", length = 50)
    private String dbSvrNm;

    @ApiModelProperty("테이블스페이스 명")  // Y VARCHAR(50)
    @Column(name = "TBLS_NM", length = 50)
    private String tblsNm;

    @ApiModelProperty("테이블스페이스 잔여 용량")  // Y VARCHAR(30)
    @Column(name = "TBLS_RMND_CPCT", length = 30)
    private String tblsRmndCpct;

    @ApiModelProperty("사용 세션")  // Y VARCHAR(30)
    @Column(name = "USE_SESN", length = 30)
    private String useSesn;

    @ApiModelProperty("DB 서버 IP")  // Y VARCHAR(20)
    @Column(name = "DB_SVR_IP", length = 20)
    private String dbSvrIp;

    @ApiModelProperty("DB 서버 PORT")  // Y VARCHAR(5)
    @Column(name = "DB_SVR_PORT", length = 5)
    private String dbSvrPort;

    @ApiModelProperty("DB 서버 SID")  // Y VARCHAR(30)
    @Column(name = "DB_SVR_SID", length = 30)
    private String dbSvrSid;

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

    public TbDbSvrSttsDto toDto() {
        return TbDbSvrSttsDto.builder()
                .dbSvrId(this.dbSvrId)
                .dbSvrNm(this.dbSvrNm)
                .tblsNm(this.tblsNm)
                .tblsRmndCpct(this.tblsRmndCpct)
                .useSesn(this.useSesn)
                .dbSvrIp(this.dbSvrIp)
                .dbSvrPort(this.dbSvrPort)
                .dbSvrSid(this.dbSvrSid)
                .updtDt(this.updtDt)
                .build();
    }

}
