use of com.ibeiliao.deployment.admin.po.account.MenuPO in project Corgi by kevinYin.
the class MenuServiceImpl method gainHasPermissionMenu.
/**
* 获取有权限的菜单
*
* @param accountId
* @param menuList
* @return
*/
private List<MenuPO> gainHasPermissionMenu(long accountId, List<MenuPO> menuList) {
if (adminAccountService.isSuperAdmin(accountId)) {
return menuList;
}
// 读取角色
List<AccountRoleRelation> accountRoleList = adminAccountService.listAccountRoles(accountId);
List<RoleMenuRelation> roleMenuList = new LinkedList<>();
// 读取每个角色的菜单ID
for (AccountRoleRelation arr : accountRoleList) {
roleMenuList.addAll(roleService.listRoleMenus(arr.getRoleId()));
}
Set<Integer> accountMenuIdSet = new HashSet<>(roleMenuList.size());
for (RoleMenuRelation rmr : roleMenuList) {
accountMenuIdSet.add(Integer.valueOf(rmr.getMenuId()));
}
// 判断哪个菜单有权限
List<MenuPO> list = new LinkedList<>();
StringBuilder buf = new StringBuilder(1024);
for (MenuPO menuPO : menuList) {
if (accountMenuIdSet.contains(Integer.valueOf(menuPO.getMenuId()))) {
list.add(menuPO);
if (buf.length() > 0)
buf.append(" , ");
buf.append(menuPO.getMenuId()).append(": ").append(menuPO.getMenuName());
}
}
return list;
}
use of com.ibeiliao.deployment.admin.po.account.MenuPO in project Corgi by kevinYin.
the class MenuServiceImpl method listToBeDeletedMenu.
/**
* 获取待删除的菜单
*
* @param appId
* @param root
* @return
*/
private List<Menu> listToBeDeletedMenu(int appId, MenuItem root) {
List<Menu> menus = new ArrayList<>();
List<MenuPO> menuPOs = menuDao.listByAppId(appId);
Map<String, Boolean> menuMap = mapMenus(appId, root);
for (MenuPO menuPO : menuPOs) {
String key = menuPO.getAppId() + "_" + menuPO.getMenuName();
if (!menuMap.containsKey(key)) {
Menu menu = VOUtil.from(menuPO, Menu.class);
menus.add(menu);
}
}
return menus;
}
use of com.ibeiliao.deployment.admin.po.account.MenuPO 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.po.account.MenuPO 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.po.account.MenuPO 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);
}
}
}
Aggregations