用户权限授权

with  d as
(select t.menu_no , b.usr_id from  menu_grant t, grp_members b
where t.obj_type='G'  and t.obj_no = b.grp_no
union
select t.menu_no , b.usr_id from  menu_grant t, users b
where t.obj_type='U' and t.obj_no= b.usr_id
)
<!--不查询子菜单 
select t.menu_no as
    menuNo
    ,t.menu_name as menuName,t.menu_link as
    menuLink,t.menu_para as
    menuPara,t.menu_parid as menuParid,t.menu_level as
menuLevel,t.menu_remark as menuRemark,t.menu_sort as menuSort
from
menu_def t
    start with t.menu_parid in ( select  distinct menu_no from d where usr_id=#{usrId})
    connect by prior t.menu_no= t.menu_parid
union  
-->
select t.menu_no as
    menuNo
    ,t.menu_name as menuName,t.menu_link as
    menuLink,t.menu_para as
    menuPara,t.menu_parid as menuParid,t.menu_level as
menuLevel,t.menu_remark as menuRemark,t.menu_sort as menuSort
from
menu_def t
   
    where t.menu_no in (select  distinct menu_no from d where usr_id=#{usrId} )
   order by menusort

dtree生成
if (menuList != null) {
script.append("<SCRIPT LANGUAGE='JavaScript'> \n");
script.append("<!-- \n");
script.append("d = new dTree('d');\n");

script.append("d.add('0','-1','" + SYSTEM_MENU_ROOT + "','#','"
+ SYSTEM_MENU_ROOT + "');\n");
//找出没有父菜单的项目追加到0后面




for (MenuDef menuDef : menuList) {
String parentid= menuDef.getMenuParid();
boolean hasParent=false;
for(MenuDef menuDefAll : menuList){

if(parentid==null)
continue;
else{
if(parentid.equals(menuDefAll.getMenuNo()))
{
hasParent=true;
}

}
}

if(!hasParent){//没有父节点,则直接挂在系统菜单下面
menuDef.setMenuParid(null);

}

script.append("d.add('"
+ menuDef.getMenuNo()
+ "','"
+ (menuDef.getMenuParid() == null ? "0" : menuDef
.getMenuParid())
+ "','"
+ menuDef.getMenuName()
+ "','"
+ ("#".equals(menuDef.getMenuLink()) ? "" : menuDef
.getMenuLink()) + "','" + menuDef.getMenuName()
+ "','main')  \n");
}

script.append("document.write(d);");
script.append(" //--> \n");
script.append(" // \n");
script.append(" </SCRIPT> \n");
}

你可能感兴趣的:(权限)