|
@@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
|
|
|
|
|
|
import cc.iotkit.common.api.PageRequest;
|
|
|
import cc.iotkit.common.api.Paging;
|
|
|
+import cc.iotkit.common.api.Request;
|
|
|
import cc.iotkit.common.excel.utils.ExcelUtil;
|
|
|
import cc.iotkit.common.log.annotation.Log;
|
|
|
import cc.iotkit.common.log.enums.BusinessType;
|
|
@@ -17,6 +18,7 @@ import cc.iotkit.system.service.ISysDeptService;
|
|
|
import cc.iotkit.system.service.ISysRoleService;
|
|
|
import cc.iotkit.system.service.ISysUserService;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -42,8 +44,9 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 获取角色信息列表
|
|
|
*/
|
|
|
+ @ApiOperation(value = "获取角色信息列表", notes = "获取角色信息列表,根据查询条件分页")
|
|
|
@SaCheckPermission("system:role:list")
|
|
|
- @GetMapping("/list")
|
|
|
+ @PostMapping("/list")
|
|
|
public Paging<SysRoleVo> list(PageRequest<SysRoleBo> query) {
|
|
|
return roleService.selectPageRoleList(query);
|
|
|
}
|
|
@@ -52,10 +55,11 @@ public class SysRoleController extends BaseController {
|
|
|
* 导出角色信息列表
|
|
|
*/
|
|
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
|
|
+ @ApiOperation(value = "导出角色信息列表", notes = "导出角色信息列表")
|
|
|
@SaCheckPermission("system:role:export")
|
|
|
@PostMapping("/export")
|
|
|
- public void export(SysRoleBo role, HttpServletResponse response) {
|
|
|
- List<SysRoleVo> list = roleService.selectRoleList(role);
|
|
|
+ public void export(@RequestBody @Validated Request<SysRoleBo> role, HttpServletResponse response) {
|
|
|
+ List<SysRoleVo> list = roleService.selectRoleList(role.getData());
|
|
|
ExcelUtil.exportExcel(list, "角色数据", SysRoleVo.class, response);
|
|
|
}
|
|
|
|
|
@@ -64,8 +68,9 @@ public class SysRoleController extends BaseController {
|
|
|
*
|
|
|
* @param roleId 角色ID
|
|
|
*/
|
|
|
+ @ApiOperation(value = "根据角色编号获取详细信息", notes = "根据角色编号获取详细信息")
|
|
|
@SaCheckPermission("system:role:query")
|
|
|
- @GetMapping(value = "/{roleId}")
|
|
|
+ @PostMapping(value = "/{roleId}")
|
|
|
public SysRoleVo getInfo(@PathVariable Long roleId) {
|
|
|
roleService.checkRoleDataScope(roleId);
|
|
|
return roleService.selectRoleById(roleId);
|
|
@@ -74,10 +79,13 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 新增角色
|
|
|
*/
|
|
|
+ @ApiOperation(value = "新增角色", notes = "新增角色")
|
|
|
@SaCheckPermission("system:role:add")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public void add(@Validated @RequestBody SysRoleBo role) {
|
|
|
+ public void add(@Validated @RequestBody Request<SysRoleBo> bo) {
|
|
|
+ SysRoleBo role = bo.getData();
|
|
|
+
|
|
|
if (!roleService.checkRoleNameUnique(role)) {
|
|
|
fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
|
|
} else if (!roleService.checkRoleKeyUnique(role)) {
|
|
@@ -90,10 +98,13 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 修改保存角色
|
|
|
*/
|
|
|
+ @ApiOperation(value = "修改保存角色", notes = "修改保存角色")
|
|
|
@SaCheckPermission("system:role:edit")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
- public void edit(@Validated @RequestBody SysRoleBo role) {
|
|
|
+ @PostMapping
|
|
|
+ public void edit(@Validated @RequestBody Request<SysRoleBo> bo) {
|
|
|
+ SysRoleBo role = bo.getData();
|
|
|
+
|
|
|
roleService.checkRoleAllowed(role.getRoleId());
|
|
|
roleService.checkRoleDataScope(role.getRoleId());
|
|
|
if (!roleService.checkRoleNameUnique(role)) {
|
|
@@ -111,10 +122,12 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 修改保存数据权限
|
|
|
*/
|
|
|
+ @ApiOperation(value = "修改保存数据权限", notes = "修改保存数据权限")
|
|
|
@SaCheckPermission("system:role:edit")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/dataScope")
|
|
|
- public void dataScope(@RequestBody SysRoleBo role) {
|
|
|
+ @PostMapping("/dataScope")
|
|
|
+ public void dataScope(@RequestBody Request<SysRoleBo> bo) {
|
|
|
+ SysRoleBo role = bo.getData();
|
|
|
roleService.checkRoleAllowed(role.getRoleId());
|
|
|
roleService.checkRoleDataScope(role.getRoleId());
|
|
|
roleService.authDataScope(role);
|
|
@@ -123,9 +136,10 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 状态修改
|
|
|
*/
|
|
|
+ @ApiOperation(value = "状态修改", notes = "状态修改")
|
|
|
@SaCheckPermission("system:role:edit")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/changeStatus")
|
|
|
+ @PostMapping("/changeStatus")
|
|
|
public void changeStatus(@RequestBody SysRoleBo role) {
|
|
|
roleService.checkRoleAllowed(role.getRoleId());
|
|
|
roleService.checkRoleDataScope(role.getRoleId());
|
|
@@ -135,20 +149,22 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 删除角色
|
|
|
*
|
|
|
- * @param roleIds 角色ID串
|
|
|
+
|
|
|
*/
|
|
|
+ @ApiOperation(value = "删除角色", notes = "删除角色")
|
|
|
@SaCheckPermission("system:role:remove")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{roleIds}")
|
|
|
- public void remove(@PathVariable Long[] roleIds) {
|
|
|
- roleService.deleteRoleByIds(roleIds);
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public void remove(@Validated @RequestBody Request<List<Long>> bo) {
|
|
|
+ roleService.deleteRoleByIds(bo.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取角色选择框列表
|
|
|
*/
|
|
|
+ @ApiOperation(value = "获取角色选择框列表", notes = "获取角色选择框列表")
|
|
|
@SaCheckPermission("system:role:query")
|
|
|
- @GetMapping("/optionselect")
|
|
|
+ @PostMapping("/optionselect")
|
|
|
public List<SysRoleVo> optionselect() {
|
|
|
return roleService.selectRoleAll();
|
|
|
}
|
|
@@ -156,29 +172,32 @@ public class SysRoleController extends BaseController {
|
|
|
/**
|
|
|
* 查询已分配用户角色列表
|
|
|
*/
|
|
|
+ @ApiOperation(value = "查询已分配用户角色列表", notes = "查询已分配用户角色列表")
|
|
|
@SaCheckPermission("system:role:list")
|
|
|
- @GetMapping("/authUser/allocatedList")
|
|
|
- public Paging<SysUserVo> allocatedList(SysUserBo user, PageRequest<?> query) {
|
|
|
- return userService.selectAllocatedList(user, query);
|
|
|
+ @PostMapping("/authUser/allocatedList")
|
|
|
+ public Paging<SysUserVo> allocatedList(Request<SysUserBo> bo, PageRequest<?> query) {
|
|
|
+ return userService.selectAllocatedList(bo.getData(), query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询未分配用户角色列表
|
|
|
*/
|
|
|
+ @ApiOperation(value = "查询未分配用户角色列表", notes = "查询未分配用户角色列表")
|
|
|
@SaCheckPermission("system:role:list")
|
|
|
- @GetMapping("/authUser/unallocatedList")
|
|
|
- public Paging<SysUserVo> unallocatedList(SysUserBo user, PageRequest<?> query) {
|
|
|
- return userService.selectUnallocatedList(user, query);
|
|
|
+ @PostMapping("/authUser/unallocatedList")
|
|
|
+ public Paging<SysUserVo> unallocatedList(Request<SysUserBo> bo, PageRequest<?> query) {
|
|
|
+ return userService.selectUnallocatedList(bo.getData(), query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消授权用户
|
|
|
*/
|
|
|
+ @ApiOperation(value = "取消授权用户", notes = "取消授权用户")
|
|
|
@SaCheckPermission("system:role:edit")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
|
- @PutMapping("/authUser/cancel")
|
|
|
- public void cancelAuthUser(@RequestBody SysUserRole userRole) {
|
|
|
- roleService.deleteAuthUser(userRole);
|
|
|
+ @PostMapping("/authUser/cancel")
|
|
|
+ public void cancelAuthUser(@RequestBody Request<SysUserRole> bo) {
|
|
|
+ roleService.deleteAuthUser(bo.getData());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,9 +206,10 @@ public class SysRoleController extends BaseController {
|
|
|
* @param roleId 角色ID
|
|
|
* @param userIds 用户ID串
|
|
|
*/
|
|
|
+ @ApiOperation(value = "批量取消授权用户", notes = "批量取消授权用户")
|
|
|
@SaCheckPermission("system:role:edit")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
|
- @PutMapping("/authUser/cancelAll")
|
|
|
+ @PostMapping("/authUser/cancelAll")
|
|
|
public void cancelAuthUserAll(Long roleId, Long[] userIds) {
|
|
|
roleService.deleteAuthUsers(roleId, userIds);
|
|
|
}
|
|
@@ -200,9 +220,10 @@ public class SysRoleController extends BaseController {
|
|
|
* @param roleId 角色ID
|
|
|
* @param userIds 用户ID串
|
|
|
*/
|
|
|
+ @ApiOperation(value = "批量选择用户授权", notes = "批量选择用户授权")
|
|
|
@SaCheckPermission("system:role:edit")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
|
- @PutMapping("/authUser/selectAll")
|
|
|
+ @PostMapping("/authUser/selectAll")
|
|
|
public void selectAuthUserAll(Long roleId, Long[] userIds) {
|
|
|
roleService.checkRoleDataScope(roleId);
|
|
|
roleService.insertAuthUsers(roleId, userIds);
|
|
@@ -213,8 +234,9 @@ public class SysRoleController extends BaseController {
|
|
|
*
|
|
|
* @param roleId 角色ID
|
|
|
*/
|
|
|
+ @ApiOperation(value = "获取对应角色部门树列表", notes = "获取对应角色部门树列表")
|
|
|
@SaCheckPermission("system:role:list")
|
|
|
- @GetMapping(value = "/deptTree/{roleId}")
|
|
|
+ @PostMapping(value = "/deptTree/{roleId}")
|
|
|
public DeptTreeSelectVo roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
|
|
DeptTreeSelectVo selectVo = new DeptTreeSelectVo();
|
|
|
selectVo.setCheckedKeys(deptService.selectDeptListByRoleId(roleId));
|