use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud-Oracle by yangzongzhuan.
the class SysUserController method getInfo.
/**
* 获取用户信息
*
* @return 用户信息
*/
@GetMapping("getInfo")
public AjaxResult getInfo() {
Long userId = SecurityUtils.getUserId();
// 角色集合
Set<String> roles = permissionService.getRolePermission(userId);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(userId);
AjaxResult ajax = AjaxResult.success();
ajax.put("user", userService.selectUserById(userId));
ajax.put("roles", roles);
ajax.put("permissions", permissions);
return ajax;
}
use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud-Oracle by yangzongzhuan.
the class SysUserController method getInfo.
/**
* 根据用户编号获取详细信息
*/
@RequiresPermissions("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId)) {
SysUser sysUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
}
return ajax;
}
use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud by yangzongzhuan.
the class SysMenuController method roleMenuTreeselect.
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuList(userId);
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud by yangzongzhuan.
the class SysProfileController method avatar.
/**
* 头像上传
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
if (!file.isEmpty()) {
LoginUser loginUser = SecurityUtils.getLoginUser();
R<SysFile> fileResult = remoteFileService.upload(file);
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData())) {
return AjaxResult.error("文件服务异常,请联系管理员");
}
String url = fileResult.getData().getUrl();
if (userService.updateUserAvatar(loginUser.getUsername(), url)) {
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", url);
// 更新缓存用户头像
loginUser.getSysUser().setAvatar(url);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
return AjaxResult.error("上传图片异常,请联系管理员");
}
use of com.ruoyi.common.core.web.domain.AjaxResult in project RuoYi-Cloud by yangzongzhuan.
the class SysUserController method getInfo.
/**
* 获取用户信息
*
* @return 用户信息
*/
@GetMapping("getInfo")
public AjaxResult getInfo() {
Long userId = SecurityUtils.getUserId();
// 角色集合
Set<String> roles = permissionService.getRolePermission(userId);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(userId);
AjaxResult ajax = AjaxResult.success();
ajax.put("user", userService.selectUserById(userId));
ajax.put("roles", roles);
ajax.put("permissions", permissions);
return ajax;
}
Aggregations