Search in sources :

Example 1 with InnerAuth

use of com.ruoyi.common.security.annotation.InnerAuth in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysUserController method info.

/**
 * 获取当前用户信息
 */
@InnerAuth
@GetMapping("/info/{username}")
public R<LoginUser> info(@PathVariable("username") String username) {
    SysUser sysUser = userService.selectUserByUserName(username);
    if (StringUtils.isNull(sysUser)) {
        return R.fail("用户名或密码错误");
    }
    // 角色集合
    Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
    // 权限集合
    Set<String> permissions = permissionService.getMenuPermission(sysUser.getUserId());
    LoginUser sysUserVo = new LoginUser();
    sysUserVo.setSysUser(sysUser);
    sysUserVo.setRoles(roles);
    sysUserVo.setPermissions(permissions);
    return R.ok(sysUserVo);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) LoginUser(com.ruoyi.system.api.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping) InnerAuth(com.ruoyi.common.security.annotation.InnerAuth)

Example 2 with InnerAuth

use of com.ruoyi.common.security.annotation.InnerAuth in project RuoYi-Cloud by yangzongzhuan.

the class SysUserController method info.

/**
 * 获取当前用户信息
 */
@InnerAuth
@GetMapping("/info/{username}")
public R<LoginUser> info(@PathVariable("username") String username) {
    SysUser sysUser = userService.selectUserByUserName(username);
    if (StringUtils.isNull(sysUser)) {
        return R.fail("用户名或密码错误");
    }
    // 角色集合
    Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
    // 权限集合
    Set<String> permissions = permissionService.getMenuPermission(sysUser.getUserId());
    LoginUser sysUserVo = new LoginUser();
    sysUserVo.setSysUser(sysUser);
    sysUserVo.setRoles(roles);
    sysUserVo.setPermissions(permissions);
    return R.ok(sysUserVo);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) LoginUser(com.ruoyi.system.api.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping) InnerAuth(com.ruoyi.common.security.annotation.InnerAuth)

Aggregations

InnerAuth (com.ruoyi.common.security.annotation.InnerAuth)2 SysUser (com.ruoyi.system.api.domain.SysUser)2 LoginUser (com.ruoyi.system.api.model.LoginUser)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2