用枚举来进行菜单和角色的绑定

一级菜单:

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum MethodMenuGroup {

tenant(true,0,"用户管理"),contractstats(false,1,"合同统计"),cert(true,2,"证书管理"),
system(true,3,"系统设置"),permission(true,4,"权限管理"),server(true,5,"服务管理"),systemaccess(false,6,"系统接入");

private Boolean visible;
private Integer order;
private String disName;

private MethodMenuGroup(Boolean visible,Integer order,String disName){
this.visible = visible;
this.order = order;
this.disName = disName;
}

public Boolean getVisible() {
return visible;
}

public Integer getOrder() {
return order;
}

public String getName(){
return disName;
}

public String getKey() {
return name();
}

}

 

二级菜单:

/**
* 菜单表的原始信息枚举
* @author xushuai
*
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ResourceMenu {
companyUser(0,MethodMenuGroup.tenant,"企业用户"),
companyAuthList(1,MethodMenuGroup.tenant,"企业认证"),
personUser(2,MethodMenuGroup.tenant,"个人用户"),
// personAuthList(3,MethodMenuGroup.tenant,"实名认证"),


contractStats(0,MethodMenuGroup.contractstats,"合同统计"),

certStats(0,MethodMenuGroup.cert,"证书统计"),
certManage(1,MethodMenuGroup.cert,"事件证书"),

commonSetting(0,MethodMenuGroup.system,"通用设置"),
paramSetting(1,MethodMenuGroup.system,"系统参数设置"),

accountManage(1,MethodMenuGroup.permission,"账号管理"),
roleManage(2,MethodMenuGroup.permission,"角色管理"),

systemLogs(0,MethodMenuGroup.server,"系统日志"),
monitClusters(1,MethodMenuGroup.server,"服务监控"),
serviceClusters(2,MethodMenuGroup.server,"服务集群"),

systemAccess(0,MethodMenuGroup.systemaccess,"系统接入");

private Integer order;
private MethodMenuGroup groupType;
private String menuName;

private ResourceMenu(Integer order,MethodMenuGroup groupType,String menuName){
this.order = order;
this.groupType = groupType;
this.menuName = menuName;
}



public Integer getOrder() {
return order;
}

 

public MethodMenuGroup getGroupType() {
return groupType;
}
public String getMenuName() {
return menuName;
}
public String getKey() {
return name();
}
}

 

 

将二级菜单 和 角色id关联一起 入库即可,节省很多的代码

posted @ 2018-04-08 15:35  精细匠人  阅读(380)  评论(0编辑  收藏  举报