package com.its.op.dto.its.database;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.dto.its.code.TbCmmnCdDto;
import com.its.op.entity.its.database.TbHldyInfr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 공휴일 정보 DTO Class
 */
@Data
@Builder
@ApiModel("TbHldyInfrDto(공휴일 정보)")
public class TbHldyInfrDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("년월일")  // N VARCHAR(8)
    @JsonProperty("ymd")
    private String ymd;

    @ApiModelProperty("요일 유형 코드")  // Y VARCHAR(7)
    @JsonProperty("day_type_cd")
    private String dayTypeCd;

    @ApiModelProperty("공휴일 명")  // Y VARCHAR(30)
    @JsonProperty("hldy_nm")
    private String hldyNm;

    @ApiModelProperty("비고")  // Y VARCHAR(200)
    @JsonProperty("rmrk")
    private String rmrk;

    // Code Description Field
    @ApiModelProperty("요일 유형 코드 설명")
    @JsonProperty("day_type_desc")    // DAY_TYPE_CD
    private String dayTypeDesc;

    @ApiModel("TbLeglHldyInfrUpdReq(공휴일 정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbLeglHldyInfrUpdReq {

        @ApiModelProperty("년월일, Nullable = N, VARCHAR(8)")  // N VARCHAR(8)
        @JsonProperty("ymd")
        @Size(min=1, max=8)
        private String ymd;

        @ApiModelProperty("요일 유형 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("day_type_cd")
        @Size(min=1, max=7)
        private String dayTypeCd;

        @ApiModelProperty("공휴일 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("hldy_nm")
        @Size(min=1, max=30)
        private String hldyNm;

        @ApiModelProperty("비고, Nullable = Y, VARCHAR(200)")  // Y VARCHAR(200)
        @JsonProperty("rmrk")
        //@Size(min=1, max=200)
        @Size(max=200)
        private String rmrk;

        @Builder
        public TbLeglHldyInfrUpdReq(String ymd, String day_type_cd, String hldy_nm, String rmrk) {
            this.ymd = ymd;
            this.dayTypeCd = day_type_cd;
            this.hldyNm = hldy_nm;
            this.rmrk = rmrk;
        }

        public TbHldyInfr toEntity() {
            return TbHldyInfr.builder()
                    .ymd(this.ymd)
                    .dayTypeCd(this.dayTypeCd)
                    .hldyNm(this.hldyNm)
                    .rmrk(this.rmrk)
                    .build();
        }

    }

    @ApiModel("LeglHldyType(휴일 유형 정보)")
    @Getter
    public static class LeglHldyType {
        @ApiModelProperty("요일 유형 코드")
        @JsonProperty("day_type_cd")
        private String dayTypeCd;

        @ApiModelProperty("공휴일 명")
        @JsonProperty("legl_hldy_nm")
        private String leglHldyNm;

        @ApiModelProperty("요일 유형 설명")
        @JsonProperty("day_type_desc")
        private String dayTypeDesc;

        public LeglHldyType(TbCmmnCdDto entity) {
            this.dayTypeCd = entity.getCmmnCd();
            this.leglHldyNm = entity.getCmmnCdKorNm();
            this.dayTypeDesc = "[" + this.dayTypeCd + "] " + this.leglHldyNm;
        }
    }


}
