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

import com.its.op.dto.its.scrs.TbScWeekHmsCntlDto;
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_WEEK_HMS_CNTL")
public class TbScWeekHmsCntl 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 NUMBER(2)
    @Column(name = "SUN_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer sunHmsPlan;

    @ApiModelProperty("월요일 시각 계획")  // Y NUMBER(2)
    @Column(name = "MON_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer monHmsPlan;

    @ApiModelProperty("화요일 시각 계획")  // Y NUMBER(2)
    @Column(name = "TUE_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer tueHmsPlan;

    @ApiModelProperty("수요일 시각 계획")  // Y NUMBER(2)
    @Column(name = "WED_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer wedHmsPlan;

    @ApiModelProperty("목요일 시각 계획")  // Y NUMBER(2)
    @Column(name = "THU_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer thuHmsPlan;

    @ApiModelProperty("금요일 시각 계획")  // Y NUMBER(2)
    @Column(name = "FRI_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer friHmsPlan;

    @ApiModelProperty("토요일 시각 계획")  // Y NUMBER(2)
    @Column(name = "SAT_HMS_PLAN", columnDefinition = "NUMBER", length = 2)
    private Integer satHmsPlan;

    public TbScWeekHmsCntlDto toDto() {
        return TbScWeekHmsCntlDto.builder()
                .ixrGrop(this.ixrGrop)
                .sunHmsPlan(this.sunHmsPlan)
                .monHmsPlan(this.monHmsPlan)
                .tueHmsPlan(this.tueHmsPlan)
                .wedHmsPlan(this.wedHmsPlan)
                .thuHmsPlan(this.thuHmsPlan)
                .friHmsPlan(this.friHmsPlan)
                .satHmsPlan(this.satHmsPlan)
                .build();
    }

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

    public void updateInfo(TbScWeekHmsCntlDto.TbScWeekHmsCntlUpdReq req) {
        this.sunHmsPlan = req.getSunHmsPlan();
        this.monHmsPlan = req.getMonHmsPlan();
        this.tueHmsPlan = req.getTueHmsPlan();
        this.wedHmsPlan = req.getWedHmsPlan();
        this.thuHmsPlan = req.getThuHmsPlan();
        this.friHmsPlan = req.getFriHmsPlan();
        this.satHmsPlan = req.getSatHmsPlan();
    }

}
