use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class UacRoleServiceImpl method getActionTreeByRoleId.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public BindAuthVo getActionTreeByRoleId(Long roleId) {
BindAuthVo bindAuthVo = new BindAuthVo();
if (roleId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10012001);
}
UacRole roleById = this.getRoleById(roleId);
if (roleById == null) {
logger.error("找不到角色信息 roleId={}", roleId);
throw new UacBizException(ErrorCodeEnum.UAC10012005, roleId);
}
List<UacMenu> uacMenus = uacMenuService.listMenuListByRoleId(roleId);
if (PublicUtil.isEmpty(uacMenus)) {
throw new UacBizException(ErrorCodeEnum.UAC10013009);
}
// 查询所有的权限信息
List<UacAction> uacActions = uacActionService.listActionList(uacMenus);
// 合并菜单和按钮权限 递归生成树结构
List<MenuVo> menuVoList = this.getAuthList(uacMenus, uacActions);
List<MenuVo> tree = TreeUtil.getChildMenuVos(menuVoList, 0L);
// 获取所有绑定的菜单和按钮权限Id集合
List<Long> checkedAuthList = uacActionService.getCheckedActionList(roleId);
bindAuthVo.setAuthTree(tree);
bindAuthVo.setCheckedAuthList(checkedAuthList);
return bindAuthVo;
}
use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class TreeUtil method getChildMenuVos.
/**
* 根据父节点的ID获取所有子节点
*
* @param list 具有树形结构特点的集合
* @param parentId 父节点ID
*
* @return 树形结构集合 child menu vos
*/
public static List<MenuVo> getChildMenuVos(List<MenuVo> list, Long parentId) {
List<MenuVo> returnList = Lists.newArrayList();
for (MenuVo menuVo : list) {
if (menuVo.getPid() == null) {
continue;
}
if (Objects.equals(menuVo.getPid(), parentId)) {
recursionFn(list, menuVo);
returnList.add(menuVo);
}
}
return returnList;
}
use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class TreeUtil method recursionFn.
/**
* 递归列表
*/
private static void recursionFn(List<MenuVo> list, MenuVo t) {
// 得到子节点列表
List<MenuVo> childList = getChildList(list, t);
t.setSubMenu(childList);
if (PublicUtil.isNotEmpty(childList)) {
t.setHasMenu(true);
}
for (MenuVo tChild : childList) {
// 判断是否有子节点
if (hasChild(list, tChild)) {
for (MenuVo n : childList) {
recursionFn(list, n);
}
tChild.setHasMenu(true);
}
}
}
Aggregations