Search in sources :

Example 1 with SaCheckPermission

use of cn.dev33.satoken.annotation.SaCheckPermission in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysRoleController method edit.

/**
 * 修改保存角色
 */
@ApiOperation("修改保存角色")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public R<Void> edit(@Validated @RequestBody SysRole role) {
    roleService.checkRoleAllowed(role);
    roleService.checkRoleDataScope(role.getRoleId());
    if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
        return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
    } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
        return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
    }
    if (roleService.updateRole(role) > 0) {
        // 更新缓存用户权限
        LoginUser loginUser = getLoginUser();
        SysUser sysUser = userService.selectUserById(loginUser.getUserId());
        if (ObjectUtil.isNotNull(sysUser) && !sysUser.isAdmin()) {
            loginUser.setMenuPermission(permissionService.getMenuPermission(sysUser));
            LoginHelper.setLoginUser(loginUser);
        }
        return R.ok();
    }
    return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) Log(com.ruoyi.common.annotation.Log) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 2 with SaCheckPermission

use of cn.dev33.satoken.annotation.SaCheckPermission in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@ApiOperation("根据用户编号获取详细信息")
@SaCheckPermission("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public R<Map<String, Object>> getInfo(@ApiParam("用户ID") @PathVariable(value = "userId", required = false) Long userId) {
    userService.checkUserDataScope(userId);
    Map<String, Object> ajax = new HashMap<>();
    List<SysRole> roles = roleService.selectRoleAll();
    ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    ajax.put("posts", postService.selectPostAll());
    if (ObjectUtil.isNotNull(userId)) {
        SysUser sysUser = userService.selectUserById(userId);
        ajax.put("user", sysUser);
        ajax.put("postIds", postService.selectPostListByUserId(userId));
        ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
    }
    return R.ok(ajax);
}
Also used : R(com.ruoyi.common.core.domain.R) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) HashMap(java.util.HashMap) BeanUtil(cn.hutool.core.bean.BeanUtil) PageQuery(com.ruoyi.common.core.domain.PageQuery) ArrayList(java.util.ArrayList) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) StringUtils(com.ruoyi.common.utils.StringUtils) Map(java.util.Map) ISysRoleService(com.ruoyi.system.service.ISysRoleService) io.swagger.annotations(io.swagger.annotations) BaseController(com.ruoyi.common.core.controller.BaseController) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoginHelper(com.ruoyi.common.helper.LoginHelper) Collectors(java.util.stream.Collectors) BusinessType(com.ruoyi.common.enums.BusinessType) ISysUserService(com.ruoyi.system.service.ISysUserService) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) ArrayUtil(cn.hutool.core.util.ArrayUtil) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) ExcelResult(com.ruoyi.common.excel.ExcelResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) SysRole(com.ruoyi.common.core.domain.entity.SysRole) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 3 with SaCheckPermission

use of cn.dev33.satoken.annotation.SaCheckPermission in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@ApiOperation("根据用户编号获取授权角色")
@SaCheckPermission("system:user:query")
@GetMapping("/authRole/{userId}")
public R<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") Long userId) {
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    Map<String, Object> ajax = new HashMap<>();
    ajax.put("user", user);
    ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    return R.ok(ajax);
}
Also used : R(com.ruoyi.common.core.domain.R) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) HashMap(java.util.HashMap) BeanUtil(cn.hutool.core.bean.BeanUtil) PageQuery(com.ruoyi.common.core.domain.PageQuery) ArrayList(java.util.ArrayList) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) StringUtils(com.ruoyi.common.utils.StringUtils) Map(java.util.Map) ISysRoleService(com.ruoyi.system.service.ISysRoleService) io.swagger.annotations(io.swagger.annotations) BaseController(com.ruoyi.common.core.controller.BaseController) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoginHelper(com.ruoyi.common.helper.LoginHelper) Collectors(java.util.stream.Collectors) BusinessType(com.ruoyi.common.enums.BusinessType) ISysUserService(com.ruoyi.system.service.ISysUserService) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) ArrayUtil(cn.hutool.core.util.ArrayUtil) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) ExcelResult(com.ruoyi.common.excel.ExcelResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) SysRole(com.ruoyi.common.core.domain.entity.SysRole) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 4 with SaCheckPermission

use of cn.dev33.satoken.annotation.SaCheckPermission in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysDeptController method excludeChild.

/**
 * 查询部门列表(排除节点)
 */
@ApiOperation("查询部门列表(排除节点)")
@SaCheckPermission("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public R<List<SysDept>> excludeChild(@ApiParam("部门ID") @PathVariable(value = "deptId", required = false) Long deptId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    depts.removeIf(d -> d.getDeptId().equals(deptId) || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
    return R.ok(depts);
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 5 with SaCheckPermission

use of cn.dev33.satoken.annotation.SaCheckPermission in project RuoYi-Flowable-Plus by KonBAI-Q.

the class GenController method getInfo.

/**
 * 修改代码生成业务
 */
@ApiOperation("修改代码生成业务")
@SaCheckPermission("tool:gen:query")
@GetMapping(value = "/{tableId}")
public R<Map<String, Object>> getInfo(@PathVariable Long tableId) {
    GenTable table = genTableService.selectGenTableById(tableId);
    List<GenTable> tables = genTableService.selectGenTableAll();
    List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("info", table);
    map.put("rows", list);
    map.put("tables", tables);
    return R.ok(map);
}
Also used : GenTable(com.ruoyi.generator.domain.GenTable) HashMap(java.util.HashMap) GenTableColumn(com.ruoyi.generator.domain.GenTableColumn) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Aggregations

SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)30 ApiOperation (io.swagger.annotations.ApiOperation)15 Log (com.ruoyi.common.annotation.Log)10 HashMap (java.util.HashMap)10 SysUserExportVo (com.ruoyi.system.domain.vo.SysUserExportVo)9 SysDept (com.ruoyi.common.core.domain.entity.SysDept)8 SysUser (com.ruoyi.common.core.domain.entity.SysUser)8 BCrypt (cn.dev33.satoken.secure.BCrypt)6 BeanUtil (cn.hutool.core.bean.BeanUtil)6 ObjectUtil (cn.hutool.core.util.ObjectUtil)6 R (com.ruoyi.common.core.domain.R)6 SysUserImportVo (com.ruoyi.system.domain.vo.SysUserImportVo)6 SysUserImportListener (com.ruoyi.system.listener.SysUserImportListener)6 ISysPostService (com.ruoyi.system.service.ISysPostService)6 ISysRoleService (com.ruoyi.system.service.ISysRoleService)6 ISysUserService (com.ruoyi.system.service.ISysUserService)6 Collectors (java.util.stream.Collectors)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 RequiredArgsConstructor (lombok.RequiredArgsConstructor)6 Validated (org.springframework.validation.annotation.Validated)6