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

import com.its.op.dto.its.scrs.TbScPstnIxrMngmDto;
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.*;
import java.io.Serializable;

/**
 * 소속 교차로 관리 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("소속 교차로 관리")
@Entity
@Table(name = "TB_SC_PSTN_IXR_MNGM")
@IdClass(TbScPstnIxrMngmKey.class)
public class TbScPstnIxrMngm 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("일련번호")  // N NUMBER(2)
    @Id
    @Column(name = "SEQ", nullable = false, columnDefinition = "NUMBER", length = 2)
    private Integer seq;

    @ApiModelProperty("소속 교차로 번호")  // Y NUMBER(4)
    @Column(name = "PSTN_IXR_NMBR", columnDefinition = "NUMBER", length = 4)
    private Integer pstnIxrNmbr;

    public TbScPstnIxrMngmDto toDto() {
        return TbScPstnIxrMngmDto.builder()
                .ixrGrop(this.ixrGrop)
                .seq(this.seq)
                .pstnIxrNmbr(this.pstnIxrNmbr)
                .build();
    }

    public TbScPstnIxrMngm(Integer ixrGrop, Integer seq) {
        this.ixrGrop = ixrGrop;
        this.seq = seq;
    }

    public void updateInfo(TbScPstnIxrMngmDto.TbScPstnIxrMngmUpdReq req) {
        this.pstnIxrNmbr = req.getPstnIxrNmbr();
    }

}
