Search in sources :

Example 1 with MenuItem

use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.

the class HtmlMenuGenerator method outputHtml.

/**
 * 输出菜单的HTML代码
 * @param root - 根节点,不会输出
 * @return 菜单的HTML代码
 */
public static String outputHtml(MenuItem root) {
    List<MenuItem> children = root.createChildren();
    StringBuilder buf = new StringBuilder(1024);
    int level = 0;
    for (MenuItem item : children) {
        outputMenu(item, buf, level + 1);
    }
    // buf.append("</ul>\n");
    return buf.toString();
}
Also used : MenuItem(com.ibeiliao.deployment.admin.utils.resource.MenuItem)

Example 2 with MenuItem

use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.

the class MenuServiceImpl method getMenuTreeWithoutResource.

@Override
public MenuItem getMenuTreeWithoutResource(int appId) {
    List<MenuPO> menuList = menuDao.listByAppId(appId);
    MenuItem root = new MenuItem("root", "", true);
    if (menuList.size() > 0) {
        buildTreeMap(appId, root, menuList);
    }
    return root;
}
Also used : MenuPO(com.ibeiliao.deployment.admin.po.account.MenuPO) MenuItem(com.ibeiliao.deployment.admin.utils.resource.MenuItem)

Example 3 with MenuItem

use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.

the class MenuServiceImpl method getMenuTree.

@Override
public MenuItem getMenuTree(int appId) {
    List<MenuPO> menuList = menuDao.listByAppId(appId);
    MenuItem root = new MenuItem("root", "", true);
    if (menuList.size() > 0) {
        buildTreeMap(appId, root, menuList);
        loadMenuResource(appId, root);
    }
    return root;
}
Also used : MenuPO(com.ibeiliao.deployment.admin.po.account.MenuPO) MenuItem(com.ibeiliao.deployment.admin.utils.resource.MenuItem)

Example 4 with MenuItem

use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.

the class MenuServiceImpl method loadMenuResource.

/**
 * 加载每个菜单下的资源
 *
 * @param appId
 *            - 应用系统ID
 * @param item
 *            - 菜单项
 */
private void loadMenuResource(int appId, MenuItem item) {
    List<MenuItem> children = item.getChildren();
    if (children == null || children.isEmpty()) {
        // 叶子节点才是带有资源的菜单
        if (item.isRoot()) {
            // 没有菜单
            return;
        }
        MenuPO menu = menuDao.getByAppIdAndMenuName(appId, item.getName());
        List<UrlResourcePO> resList = menuResourcesRelationDao.listSpecResourceByMenu(menu.getMenuId(), appId);
        for (UrlResourcePO res : resList) {
            MenuItem resItem = new MenuItem(res.getUrlName(), res.getUri());
            // TIP chenjianhong 主键提供给界面
            resItem.setId(res.getResId());
            item.createChildren().add(resItem);
        }
    } else {
        for (MenuItem mi : children) {
            loadMenuResource(appId, mi);
        }
    }
}
Also used : MenuPO(com.ibeiliao.deployment.admin.po.account.MenuPO) UrlResourcePO(com.ibeiliao.deployment.admin.po.account.UrlResourcePO) MenuItem(com.ibeiliao.deployment.admin.utils.resource.MenuItem)

Example 5 with MenuItem

use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.

the class EditRoleController method listAllAppMenu.

/**
 * 读取所有APP的菜单,及角色的菜单权限
 * @param roleId 角色ID
 * @return
 */
@MenuResource("读取角色菜单")
@RequestMapping("allAppMenus")
@ResponseBody
public Map<String, Object> listAllAppMenu(int roleId) {
    Map<String, Object> map = new HashMap<>(4);
    List<AppDefine> apps = appService.listAll();
    List<MenuItem> appMenus = new ArrayList<>(apps.size());
    for (AppDefine app : apps) {
        appMenus.add(menuService.getMenuTree(app.getAppId()));
    }
    map.put("success", Boolean.TRUE);
    map.put("appList", apps);
    map.put("appMenus", appMenus);
    if (roleId > 0) {
        List<RoleMenuRelation> menuIds = roleService.listRoleMenus(roleId);
        map.put("menuIds", menuIds);
        Role role = roleService.getById(roleId);
        map.put("role", role);
        List<RoleResRelation> resList = roleService.listRoleResources(roleId);
        map.put("resIds", resList);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MenuItem(com.ibeiliao.deployment.admin.utils.resource.MenuItem) Role(com.ibeiliao.deployment.admin.vo.account.Role) RoleResRelation(com.ibeiliao.deployment.admin.vo.account.RoleResRelation) AppDefine(com.ibeiliao.deployment.admin.vo.account.AppDefine) RoleMenuRelation(com.ibeiliao.deployment.admin.vo.account.RoleMenuRelation) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

MenuItem (com.ibeiliao.deployment.admin.utils.resource.MenuItem)13 MenuPO (com.ibeiliao.deployment.admin.po.account.MenuPO)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 RestResult (com.ibeiliao.deployment.admin.common.RestResult)1 UrlResourcePO (com.ibeiliao.deployment.admin.po.account.UrlResourcePO)1 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 AppDefine (com.ibeiliao.deployment.admin.vo.account.AppDefine)1 Role (com.ibeiliao.deployment.admin.vo.account.Role)1 RoleMenuRelation (com.ibeiliao.deployment.admin.vo.account.RoleMenuRelation)1 RoleResRelation (com.ibeiliao.deployment.admin.vo.account.RoleResRelation)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1