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

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

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

/**
 * 운영시스템메뉴 DTO Class
 */
@Data
@Builder
@ApiModel("TbOpersystMenuDto(운영시스템메뉴)")
public class TbOperSystMenuDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("운영시스템메뉴ID")  // N VARCHAR(30)
    @JsonProperty("opersyst_menu_id")
    private String operSystMenuId;

    @ApiModelProperty("메뉴명")  // Y VARCHAR(100)
    @JsonProperty("menu_name")
    private String menuName;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @JsonProperty("del_yn")
    private String delYn;

    @ApiModelProperty("메뉴레벨")  // Y NUMBER(2)
    @JsonProperty("menu_levl")
    private Integer menuLevl;

    @ApiModelProperty("운영시스템ID")  // Y VARCHAR(30)
    @JsonProperty("oper_syst_id")
    private String operSystId;

    // Code Description Field

    @ApiModel("TbOpersystMenuUpdReq(운영시스템메뉴 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbOperSystMenuUpdReq {

        @ApiModelProperty("운영시스템메뉴ID, Nullable = N, VARCHAR(30)")  // N VARCHAR(30)
        @JsonProperty("opersyst_menu_id")
        @Size(min=1, max=30)
        private String operSystMenuId;

        @ApiModelProperty("메뉴명, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("menu_name")
        @Size(min=1, max=100)
        private String menuName;

        @ApiModelProperty("삭제 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("del_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String delYn;

        @ApiModelProperty("메뉴레벨, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("menu_levl")
        @PositiveOrZero
        private Integer menuLevl;

        @ApiModelProperty("운영시스템ID, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("oper_syst_id")
        @Size(min=1, max=30)
        private String operSystId;

        @Builder
        public TbOperSystMenuUpdReq(String opersyst_menu_id, String menu_name, String del_yn, Integer menu_levl, String oper_syst_id) {
            this.operSystMenuId = opersyst_menu_id;
            this.menuName = menu_name;
            this.delYn = del_yn;
            this.menuLevl = menu_levl;
            this.operSystId = oper_syst_id;
        }

        public TbOperSystMenu toEntity() {
            return TbOperSystMenu.builder()
                    .operSystMenuId(this.operSystMenuId)
                    .menuName(this.menuName)
                    .delYn(this.delYn)
                    .menuLevl(this.menuLevl)
                    .operSystId(this.operSystId)
                    .build();
        }

    }

}
