use of com.github.liuweijw.business.admin.beans.UserBean in project fw-cloud-framework by liuweijw.
the class UserServiceImpl method findUserInfo.
@Override
public UserBean findUserInfo(AuthUser user) {
User dbUser = findUserByUsername(user.getUsername(), false);
UserBean userInfo = new UserBean();
// 过滤关键信息
dbUser.setPassword("");
dbUser.setCreateTime(null);
dbUser.setUpdateTime(null);
userInfo.setUser(dbUser);
// 设置角色列表
List<AuthRole> roleList = user.getRoleList();
List<String> roleCodes = new ArrayList<>();
roleList.stream().forEach(r -> {
roleCodes.add(r.getRoleCode());
});
String[] roles = roleCodes.toArray(new String[roleCodes.size()]);
userInfo.setRoles(roles);
// 设置权限列表(menu.permission)
Set<String> permissions = new HashSet<String>();
for (String roleCode : roles) {
permissions.addAll(menuService.findMenuPermissions(roleCode));
}
userInfo.setPermissions(permissions.toArray(new String[permissions.size()]));
return userInfo;
}
Aggregations