package com.its.op.entity.its.scrs;

import com.its.op.dto.its.scrs.TbScSgnlIxrMngmDto;
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_SC_SGNL_IXR_MNGM")
public class TbScSgnlIxrMngm implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("신호 교차로 번호")  // N NUMBER(4)
    @Id
    @Column(name = "SGNL_IXR_NMBR", nullable = false, columnDefinition = "NUMBER", length = 4)
    private Integer sgnlIxrNmbr;

    @ApiModelProperty("교차로 그룹")  // N NUMBER(3)
    @Column(name = "IXR_GROP", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer ixrGrop;

    @ApiModelProperty("교차로 구분(0: 중요 교차로, 1: 준중요 교차로, 2: 비중요 교차로)")  // Y NUMBER(1)
    @Column(name = "IXR_DVSN", columnDefinition = "NUMBER", length = 1)
    private Integer ixrDvsn;

    @ApiModelProperty("규격 구분(0:2004년, 1:2010년)")  // Y NUMBER(1)
    @Column(name = "STAD_DVSN", columnDefinition = "NUMBER", length = 1)
    private Integer stadDvsn;

    @ApiModelProperty("교차로 명")  // Y VARCHAR2(50)
    @Column(name = "IXR_NM", length = 50)
    private String ixrNm;

    @ApiModelProperty("등록 유무")  // Y NUMBER(1)
    @Column(name = "RGST_EN", columnDefinition = "NUMBER", length = 1)
    private Integer rgstEn;

    public TbScSgnlIxrMngmDto toDto() {
        return TbScSgnlIxrMngmDto.builder()
                .sgnlIxrNmbr(this.sgnlIxrNmbr)
                .ixrGrop(this.ixrGrop)
                .ixrDvsn(this.ixrDvsn)
                .stadDvsn(this.stadDvsn)
                .ixrNm(this.ixrNm)
                .rgstEn(this.rgstEn)
                .build();
    }

    public TbScSgnlIxrMngm(Integer sgnlIxrNmbr) {
        this.sgnlIxrNmbr = sgnlIxrNmbr;
    }

    public void updateInfo(TbScSgnlIxrMngmDto.TbScSgnlIxrMngmUpdReq req) {
        this.ixrGrop = req.getIxrGrop();
        this.ixrDvsn = req.getIxrDvsn();
        this.stadDvsn = req.getStadDvsn();
        this.ixrNm = req.getIxrNm();
        this.rgstEn = req.getRgstEn();
    }

}
