コード例 #1
0
 @Override
 public String getNodeById(String nodeId, User user) {
   int roleId = user.getRole().getRoleId();
   List<Menu> menus = menuDAO.findNoeById(Integer.parseInt(nodeId));
   List<MenuBean> menuBeans = new ArrayList<MenuBean>();
   for (Menu menu : menus) {
     if (0 == menu.getMenuLeaf()) {
       MenuBean menuBean = new MenuBean();
       menuBean.setId(menu.getMenuId());
       menuBean.setLeaf(menu.getMenuLeaf());
       menuBean.setMenuParentId(menu.getMenuParentId());
       menuBean.setMenuUrl(menu.getMenuUrl());
       menuBean.setText(menu.getMenuTitle());
       menuBean.setMenuIcon(menu.getMenuIcon());
       menuBeans.add(menuBean);
     } else {
       Permission permission =
           permissionDAO.findByMenuIdAndFunction(menu.getMenuId(), 1); // 查询出菜单的查询模板的权限序号
       RolePermission rolePer = null;
       if (null != permission) {
         rolePer =
             rolePermissionDAO.findByPerIdAndRoleId(permission.getPerId(), String.valueOf(roleId));
       }
       // 有查询权限的菜单才显示
       if (null != rolePer) {
         MenuBean menuBean = new MenuBean();
         menuBean.setId(menu.getMenuId());
         menuBean.setLeaf(menu.getMenuLeaf());
         menuBean.setMenuParentId(menu.getMenuParentId());
         menuBean.setMenuUrl(menu.getMenuUrl());
         menuBean.setText(menu.getMenuTitle());
         menuBean.setMenuIcon(menu.getMenuIcon());
         menuBeans.add(menuBean);
       }
     }
   }
   return JSONArray.fromObject(menuBeans).toString();
 }
コード例 #2
0
 @Override
 public List<Menu> getAllLeaf() {
   return menuDAO.findAllLeaf();
 }