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

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

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

    @ApiModelProperty("교차로 그룹 명")  // Y VARCHAR2(50)
    @Column(name = "IXR_GROP_NM", length = 50)
    private String ixrGropNm;

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

    public TbScIxrGropMngmDto toDto() {
        return TbScIxrGropMngmDto.builder()
                .ixrGrop(this.ixrGrop)
                .ixrGropNm(this.ixrGropNm)
                .rgstEn(this.rgstEn)
                .build();
    }

    public TbScIxrGropMngm(Integer ixrGrop) {
        this.ixrGrop = ixrGrop;
    }

    public void updateInfo(TbScIxrGropMngmDto.TbScIxrGropMngmUpdReq req) {
        this.ixrGropNm = req.getIxrGropNm();
        this.rgstEn = req.getRgstEn();
    }

}
