Exemple #1
0
 /**
  * 返回菜单树
  *
  * @return
  */
 public Menu getTreeMenus() {
   List<Menu> menus = menuDao.listAll();
   Menu root = getRootMenu(menus);
   CollectionSort.sortList(menus, "sno", true);
   eachMenu(menus, root);
   return root;
 }
Exemple #2
0
 /**
  * 用户所具有的菜单,关联权限
  *
  * @param userId
  * @return
  */
 @Transactional(readOnly = true)
 public List<Menu> getUserMenuObject(String userId, String roleId, String isAdmin) {
   List<Menu> menus = null;
   if (!"1".equals(isAdmin)) { // 非管理员
     String sql =
         "select * from ( select t01.* from t_cor_menu t01 join (\n"
             + "SELECT t4.resource_id from t_cor_user t1 join \n"
             + "t_cor_user_role t2 on t1.id_=t2.user_id\n"
             + "join t_cor_role t3 on t2.role_id=t3.id_\n"
             + "join t_cor_authority t4 on t4.role_id=t3.id_ where t1.id_=? and t3.enabled_='1' and t1.enabled_='1') t02 \n"
             + "on t01.resource_id=t02.resource_id) t  order by t.sno_ asc";
     menus = menuDao.listBySql(sql, userId);
   } else {
     menus = menuDao.listAll();
   }
   if (menus == null || menus.isEmpty()) {
     return null;
   }
   Menu root = getRootMenu(menus);
   eachMenu(menus, root);
   List<Menu> trees = root.getRows();
   CollectionSort.sortList(trees, "sno", true);
   return trees;
 }