package com.product.admin.entity; import com.beust.jcommander.internal.Sets; import com.google.common.collect.Maps; import com.product.admin.config.CmnConst; import com.product.common.lang.StringUtils; import com.product.core.entity.FieldSetEntity; import java.io.Serializable; import java.util.*; /** * @author cheng * @desc 菜单详情 * @Date 2021年11月15日18:20:20 */ public class MenuEntity implements Serializable, Cloneable, Comparable { public static final long serialVersionUID = 1L; private MenuTreeEntity.MenuArray children; /** * 菜单名称 */ private String menu_name; /** * 门户uuid */ private String portal_uuid; /** * 功能uuid */ private String function_uuid; /** * 菜单描述 */ private String menu_description; /** * 菜单颜色 */ private String menu_color; // private String menu_route_component; /** * 菜单编码 */ private String tricode; /** * 菜单上级编码 */ private String tricode_parent; /** * 菜单图标 */ private String menu_icon; /** * 是否显示 */ private boolean show; /** * 菜单排序 */ private Integer sequence; /** * 功能类型 */ private String function_type; /** * 功能名称 */ private String function_name; /** * 表uuid */ private String table_uuid; /** * 按钮uuid */ private String button_uuid; /** * 路由名称 */ private String route_name; /** * 页面类型 */ private Integer page_type; /** * mvc页面表uuid */ private String mvc_page_uuid; /** * 页面地址 */ private String page_url; /** * 菜单uuid */ private String menu_uuid; private Set roleUuids; private boolean alwaysShow; private String redirect; private String component; private boolean hidden; private String name; private String path; private Map meta = Maps.newHashMap(); public void setMenu_name(String menu_name) { this.menu_name = menu_name; } public void setPortal_uuid(String portal_uuid) { this.portal_uuid = portal_uuid; } public void setFunction_uuid(String function_uuid) { this.function_uuid = function_uuid; } public void setMenu_description(String menu_description) { this.menu_description = menu_description; } public void setMenu_color(String menu_color) { this.menu_color = menu_color; } public void setTricode(String tricode) { this.tricode = tricode; } public void setTricode_parent(String tricode_parent) { this.tricode_parent = tricode_parent; } public void setMenu_icon(String menu_icon) { this.menu_icon = menu_icon; } public void setShow(boolean show) { this.show = show; } public void setSequence(Integer sequence) { this.sequence = sequence; } public void setFunction_type(String function_type) { this.function_type = function_type; } public void setFunction_name(String function_name) { this.function_name = function_name; } public void setTable_uuid(String table_uuid) { this.table_uuid = table_uuid; } public void setButton_uuid(String button_uuid) { this.button_uuid = button_uuid; } public void setRoute_name(String route_name) { this.route_name = route_name; } public void setPage_type(Integer page_type) { this.page_type = page_type; } public void setMvc_page_uuid(String mvc_page_uuid) { this.mvc_page_uuid = mvc_page_uuid; } public void setPage_url(String page_url) { this.page_url = page_url; } public void setMenu_uuid(String menu_uuid) { this.menu_uuid = menu_uuid; } public void setRoleUuids(Set roleUuids) { this.roleUuids = roleUuids; } public void setAlwaysShow(boolean alwaysShow) { this.alwaysShow = alwaysShow; } public void setRedirect(String redirect) { this.redirect = redirect; } public void setComponent(String component) { this.component = component; } public void setHidden(boolean hidden) { this.hidden = hidden; } public void setName(String name) { this.name = name; } public void setPath(String path) { this.path = path; } public void setMeta(Map meta) { this.meta = meta; } @Override public MenuEntity clone() { try { return (MenuEntity) super.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); return null; } } public MenuEntity(FieldSetEntity fse) { reload(fse); } public void reload(FieldSetEntity fse) { this.page_type = fse.getInteger("page_type"); this.page_url = fse.getString("page_url"); this.button_uuid = fse.getString("button_uuid"); this.function_name = fse.getString("function_name"); this.function_uuid = fse.getString("function_uuid"); this.menu_color = fse.getString("menu_color"); this.menu_description = fse.getString("menu_description"); this.menu_icon = fse.getString("menu_icon"); this.menu_name = fse.getString("menu_name"); this.mvc_page_uuid = fse.getString("mvc_page_type"); this.portal_uuid = fse.getString("portal_uuid"); this.route_name = fse.getString("route_name"); this.sequence = fse.getInteger("sequence"); this.show = fse.getBoolean("is_show"); this.table_uuid = fse.getString("table_uuid"); this.tricode = fse.getString("tricode"); this.tricode_parent = fse.getString("tricode_parent"); this.menu_uuid = fse.getString("menu_uuid"); this.function_type = fse.getString("function_type"); if (!StringUtils.isEmpty(fse.getString("role_uuid"))) { if (this.roleUuids == null) { this.roleUuids = Sets.newHashSet(); } this.roleUuids.addAll(Arrays.asList(fse.getString("role_uuid").split(","))); } String function_uuid = this.getFunction_uuid(); String path = ""; String name = ""; String component = ""; if (this.IsCatalogue()) { // 目录 this.alwaysShow = this.IsCatalogue(); this.redirect = "noRedirect"; path += "/" + getTricode(); if (StringUtils.isEmpty(getTricode_parent())) { component = "Layout"; } } else { String button_uuid = getButton_uuid(); path = "/" + button_uuid; name = getRoute_name(); component = getPage_url(); } this.hidden = false; this.name = name; this.path = path; this.component = component; Integer page_type = getPage_type(); meta.put("title", getMenu_name()); meta.put(CmnConst.ICON, getMenu_icon()); meta.put("noCache", page_type != null && page_type == 1); meta.put("group", function_uuid); } public void addChildrenMenu(MenuEntity menuEntity) { if (children == null) { children = MenuTreeEntity.newArrayList(); } children.add(menuEntity); } /** * 是否目录 * * @return */ public boolean IsCatalogue() { return StringUtils.isEmpty(this.function_uuid); } public MenuTreeEntity.MenuArray getChildren() { return children; } public void setChildren(MenuTreeEntity.MenuArray children) { this.children = children; } public String getMenu_name() { return menu_name; } public String getPortal_uuid() { return portal_uuid; } public String getFunction_uuid() { return function_uuid; } public String getMenu_description() { return menu_description; } public String getMenu_color() { return menu_color; } public String getTricode() { return tricode; } public String getTricode_parent() { return tricode_parent; } public String getMenu_icon() { return menu_icon; } public boolean isShow() { return show; } public Integer getSequence() { return sequence; } public String getFunction_type() { return function_type; } public String getFunction_name() { return function_name; } public String getTable_uuid() { return table_uuid; } public String getButton_uuid() { return button_uuid; } public String getRoute_name() { return route_name; } public Integer getPage_type() { return page_type; } public String getMvc_page_uuid() { return mvc_page_uuid; } public String getPage_url() { return page_url; } public String getMenu_uuid() { return menu_uuid; } public Set getRoleUuids() { return roleUuids; } public boolean isAlwaysShow() { return alwaysShow; } public String getRedirect() { return redirect; } public String getComponent() { return component; } public boolean isHidden() { return hidden; } public String getName() { return name; } public String getPath() { return path; } public Map getMeta() { return meta; } @Override public int compareTo(Object o) { MenuEntity a = (MenuEntity) o; MenuEntity b = this; return a.getTricode().length() == b.getTricode().length() ? (a.getSequence() == b.getSequence() ? a.getTricode().compareTo(b.getTricode()) : a.getSequence() - b.getSequence()) : a.getTricode().length() - b.getTricode().length(); } }