use of com.ibeiliao.deployment.admin.vo.account.RoleMenuRelation 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.vo.account.RoleMenuRelation 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