package com.its.op.dto.its.oper;

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

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Positive;
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 VARCHAR2(30)
    @JsonProperty("oper_syst_id")
    private String operSystId;

    @ApiModelProperty("")  // N VARCHAR2(100)
    @JsonProperty("menu_id")
    private String menuId;

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

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

    @ApiModelProperty("상위메뉴ID")  // Y VARCHAR2(100)
    @JsonProperty("parent_menu_id")
    private String parentMenuId;

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

    // Code Description Field
    @ApiModelProperty("삭제 여부 설명")
    @JsonProperty("del_desc")    // DEL_YN
    private String delDesc;

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

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

        @ApiModelProperty(", Nullable = N, VARCHAR2(100)")  // N VARCHAR2(100)
        @JsonProperty("menu_id")
        @Size(min=1, max=100)
        private String menuId;

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

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

        @ApiModelProperty("상위메뉴ID, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("parent_menu_id")
        @Size(min=1, max=100)
        private String parentMenuId;

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

        @Builder
        public TbOperSystMenuUpdReq(String oper_syst_id, String menu_id, String menu_name, Integer menu_levl, String parent_menu_id, String del_yn) {
            this.operSystId = oper_syst_id;
            this.menuId = menu_id;
            this.menuName = menu_name;
            this.menuLevl = menu_levl;
            this.parentMenuId = parent_menu_id;
            this.delYn = del_yn;
        }

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

    }

}
