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

import com.its.api.its.model.dto.incident.TbIncdOcrrVmsDto;
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;

/**
 * 돌발상황 발생 VMS Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("돌발상황 발생 VMS")
@Entity
@Table(name = "TB_INCD_OCRR_VMS")
public class TbIncdOcrrVms implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("돌발상황 발생 ID")  // N VARCHAR(12)
    @Id
    @Column(name = "INCD_OCRR_ID", nullable = false, length = 12)
    private String incdOcrrId;

    @ApiModelProperty("시작 위치 명")  // Y VARCHAR(10)
    @Column(name = "STRT_LCTN_NM", length = 10)
    private String strtLctnNm;

    @ApiModelProperty("종료 위치 명")  // Y VARCHAR(10)
    @Column(name = "END_LCTN_NM", length = 10)
    private String endLctnNm;

    @ApiModelProperty("발생 위치 명")  // Y VARCHAR(100)
    @Column(name = "OCRR_LCTN_NM", length = 100)
    private String ocrrLctnNm;

    @ApiModelProperty("VMS 돌발상황 유형 코드")  // Y VARCHAR(7)
    @Column(name = "VMS_INCD_TYPE_CD", length = 7)
    private String vmsIncdTypeCd;

    @ApiModelProperty("VMS 돌발상황 상세 유형 코드")  // Y VARCHAR(7)
    @Column(name = "VMS_INCD_DETL_TYPE_CD", length = 7)
    private String vmsIncdDetlTypeCd;

    @ApiModelProperty("소통 등급 코드")  // Y VARCHAR(7)
    @Column(name = "CMTR_GRAD_CD", length = 7)
    private String cmtrGradCd;

    @ApiModelProperty("돌발상황 차단 차로")  // Y VARCHAR(6)
    @Column(name = "INCD_CLSR_LANE", length = 6)
    private String incdClsrLane;

    @ApiModelProperty("VMS 표출 여부")  // Y CHAR(1)
    @Column(name = "VMS_DSPL_YN", columnDefinition = "CHAR", length = 1)
    private String vmsDsplYn;

    @ApiModelProperty("돌발상황 진행 단계 코드")  // Y VARCHAR(7)
    @Column(name = "INCD_PRGR_STEP_CD", length = 7)
    private String incdPrgrStepCd;

    @ApiModelProperty("돌발상황 시작 일시")  // Y VARCHAR(14)
    @Column(name = "INCD_STRT_DT", length = 14)
    private String incdStrtDt;

    @ApiModelProperty("돌발상황 종료 예정 일시")  // Y VARCHAR(14)
    @Column(name = "INCD_END_PRAR_DT", length = 14)
    private String incdEndPrarDt;

    @ApiModelProperty("링크ID")  // Y NUMBER(10)
    @Column(name = "LINK_ID", columnDefinition = "NUMBER", length = 10)
    private Long linkId;

    public TbIncdOcrrVmsDto toDto() {
        return TbIncdOcrrVmsDto.builder()
                .incdOcrrId(this.incdOcrrId)
                .strtLctnNm(this.strtLctnNm)
                .endLctnNm(this.endLctnNm)
                .ocrrLctnNm(this.ocrrLctnNm)
                .vmsIncdTypeCd(this.vmsIncdTypeCd)
                .vmsIncdDetlTypeCd(this.vmsIncdDetlTypeCd)
                .cmtrGradCd(this.cmtrGradCd)
                .incdClsrLane(this.incdClsrLane)
                .vmsDsplYn(this.vmsDsplYn)
                .incdPrgrStepCd(this.incdPrgrStepCd)
                .incdStrtDt(this.incdStrtDt)
                .incdEndPrarDt(this.incdEndPrarDt)
                .linkId(this.linkId)
                .build();
    }

    public TbIncdOcrrVms(String incdOcrrId) {
        this.incdOcrrId = incdOcrrId;
    }

    public void updateInfo(TbIncdOcrrVmsDto.TbIncdOcrrVmsUpdReq req) {
        this.strtLctnNm = req.getStrtLctnNm();
        this.endLctnNm = req.getEndLctnNm();
        this.ocrrLctnNm = req.getOcrrLctnNm();
        this.vmsIncdTypeCd = req.getVmsIncdTypeCd();
        this.vmsIncdDetlTypeCd = req.getVmsIncdDetlTypeCd();
        this.cmtrGradCd = req.getCmtrGradCd();
        this.incdClsrLane = req.getIncdClsrLane();
        this.vmsDsplYn = req.getVmsDsplYn();
        this.incdPrgrStepCd = req.getIncdPrgrStepCd();
        this.incdStrtDt = req.getIncdStrtDt();
        this.incdEndPrarDt = req.getIncdEndPrarDt();
        this.linkId = req.getLinkId();
    }

}
