| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(value = "角色管理控制器",tags = "角色管理控制器") |
| | | @RestController |
| | | @RequestMapping("/system/role") |
| | | public class SysRoleController extends BaseController { |
| | |
| | | @ApiOperation(value = "角色管理-分页列表", tags = "系统后台-权限管理") |
| | | public R<IPage<SysRolePageVO>> page(@RequestParam(value = "pageNum",defaultValue = "0")Integer pageNum, |
| | | @RequestParam(value = "pageSize",defaultValue="10")Integer pageSize, |
| | | @RequestParam(value = "name",required = false)String name) { |
| | | @RequestParam(value = "roleName",required = false)String name) { |
| | | IPage<SysRolePageVO> iPage = new Page<>(pageNum, pageSize); |
| | | return R.ok(roleService.page(iPage,name)); |
| | | } |
| | |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | | }*/ |
| | | @ApiOperation(value = "新增角色", notes = "系统后台-权限管理") |
| | | @ApiOperation(value = "新增角色", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @ApiOperation(value = "修改角色", notes = "系统后台-权限管理") |
| | | @ApiOperation(value = "修改角色", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PutMapping("/edit") |
| | | public R<Void> edit(@Valid @RequestBody EditSysRoleDTO dto) { |
| | | if (dto.getRoleId()==2){ |
| | | return R.fail("超级管理员不能修改"); |
| | | } |
| | | roleService.edit(dto); |
| | | // 更新缓存用户权限 |
| | | LoginUser loginUser = getLoginUser(); |
| | | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) { |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getPhonenumber())); |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| | | tokenService.setLoginUser(loginUser); |
| | | } |
| | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | @ApiOperation(value = "删除角色", notes = "系统后台-权限管理") |
| | | @ApiOperation(value = "删除角色", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleId}") |
| | | public R<Void> remove(@PathVariable Long roleId) { |
| | | if (roleId==2){ |
| | | return R.fail("超级管理员不能删除"); |
| | | } |
| | | roleService.deleteRoleById(roleId); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 查看详情 |
| | | */ |
| | | @ApiOperation(value = "查看详情", notes = "系统后台-权限管理") |
| | | @ApiOperation(value = "查看详情", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @GetMapping("/{roleId}") |
| | |
| | | /** |
| | | * 获取角色选择框列表 |
| | | */ |
| | | /* |
| | | @ApiOperation(value = "获取角色选择框列表", notes = "获取角色选择框列表") |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() { |
| | | return success(roleService.selectRoleAll()); |
| | | @ApiOperation(value = "账号管理-获取角色下拉框", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @GetMapping("/getOptionSelect") |
| | | public R<List<SysRoleVO>> getOptionSelect() { |
| | | return R.ok(roleService.getOptionSelect()); |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * 查询已分配用户角色列表 |