

package com.nantian.sc.cloud.admin.api.dto;

import com.nantian.sc.cloud.admin.api.vo.MenuVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @date 2017年11月9日23:33:27
 */
@Data
@ApiModel(value = "菜单树")
@EqualsAndHashCode(callSuper = true)
public class MenuTree extends TreeNode {
	/**
	 * 菜单图标
	 */
	@ApiModelProperty(value = "菜单图标")
	private String icon;
	/**
	 *  菜单名称
	 */
	@ApiModelProperty(value = "菜单名称")
	private String name;
	private boolean spread = false;
	/**
	 * 前端路由标识路径
	 */
	@ApiModelProperty(value = "前端路由标识路径")
	private String path;
	/**
	 * 路由缓冲
	 */
	@ApiModelProperty(value = "路由缓冲")
	private String keepAlive;
	/**
	 * 权限编码
	 */
	@ApiModelProperty(value = "权限编码")
	private String code;
	/**
	 * 菜单类型 （0菜单 1按钮）
	 */
	@ApiModelProperty(value = "菜单类型,0:菜单 1:按钮")
	private String type;
	/**
	 * 菜单标签
	 */
	@ApiModelProperty(value = "菜单标签")
	private String label;

	@ApiModelProperty(value = "菜单id")
	private Integer menuId;

	@ApiModelProperty(value = "文件路径")
	private String filePath;

	@ApiModelProperty(value = "是否显示菜单（0：否，1：是）")
	private String hideMenu;

	@ApiModelProperty(value = "角色权限（1：节能，2：计量，3：公共机构，0：系统管理）")
	private String authority;

	@ApiModelProperty(value = "主菜单")
	private String component;

	@ApiModelProperty(value = "英文名称")
	private String yName;

	@ApiModelProperty(value = "菜单名称信息")
	private String title;

	@ApiModelProperty(value = "菜单名称等信息")
	private Map<String,Object> meta;

	@ApiModelProperty(value = "菜单权限标识")
	private String permission;

	/**
	 * 排序值
	 */
	@ApiModelProperty(value = "排序值")
	private Integer sort;

	public MenuTree() {
	}

	public MenuTree(int id, String name, int parentId) {
		this.id = id;
		this.parentId = parentId;
		this.name = name;
		this.label = name;
	}

	public MenuTree(int id, String name, MenuTree parent) {
		this.id = id;
		this.parentId = parent.getId();
		this.name = name;
		this.label = name;
	}

	public MenuTree(MenuVO menuVo) {
		this.id = menuVo.getMenuId();
		this.parentId = menuVo.getParentId();
		this.icon = menuVo.getIcon();
		this.name = menuVo.getName();
		this.path = menuVo.getPath();
		this.type = menuVo.getType();
		this.label = menuVo.getName();
		this.sort = menuVo.getSort();
		this.keepAlive = menuVo.getKeepAlive();
        this.filePath = menuVo.getFilePath();
        this.hideMenu = menuVo.getHideMenu();
        this.authority = menuVo.getAuthority();
        this.yName = menuVo.getYName();
        this.title = menuVo.getName();
        this.permission = menuVo.getPermission();
		Map<String,Object> map = new HashMap<>();
		map.put("title",menuVo.getName());
		this.meta = map;
	}
}
