use of com.codingmore.webapi.ResultObject in project coding-more by itwanger.
the class UsersController method getAdminInfo.
@ApiOperation(value = "获取当前登录用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ResponseBody
public ResultObject getAdminInfo(Principal principal) {
if (principal == null) {
return ResultObject.unauthorized(null);
}
AdminUserDetails adminUserDetails = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Users user = adminUserDetails.getUsers();
// ?
user.setUserPass(null);
Map<String, Object> data = new HashMap<>();
data.put("userDetail", adminUserDetails.getUsers());
data.put("username", user.getUserLogin());
data.put("menus", roleService.getMenuList(user.getUsersId()));
data.put("icon", user.getDisplayName());
List<Role> roleList = usersService.getRoleList(user.getUsersId());
if (CollUtil.isNotEmpty(roleList)) {
List<String> roles = roleList.stream().map(Role::getName).collect(Collectors.toList());
data.put("roles", roles);
}
return ResultObject.success(data);
}
use of com.codingmore.webapi.ResultObject in project codingmore-learning by itwanger.
the class UsersController method getAdminInfo.
@ApiOperation(value = "获取当前登录用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ResponseBody
public ResultObject getAdminInfo(Principal principal) {
if (principal == null) {
return ResultObject.unauthorized(null);
}
String username = principal.getName();
Users users = usersService.getAdminByUsername(username);
Map<String, Object> data = new HashMap<>();
data.put("username", users.getUserLogin());
/* data.put("menus", roleService.getMenuList(umsAdmin.getId()));
data.put("icon", umsAdmin.getIcon());
List<UmsRole> roleList = usersService.getRoleList(umsAdmin.getId());
if(CollUtil.isNotEmpty(roleList)){
List<String> roles = roleList.stream().map(UmsRole::getName).collect(Collectors.toList());
data.put("roles",roles);
}*/
return ResultObject.success(data);
}
Aggregations