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

import com.its.api.its.model.dto.view.VwFcltSttsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;

/**
 *  Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("시설물 상태정보")
@Entity
@Table(name = "VW_FCLT_STTS")
@IdClass(VwFcltSttsKey.class)
public class VwFcltStts implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시설물유형")  // Y VARCHAR(4)
    @Id
    @Column(name = "FCLT_TYPE", length = 4)
    private String fcltType;

    @ApiModelProperty("시설물아이디")  // Y VARCHAR(30)
    @Id
    @Column(name = "FCLT_ID", length = 30)
    private String fcltId;

    @ApiModelProperty("시설물명")  // Y VARCHAR(100)
    @Column(name = "FCLT_NM", length = 100)
    private String fcltNm;

    @ApiModelProperty("시설물관리번호")  // Y VARCHAR(256)
    @Column(name = "FCLT_NMBR", length = 256)
    private String fcltNmbr;

    @ApiModelProperty("시설물종류")  // Y VARCHAR(32)
    @Column(name = "FCLT_KIND", length = 32)
    private String fcltKind;

    @ApiModelProperty("위치X좌표")  // Y NUMBER(0)
    @Column(name = "X_CRDN", columnDefinition = "NUMBER", length = 0)
    private Double xCrdn;

    @ApiModelProperty("위치Y좌표")  // Y NUMBER(0)
    @Column(name = "Y_CRDN", columnDefinition = "NUMBER", length = 0)
    private Double yCrdn;

    @ApiModelProperty("상태코드")  // Y VARCHAR(1)
    @Column(name = "STTS_CD", length = 1)
    private String sttsCd;

    @ApiModelProperty("상태코드설명")  // Y VARCHAR(4)
    @Column(name = "STTS_DESC", length = 4)
    private String sttsDesc;

    @ApiModelProperty("스트림주소")  // Y VARCHAR(200)
    @Column(name = "STRM_URL", length = 200)
    private String strmUrl;

    @ApiModelProperty("정보1")  // Y VARCHAR(65532)
    @Column(name = "FCLT_INFO1", length = 200)
    private String fcltInfo1;

    @ApiModelProperty("정보2")  // Y CHAR(0)
    @Column(name = "FCLT_INFO2", columnDefinition="CHAR", length = 200)
    private String fcltInfo2;

    public VwFcltSttsDto toDto() {
        return VwFcltSttsDto.builder()
                .fcltType(this.fcltType)
                .fcltId(this.fcltId)
                .fcltNm(this.fcltNm)
                .fcltNmbr(this.fcltNmbr)
                .fcltKind(this.fcltKind)
                .xCrdn(this.xCrdn)
                .yCrdn(this.yCrdn)
                .sttsCd(this.sttsCd)
                .sttsDesc(this.sttsDesc)
                .strmUrl(this.strmUrl)
                .fcltInfo1(this.fcltInfo1)
                .fcltInfo2(this.fcltInfo2)
                .build();
    }

}
