/** * 获取当前用户角色列表 * * @return */ public static List<Role> getRoleList() { @SuppressWarnings("unchecked") List<Role> roleList = (List<Role>) getCache(CACHE_ROLE_LIST); if (roleList == null) { User user = getUser(); if (user.isAdmin()) { roleList = roleDao.findAllList(); } else { Role role = new Role(); roleList = roleDao.findList(role); } putCache(CACHE_ROLE_LIST, roleList); } return roleList; }
/** * 获取当前用户授权菜单 * * @return */ public static List<Menu> getMenuList() { @SuppressWarnings("unchecked") List<Menu> menuList = (List<Menu>) getCache(CACHE_MENU_LIST); if (menuList == null) { User user = getUser(); if (user.isAdmin()) { menuList = menuDao.findAllList(); } else { Menu m = new Menu(); m.setUserId(user.getId()); menuList = menuDao.findByUserId(m); } putCache(CACHE_MENU_LIST, menuList); } return menuList; }