easyui中权限分配和添加 前后端代码
阅读原文时间:2023年07月09日阅读:1
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() \+ path + "/"; %> <%-- --%> <%-- --%>


角色名称: 类型生效标志:
角色名称: 类型生效标志:
时间戳:



java代码==============

/**
* 查询权限列表
* @param categoryId
* @return
*/
@Override
public List> getMenus(String categoryId) {
List>menuallist= userDao.selectMenuAllList();
List meunSelectedList = null;
if (StringUtils.isNotBlank(categoryId)) {
//查询已有权限
meunSelectedList = userDao.selectMenuSelectedList(categoryId);
}
//获取树状结构
List>listTree=getTreeList(menuallist,meunSelectedList,"id","pre_id","children");
return listTree;
}
public List> getTreeList(List>menuaList,List idlist,String id,String pre_id,String children) {
System.out.println("获取树状结构开始》》》》》》》》》》》》》》》》》》》");
/**
* 给获取数组的每一项添加一个子项
*/
for(int i=0;i>());
}
System.out.println("menuaList=="+menuaList);
List>treeList=new ArrayList>();
for(MapoutMap:menuaList) {
for(MapinMap:menuaList) {
String outid=outMap.get(id).toString();
String inPre_id=inMap.get(pre_id).toString();
if(outid.equals(inPre_id)) {
List> listMap=(ArrayList>)outMap.get(children);
listMap.add(inMap);
String inId=inMap.get("id").toString();
//判断查询获取的id和内循环id是否相同 如果相同给checked赋值为true
if(null!=idlist) {
if(isFaseOrTrue(inId,idlist)) {
inMap.put("checked", "true");
}
}
}
}
String outPid=outMap.get(pre_id).toString();
if(StringUtils.isAllBlank(outPid)) {
treeList.add(outMap);
String outId=outMap.get(id).toString();
if(null!=idlist) {
if(isFaseOrTrue(outId,idlist)) {
outMap.put("checked", "true");
}
}
}
}
return treeList;

}
//判断表达式
private Boolean isFaseOrTrue(String id,Listlist) {
Boolean flag=false;
for(String str:list) {
if(id.equals(str)) {
flag=true;
break;
}
}
return flag;
}