Пример #1
0
  /**
   * 获取根节点菜单
   *
   * @return
   * @author 陈超 2011-02-03
   */
  @SuppressWarnings("unchecked")
  public List<Menu> getMenuByParentId(String parentId, String userId) {
    //		List<PropertyFilter> filters = new LinkedList<PropertyFilter>();
    //		PropertyFilter filter01 = new
    // PropertyFilter("parentMenuId",parentId,PropertyFilter.MatchType.EQ);
    //		filters.add(filter01);
    //		List<Menu> results=menuDao.find(filters);

    List<Menu> results = new LinkedList<Menu>();
    String sql =
        "select a.id,a.C_ICON,a.C_NAME,a.C_PARENT_ID,a.C_URL,a.C_ENNAME from sys_menu as a,sys_role_menu as b where a.c_parent_id='"
            + parentId
            + "' and a.id=b.c_menu_id and b.c_role_id in (select c_role_id from sys_user_role where c_user_id='"
            + userId
            + "') order by a.C_NO asc";
    List r = menuDao.excuteQuery(sql);
    for (Object o : r) {
      Object[] vs = (Object[]) o;
      Menu m = new Menu();
      m.setId((String) vs[0]);
      m.setIcon((String) vs[1]);
      m.setName((String) vs[2]);
      m.setParentMenuId((String) vs[3]);
      m.setUrl((String) vs[4]);
      m.setEnName((String) vs[5]);
      results.add(m);
    }
    return results;
  }
Пример #2
0
  /**
   * 获取已赋权的菜单信息
   *
   * @param roleId
   * @return
   * @author 陈超 2011-01-16
   */
  @SuppressWarnings("unchecked")
  public List<Menu> getSelectedMeunsByRoleId(String roleId) {
    List<Menu> menus = new LinkedList();
    String sql =
        "select a.id,a.C_ICON,a.C_NAME,a.C_PARENT_ID from sys_menu as a,sys_role_menu as b where b.c_menu_id = a.id and b.c_role_id='"
            + roleId
            + "'";
    List r = menuDao.excuteQuery(sql);
    for (Object o : r) {
      Object[] vs = (Object[]) o;
      Menu m = new Menu();
      m.setId((String) vs[0]);
      m.setIcon((String) vs[1]);
      m.setName((String) vs[2]);
      m.setParentMenuId((String) vs[3]);

      menus.add(m);
    }
    return menus;
  }