package com.its.op.dto.its.code;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.code.TbSectGrad;
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("TbSectGradClsfDto(구간 등급 분류)")
public class TbSectGradClsfDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("구간 등급 코드")  // N VARCHAR(7)
    @JsonProperty("sect_grad_cd")
    private String sectGradCd;

    @ApiModelProperty("구간 등급 명")  // Y VARCHAR(40)
    @JsonProperty("sect_grad_nm")
    private String sectGradNm;

    // Code Description Field
    @ApiModelProperty("구간 등급 코드 설명")
    @JsonProperty("sect_grad_desc")    // SECT_GRAD_CD
    private String sectGradDesc;

    @ApiModel("TbSectGradClsfUpdReq(구간 등급 분류 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbSectGradClsfUpdReq {

        @ApiModelProperty("구간 등급 코드, Nullable = N, VARCHAR(7)")  // N VARCHAR(7)
        @JsonProperty("sect_grad_cd")
        @Size(min=1, max=7)
        private String sectGradCd;

        @ApiModelProperty("구간 등급 명, Nullable = Y, VARCHAR(40)")  // Y VARCHAR(40)
        @JsonProperty("sect_grad_nm")
        @Size(min=1, max=40)
        private String sectGradNm;

        @Builder
        public TbSectGradClsfUpdReq(String sect_grad_cd, String sect_grad_nm) {
            this.sectGradCd = sect_grad_cd;
            this.sectGradNm = sect_grad_nm;
        }

        public TbSectGrad toEntity() {
            return TbSectGrad.builder()
                    .sectGradCd(this.sectGradCd)
                    .sectGradNm(this.sectGradNm)
                    .build();
        }

    }

}
