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();
}
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;
}
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;
}
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);
}
}
}
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;
}
Aggregations