Search in sources :

Example 1 with AjaxResult

use of com.ruoyi.framework.web.domain.AjaxResult in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysProfileController method profile.

/**
 * 个人信息
 */
@GetMapping
public AjaxResult profile() {
    LoginUser loginUser = getLoginUser();
    SysUser user = loginUser.getUser();
    AjaxResult ajax = AjaxResult.success(user);
    ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
    ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) SysUser(com.ruoyi.project.system.domain.SysUser) LoginUser(com.ruoyi.framework.security.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with AjaxResult

use of com.ruoyi.framework.web.domain.AjaxResult in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@PreAuthorize("@ss.hasPermi('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;
}
Also used : SysUser(com.ruoyi.project.system.domain.SysUser) PathVariable(org.springframework.web.bind.annotation.PathVariable) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ArrayUtils(org.apache.commons.lang3.ArrayUtils) TableDataInfo(com.ruoyi.framework.web.page.TableDataInfo) ISysRoleService(com.ruoyi.project.system.service.ISysRoleService) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) ISysPostService(com.ruoyi.project.system.service.ISysPostService) RequestBody(org.springframework.web.bind.annotation.RequestBody) AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) StringUtils(com.ruoyi.common.utils.StringUtils) PutMapping(org.springframework.web.bind.annotation.PutMapping) SecurityUtils(com.ruoyi.common.utils.SecurityUtils) GetMapping(org.springframework.web.bind.annotation.GetMapping) SysRole(com.ruoyi.project.system.domain.SysRole) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ISysUserService(com.ruoyi.project.system.service.ISysUserService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) BaseController(com.ruoyi.framework.web.controller.BaseController) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) MultipartFile(org.springframework.web.multipart.MultipartFile) BusinessType(com.ruoyi.framework.aspectj.lang.enums.BusinessType) AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) SysUser(com.ruoyi.project.system.domain.SysUser) SysRole(com.ruoyi.project.system.domain.SysRole) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with AjaxResult

use of com.ruoyi.framework.web.domain.AjaxResult in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId) {
    AjaxResult ajax = AjaxResult.success();
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    ajax.put("user", user);
    ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    return ajax;
}
Also used : SysUser(com.ruoyi.project.system.domain.SysUser) PathVariable(org.springframework.web.bind.annotation.PathVariable) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ArrayUtils(org.apache.commons.lang3.ArrayUtils) TableDataInfo(com.ruoyi.framework.web.page.TableDataInfo) ISysRoleService(com.ruoyi.project.system.service.ISysRoleService) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) ISysPostService(com.ruoyi.project.system.service.ISysPostService) RequestBody(org.springframework.web.bind.annotation.RequestBody) AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) StringUtils(com.ruoyi.common.utils.StringUtils) PutMapping(org.springframework.web.bind.annotation.PutMapping) SecurityUtils(com.ruoyi.common.utils.SecurityUtils) GetMapping(org.springframework.web.bind.annotation.GetMapping) SysRole(com.ruoyi.project.system.domain.SysRole) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ISysUserService(com.ruoyi.project.system.service.ISysUserService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) BaseController(com.ruoyi.framework.web.controller.BaseController) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) MultipartFile(org.springframework.web.multipart.MultipartFile) BusinessType(com.ruoyi.framework.aspectj.lang.enums.BusinessType) AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) SysUser(com.ruoyi.project.system.domain.SysUser) SysRole(com.ruoyi.project.system.domain.SysRole) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with AjaxResult

use of com.ruoyi.framework.web.domain.AjaxResult in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysLoginController method getInfo.

/**
 * 获取用户信息
 *
 * @return 用户信息
 */
@GetMapping("getInfo")
public AjaxResult getInfo() {
    SysUser user = SecurityUtils.getLoginUser().getUser();
    // 角色集合
    Set<String> roles = permissionService.getRolePermission(user);
    // 权限集合
    Set<String> permissions = permissionService.getMenuPermission(user);
    AjaxResult ajax = AjaxResult.success();
    ajax.put("user", user);
    ajax.put("roles", roles);
    ajax.put("permissions", permissions);
    return ajax;
}
Also used : AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) SysUser(com.ruoyi.project.system.domain.SysUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with AjaxResult

use of com.ruoyi.framework.web.domain.AjaxResult in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysMenuController method roleMenuTreeselect.

/**
 * 加载对应角色菜单列表树
 */
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
    List<SysMenu> menus = menuService.selectMenuList(getUserId());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
    ajax.put("menus", menuService.buildMenuTreeSelect(menus));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) SysMenu(com.ruoyi.project.system.domain.SysMenu) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

AjaxResult (com.ruoyi.framework.web.domain.AjaxResult)26 GetMapping (org.springframework.web.bind.annotation.GetMapping)16 PostMapping (org.springframework.web.bind.annotation.PostMapping)12 SysUser (com.ruoyi.project.system.domain.SysUser)8 StringUtils (com.ruoyi.common.utils.StringUtils)6 Log (com.ruoyi.framework.aspectj.lang.annotation.Log)6 List (java.util.List)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 RestController (org.springframework.web.bind.annotation.RestController)6 MultipartFile (org.springframework.web.multipart.MultipartFile)6 UserConstants (com.ruoyi.common.constant.UserConstants)4 SecurityUtils (com.ruoyi.common.utils.SecurityUtils)4 ExcelUtil (com.ruoyi.common.utils.poi.ExcelUtil)4 BusinessType (com.ruoyi.framework.aspectj.lang.enums.BusinessType)4 LoginUser (com.ruoyi.framework.security.LoginUser)4 BaseController (com.ruoyi.framework.web.controller.BaseController)4 TableDataInfo (com.ruoyi.framework.web.page.TableDataInfo)4 SysRole (com.ruoyi.project.system.domain.SysRole)4