use of com.albedo.java.modules.sys.domain.vo.UserInfo in project albedo by somowhere.
the class UserServiceImpl method getInfo.
/**
* 通过查用户的全部信息
*
* @param userVo 用户
* @return
*/
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public UserInfo getInfo(UserVo userVo) {
UserInfo userInfo = new UserInfo();
userInfo.setUser(userVo);
List<RoleDo> roleDos = roleService.findListByUserId(userVo.getId());
// 设置角色列表 (ID)
List<Long> roleIds = roleDos.stream().map(RoleDo::getId).collect(Collectors.toList());
userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class));
// 设置权限列表(menu.permission)
Set<String> permissions = new HashSet<>();
roleIds.forEach(roleId -> {
List<String> permissionList = menuService.findListByRoleId(roleId).stream().filter(menuVo -> StringUtil.isNotEmpty(menuVo.getPermission())).map(MenuVo::getPermission).collect(Collectors.toList());
permissions.addAll(permissionList);
});
userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class));
return userInfo;
}
Aggregations