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

import com.its.op.dto.its.scrs.TbScSpclDdHmsCntlDto;
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_SPCL_DD_HMS_CNTL")
@IdClass(TbScSpclDdHmsCntlKey.class)
public class TbScSpclDdHmsCntl 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 = "SPCL_DD_SEQ", nullable = false, columnDefinition = "NUMBER", length = 2)
    private Integer spclDdSeq;

    @ApiModelProperty("특수 일 월")  // Y NUMBER(2)
    @Column(name = "SPCL_DD_MN", columnDefinition = "NUMBER", length = 2)
    private Integer spclDdMn;

    @ApiModelProperty("특수 일 일")  // Y NUMBER(2)
    @Column(name = "SPCL_DD_DD", columnDefinition = "NUMBER", length = 2)
    private Integer spclDdDd;

    @ApiModelProperty("시각 계획 번호")  // Y NUMBER(2)
    @Column(name = "HMS_PLAN_NMBR", columnDefinition = "NUMBER", length = 2)
    private Integer hmsPlanNmbr;

    @ApiModelProperty("시간 계획 번호")  // Y NUMBER(2)
    @Column(name = "HH_PLAN_NMBR", columnDefinition = "NUMBER", length = 2)
    private Integer hhPlanNmbr;

    public TbScSpclDdHmsCntlDto toDto() {
        return TbScSpclDdHmsCntlDto.builder()
                .ixrGrop(this.ixrGrop)
                .spclDdSeq(this.spclDdSeq)
                .spclDdMn(this.spclDdMn)
                .spclDdDd(this.spclDdDd)
                .hmsPlanNmbr(this.hmsPlanNmbr)
                .hhPlanNmbr(this.hhPlanNmbr)
                .build();
    }

    public TbScSpclDdHmsCntl(Integer ixrGrop, Integer spclDdSeq) {
        this.ixrGrop = ixrGrop;
        this.spclDdSeq = spclDdSeq;
    }

    public void updateInfo(TbScSpclDdHmsCntlDto.TbScSpclDdHmsCntlUpdReq req) {
        this.spclDdMn = req.getSpclDdMn();
        this.spclDdDd = req.getSpclDdDd();
        this.hmsPlanNmbr = req.getHmsPlanNmbr();
        this.hhPlanNmbr = req.getHhPlanNmbr();
    }

}
