package com.its.op.entity.its.road;

import com.its.op.dto.its.road.TbRoadVrtxArrDto;
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 = "TB_ROAD_VRTX_ARR")
@IdClass(TbRoadVrtxArrKey.class)
public class TbRoadVrtxArr implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("도로 ID")  // N NUMBER(10)
    @Id
    @Column(name = "ROAD_ID", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long roadId;

    @ApiModelProperty("레벨")  // N NUMBER(5)
    @Id
    @Column(name = "LEVL", nullable = false, columnDefinition = "NUMBER", length = 5)
    private Integer levl;

    @ApiModelProperty("좌표갯수")  // Y NUMBER(4)
    @Column(name = "CRDN_CNT", columnDefinition = "NUMBER", length = 4)
    private Integer crdnCnt;

    @ApiModelProperty("X 좌표배열")  // Y VARCHAR(4000)
    @Column(name = "X_CRDN_ARR", length = 4000)
    private String xCrdnArr;

    @ApiModelProperty("Y 좌표배열")  // Y VARCHAR(4000)
    @Column(name = "Y_CRDN_ARR", length = 4000)
    private String yCrdnArr;

    @ApiModelProperty("X 좌표최소")  // Y NUMBER(11,8)
    @Column(name = "X_CRDN_MIN", columnDefinition = "NUMBER", length = 11, precision = 8)
    private Double xCrdnMin;

    @ApiModelProperty("X 좌표최대")  // Y NUMBER(11,8)
    @Column(name = "X_CRDN_MAX", columnDefinition = "NUMBER", length = 11, precision = 8)
    private Double xCrdnMax;

    @ApiModelProperty("Y 좌표최소")  // Y NUMBER(10,8)
    @Column(name = "Y_CRDN_MIN", columnDefinition = "NUMBER", length = 10, precision = 8)
    private Double yCrdnMin;

    @ApiModelProperty("Y 좌표최대")  // Y NUMBER(10,8)
    @Column(name = "Y_CRDN_MAX", columnDefinition = "NUMBER", length = 10, precision = 8)
    private Double yCrdnMax;

    public TbRoadVrtxArrDto toDto() {
        return TbRoadVrtxArrDto.builder()
                .roadId(this.roadId)
                .levl(this.levl)
                .crdnCnt(this.crdnCnt)
                .xCrdnArr(this.xCrdnArr)
                .yCrdnArr(this.yCrdnArr)
                .xCrdnMin(this.xCrdnMin)
                .xCrdnMax(this.xCrdnMax)
                .yCrdnMin(this.yCrdnMin)
                .yCrdnMax(this.yCrdnMax)
                .build();
    }

}
