package com.oqpo.api.web.dto.response.menu;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.oper.MenuEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class MenuInfoResponse {
    @ApiModelProperty(value = "메뉴번호")
    private Integer menuNo;

    @ApiModelProperty(value = "메뉴ID")
    private String menuId;

    @ApiModelProperty(value = "상위메뉴번호")
    private Integer topMenuNo;

    @ApiModelProperty(value = "메뉴명")
    private String menuNm;

    @ApiModelProperty(value = "사용여부")
    private String useYn;

    @ApiModelProperty(value = "출력순번")
    private Integer viewNum;

    @ApiModelProperty(value = "접속URL")
    private String connUrl;

    @ApiModelProperty(value = "아이콘여부")
    private String iconYn;

    @ApiModelProperty(value = "메뉴상세내역")
    private String roleDesc;

    @ApiModelProperty(value = "view구분")
    private String openCd;

    @ApiModelProperty(value = "상위메뉴명")
    private String topMenuNm;

    public static MenuInfoResponse toDTO(MenuEntity entity) {
        if (entity == null) return null;
        return MenuInfoResponse.builder()
                .menuNo(entity.getMenuNo())
                .menuId(entity.getMenuId())
                .topMenuNo(entity.getTopMenuNo())
                .menuNm(entity.getMenuNm())
                .useYn(entity.getUseYn())
                .viewNum(entity.getViewNum())
                .connUrl(entity.getConnUrl())
                .iconYn(entity.getIconYn())
                .roleDesc(entity.getRoleDesc())
                .openCd(entity.getOpenCd())
                .topMenuNm(entity.getTopMenuNm())
                .build();
    }
}
