package com.eactive.eai.rms.common.acl.menu.ui;

import com.eactive.eai.rms.data.entity.man.menu.Menu;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@Data
public class MenuUI {

	private String id;

	@JsonProperty("MENUID")
	private String menuId;

	@JsonProperty("PARENTMENUID")
	private String parentMenuId;

	@JsonProperty("SORTORDER")
	private Integer sortOrder;

	@JsonProperty("MENUNAME")
	private String menuName;

	@JsonProperty("MENUURL")
	private String menuUrl;

	@JsonProperty("MENUIMAGE")
	private String menuImage;

	@JsonProperty("DISPLAYYN")
	private String displayYn;

	@JsonProperty("USEYN")
	private String useYn;

	@JsonProperty("APPPATH")
	private String appPath;

	@JsonProperty("APPCODE")
	private String appCode;

//	@JsonProperty("DISPLAYYNNM")
//	private String displayYNNM;
//	
//	@JsonProperty("USEYNNM")
//	private String useYNNM;

	private String parent;

	private Integer level;

	private String expanded;

	private String isLeaf;

	public MenuUI(Menu menu, Integer level, boolean forceLeaf) {
		this.id = menu.getId();
		this.menuId = menu.getId();
		this.parentMenuId = menu.getParentMenuId();
		this.parent = menu.getParentMenuId();
		this.sortOrder = menu.getSortOrder();
		this.menuName = menu.getMenuName();
		this.level = level;
		this.appCode = menu.getAppCode();
		this.appPath = menu.getAppPath();
		this.displayYn = menu.getDisplayYn();
		this.menuImage = menu.getMenuImage();
		this.menuUrl = menu.getMenuUrl();
		this.useYn = menu.getUseYn();
		this.menuName = menu.getMenuName();
		this.expanded = "true";

		if (menu.getChildMenus().isEmpty()) {
			this.isLeaf = "true";
		} else {
			this.isLeaf = "false";
		}
		if (forceLeaf) {
			this.isLeaf = "true";
			this.expanded = "true";
		}
	}

	public MenuUI() {
	}
}
