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

import com.its.api.bis.model.dto.BitDto;
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;
import java.time.LocalDateTime;

/**
 *  Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("BIT 정보")
@Entity
@Table(name = "BIT")
public class Bit implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("BIT ID")  // N VARCHAR(10)
    @Id
    @Column(name = "BITID", nullable = false, length = 10)
    private String bitid;

    @ApiModelProperty("BIT 명")  // Y VARCHAR(50)
    @Column(name = "BITNAME", length = 50)
    private String bitname;

    @ApiModelProperty("BIT 유형")  // Y CHAR(1)
    @Column(name = "BITTYPE", columnDefinition = "CHAR", length = 1)
    private String bittype;

    @ApiModelProperty("주소")  // Y VARCHAR(100)
    @Column(name = "ADDRESS", length = 100)
    private String address;

    @ApiModelProperty("등록일시")  // Y DATE(0)
    @Column(name = "REGDATE")
    private LocalDateTime regdate;

    @ApiModelProperty("사용여부")  // Y CHAR(1)
    @Column(name = "USEFLAG", columnDefinition = "CHAR", length = 1)
    private String useflag;

    @ApiModelProperty("우선순위")  // Y CHAR(1)
    @Column(name = "CONNPRIORITY", columnDefinition = "CHAR", length = 1)
    private String connpriority;

    @ApiModelProperty("시나리오 ID")  // Y VARCHAR(10)
    @Column(name = "BITSCENARIOID", length = 10)
    private String bitscenarioid;

    @ApiModelProperty("메이크")  // Y VARCHAR(30)
    @Column(name = "BITMAKE", length = 30)
    private String bitmake;

    @ApiModelProperty("RESOLUTION")  // Y CHAR(1)
    @Column(name = "RESOLUTION", columnDefinition = "CHAR", length = 1)
    private String resolution;

    @ApiModelProperty("ADMINTYPE")  // Y CHAR(1)
    @Column(name = "ADMINTYPE", columnDefinition = "CHAR", length = 1)
    private String admintype;

    @ApiModelProperty("DMBCHANNEL")  // Y NUMBER(1)
    @Column(name = "DMBCHANNEL", columnDefinition = "NUMBER", length = 1)
    private Integer dmbchannel;

    @ApiModelProperty("DMBVOLUME")  // Y NUMBER(2)
    @Column(name = "DMBVOLUME", columnDefinition = "NUMBER", length = 2)
    private Integer dmbvolume;

    @ApiModelProperty("LOCALNO")  // Y NUMBER(5)
    @Column(name = "LOCALNO", columnDefinition = "NUMBER", length = 5)
    private Integer localno;

    @ApiModelProperty("COORDX")  // Y NUMBER(0)
    @Column(name = "COORDX", columnDefinition = "NUMBER", length = 0)
    private Double coordx;

    @ApiModelProperty("COORDY")  // Y NUMBER(0)
    @Column(name = "COORDY", columnDefinition = "NUMBER", length = 0)
    private Double coordy;

    @ApiModelProperty("TMCOORDX")  // Y NUMBER(0)
    @Column(name = "TMCOORDX", columnDefinition = "NUMBER", length = 0)
    private Integer tmcoordx;

    @ApiModelProperty("TMCOORDY")  // Y NUMBER(0)
    @Column(name = "TMCOORDY", columnDefinition = "NUMBER", length = 0)
    private Integer tmcoordy;

    @ApiModelProperty("WCOMMTYPE")  // Y CHAR(1)
    @Column(name = "WCOMMTYPE", columnDefinition = "CHAR", length = 1)
    private String wcommtype;

    @ApiModelProperty("WIPADDRESS")  // Y VARCHAR(15)
    @Column(name = "WIPADDRESS", length = 15)
    private String wipaddress;

    @ApiModelProperty("WLIPADDRESS")  // Y VARCHAR(15)
    @Column(name = "WLIPADDRESS", length = 15)
    private String wlipaddress;

    @ApiModelProperty("WPORT")  // Y NUMBER(5)
    @Column(name = "WPORT", columnDefinition = "NUMBER", length = 5)
    private Integer wport;

    @ApiModelProperty("WLPORT")  // Y NUMBER(5)
    @Column(name = "WLPORT", columnDefinition = "NUMBER", length = 5)
    private Integer wlport;

    @ApiModelProperty("DMBFLAG")  // Y CHAR(1)
    @Column(name = "DMBFLAG", columnDefinition = "CHAR", length = 1)
    private String dmbflag;

    @ApiModelProperty("BITSERVICEFLAG")  // Y CHAR(1)
    @Column(name = "BITSERVICEFLAG", columnDefinition = "CHAR", length = 1)
    private String bitserviceflag;

    public BitDto toDto() {
        return BitDto.builder()
                .bitid(this.bitid)
                .bitname(this.bitname)
                .bittype(this.bittype)
                .address(this.address)
                .regdate(this.regdate)
                .useflag(this.useflag)
                .connpriority(this.connpriority)
                .bitscenarioid(this.bitscenarioid)
                .bitmake(this.bitmake)
                .resolution(this.resolution)
                .admintype(this.admintype)
                .dmbchannel(this.dmbchannel)
                .dmbvolume(this.dmbvolume)
                .localno(this.localno)
                .coordx(this.coordx)
                .coordy(this.coordy)
                .tmcoordx(this.tmcoordx)
                .tmcoordy(this.tmcoordy)
                .wcommtype(this.wcommtype)
                .wipaddress(this.wipaddress)
                .wlipaddress(this.wlipaddress)
                .wport(this.wport)
                .wlport(this.wlport)
                .dmbflag(this.dmbflag)
                .bitserviceflag(this.bitserviceflag)
                .build();
    }

}
