package com.its.api.its.model.dto.vms;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.vms.TbVmsLumSetSch;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * VMS 휘도설정 스케쥴 DTO Class
 */
@Data
@Builder
@ApiModel("TbVmsLumSetSchDto(VMS 휘도설정 스케쥴)")
public class TbVmsLumSetSchDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS 제어기 번호")  // N NUMBER(10)
    @JsonProperty("vms_ctlr_nmbr")
    private Long vmsCtlrNmbr;

    @ApiModelProperty("설정시각(HH24MI)")  // N VARCHAR(4)
    @JsonProperty("sch_time")
    private String schTime;

    @ApiModelProperty("휘도값(0:자동,1~100)")  // N NUMBER(3)
    @JsonProperty("luminance")
    private Integer luminance;

    @ApiModelProperty("사용여부(Y:시용,N:사용안함)")  // N CHAR(1)
    @JsonProperty("use_yn")
    private String useYn;

    // Code Description Field
    @ApiModelProperty("사용여부(Y:시용,N:사용안함) 설명")
    @JsonProperty("use_desc")    // USE_YN
    private String useDesc;

    @ApiModelProperty("VMS ID")  // Y VARCHAR(4)
    @Column(name = "VMS_ID", length = 4)
    private String vmsId;

    @ApiModelProperty("VMS 제어기 ID")  // Y VARCHAR(30)
    @Column(name = "VMS_CTLR_ID", length = 30)
    private String vmsCtlrId;

    @ApiModelProperty("VMS 명")  // Y VARCHAR(40)
    @Column(name = "VMS_NM", length = 40)
    private String vmsNm;

    @ApiModel("TbVmsLumSetSchUpdReq(VMS 휘도설정 스케쥴 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbVmsLumSetSchUpdReq {

        @ApiModelProperty("VMS 제어기 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("vms_ctlr_nmbr")
        @PositiveOrZero
        private Long vmsCtlrNmbr;

        @ApiModelProperty("설정시각(HH24MI), Nullable = N, VARCHAR(4)")  // N VARCHAR(4)
        @JsonProperty("sch_time")
        @Size(min=1, max=4)
        private String schTime;

        @ApiModelProperty("휘도값(0:자동,1~100), Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("luminance")
        @PositiveOrZero
        private Integer luminance;

        @ApiModelProperty("사용여부(Y:시용,N:사용안함), Nullable = N, CHAR(1)")  // N CHAR(1)
        @JsonProperty("use_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String useYn;

        @Builder
        public TbVmsLumSetSchUpdReq(Long vms_ctlr_nmbr, String sch_time, Integer luminance, String use_yn) {
            this.vmsCtlrNmbr = vms_ctlr_nmbr;
            this.schTime = sch_time;
            this.luminance = luminance;
            this.useYn = use_yn;
        }

        public TbVmsLumSetSch toEntity() {
            return TbVmsLumSetSch.builder()
                    .vmsCtlrNmbr(this.vmsCtlrNmbr)
                    .schTime(this.schTime)
                    .luminance(this.luminance)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
