|
|
|
@ -33,12 +33,10 @@ import com.psdc.service.ISysRoleService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 角色信息 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@RestController |
|
|
|
|
@RequestMapping("/system/role") |
|
|
|
|
public class SysRoleController extends BaseController |
|
|
|
|
{ |
|
|
|
|
public class SysRoleController extends BaseController { |
|
|
|
|
@Autowired |
|
|
|
|
private ISysRoleService roleService; |
|
|
|
|
|
|
|
|
@ -52,11 +50,9 @@ public class SysRoleController extends BaseController |
|
|
|
|
private ISysUserService userService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:list')") |
|
|
|
|
@GetMapping("/list") |
|
|
|
|
public TableDataInfo list(SysRole role) |
|
|
|
|
{ |
|
|
|
|
public TableDataInfo list(SysRole role) { |
|
|
|
|
startPage(); |
|
|
|
|
List<SysRole> list = roleService.selectRoleList(role); |
|
|
|
|
return getDataTable(list); |
|
|
|
@ -65,8 +61,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT) |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:export')") |
|
|
|
|
@PostMapping("/export") |
|
|
|
|
public void export(HttpServletResponse response, SysRole role) |
|
|
|
|
{ |
|
|
|
|
public void export(HttpServletResponse response, SysRole role) { |
|
|
|
|
List<SysRole> list = roleService.selectRoleList(role); |
|
|
|
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
|
|
|
|
util.exportExcel(response, list, "角色数据"); |
|
|
|
@ -77,8 +72,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:query')") |
|
|
|
|
@GetMapping(value = "/{roleId}") |
|
|
|
|
public AjaxResult getInfo(@PathVariable Long roleId) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult getInfo(@PathVariable Long roleId) { |
|
|
|
|
roleService.checkRoleDataScope(roleId); |
|
|
|
|
return success(roleService.selectRoleById(roleId)); |
|
|
|
|
} |
|
|
|
@ -89,14 +83,10 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:add')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.INSERT) |
|
|
|
|
@PostMapping |
|
|
|
|
public AjaxResult add(@Validated @RequestBody SysRole role) |
|
|
|
|
{ |
|
|
|
|
if (!roleService.checkRoleNameUnique(role)) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult add(@Validated @RequestBody SysRole role) { |
|
|
|
|
if (!roleService.checkRoleNameUnique(role)) { |
|
|
|
|
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
|
|
|
|
} |
|
|
|
|
else if (!roleService.checkRoleKeyUnique(role)) |
|
|
|
|
{ |
|
|
|
|
} else if (!roleService.checkRoleKeyUnique(role)) { |
|
|
|
|
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
|
|
} |
|
|
|
|
role.setCreateBy(getUsername()); |
|
|
|
@ -110,26 +100,20 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
|
|
@PutMapping |
|
|
|
|
public AjaxResult edit(@Validated @RequestBody SysRole role) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult edit(@Validated @RequestBody SysRole role) { |
|
|
|
|
roleService.checkRoleAllowed(role); |
|
|
|
|
roleService.checkRoleDataScope(role.getRoleId()); |
|
|
|
|
if (!roleService.checkRoleNameUnique(role)) |
|
|
|
|
{ |
|
|
|
|
if (!roleService.checkRoleNameUnique(role)) { |
|
|
|
|
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
|
|
|
|
} |
|
|
|
|
else if (!roleService.checkRoleKeyUnique(role)) |
|
|
|
|
{ |
|
|
|
|
} else if (!roleService.checkRoleKeyUnique(role)) { |
|
|
|
|
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
|
|
} |
|
|
|
|
role.setUpdateBy(getUsername()); |
|
|
|
|
|
|
|
|
|
if (roleService.updateRole(role) > 0) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (roleService.updateRole(role) > 0) { |
|
|
|
|
// 更新缓存用户权限
|
|
|
|
|
LoginUser loginUser = getLoginUser(); |
|
|
|
|
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) |
|
|
|
|
{ |
|
|
|
|
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) { |
|
|
|
|
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
|
|
|
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
|
|
|
|
tokenService.setLoginUser(loginUser); |
|
|
|
@ -145,8 +129,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
|
|
@PutMapping("/dataScope") |
|
|
|
|
public AjaxResult dataScope(@RequestBody SysRole role) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult dataScope(@RequestBody SysRole role) { |
|
|
|
|
roleService.checkRoleAllowed(role); |
|
|
|
|
roleService.checkRoleDataScope(role.getRoleId()); |
|
|
|
|
return toAjax(roleService.authDataScope(role)); |
|
|
|
@ -158,8 +141,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
|
|
@PutMapping("/changeStatus") |
|
|
|
|
public AjaxResult changeStatus(@RequestBody SysRole role) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult changeStatus(@RequestBody SysRole role) { |
|
|
|
|
roleService.checkRoleAllowed(role); |
|
|
|
|
roleService.checkRoleDataScope(role.getRoleId()); |
|
|
|
|
role.setUpdateBy(getUsername()); |
|
|
|
@ -172,8 +154,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:remove')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE) |
|
|
|
|
@DeleteMapping("/{roleIds}") |
|
|
|
|
public AjaxResult remove(@PathVariable Long[] roleIds) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult remove(@PathVariable Long[] roleIds) { |
|
|
|
|
return toAjax(roleService.deleteRoleByIds(roleIds)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -182,8 +163,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:query')") |
|
|
|
|
@GetMapping("/optionselect") |
|
|
|
|
public AjaxResult optionselect() |
|
|
|
|
{ |
|
|
|
|
public AjaxResult optionselect() { |
|
|
|
|
return success(roleService.selectRoleAll()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -192,8 +172,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:list')") |
|
|
|
|
@GetMapping("/authUser/allocatedList") |
|
|
|
|
public TableDataInfo allocatedList(SysUser user) |
|
|
|
|
{ |
|
|
|
|
public TableDataInfo allocatedList(SysUser user) { |
|
|
|
|
startPage(); |
|
|
|
|
List<SysUser> list = userService.selectAllocatedList(user); |
|
|
|
|
return getDataTable(list); |
|
|
|
@ -204,8 +183,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
*/ |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:list')") |
|
|
|
|
@GetMapping("/authUser/unallocatedList") |
|
|
|
|
public TableDataInfo unallocatedList(SysUser user) |
|
|
|
|
{ |
|
|
|
|
public TableDataInfo unallocatedList(SysUser user) { |
|
|
|
|
startPage(); |
|
|
|
|
List<SysUser> list = userService.selectUnallocatedList(user); |
|
|
|
|
return getDataTable(list); |
|
|
|
@ -217,8 +195,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT) |
|
|
|
|
@PutMapping("/authUser/cancel") |
|
|
|
|
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) { |
|
|
|
|
return toAjax(roleService.deleteAuthUser(userRole)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -228,8 +205,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT) |
|
|
|
|
@PutMapping("/authUser/cancelAll") |
|
|
|
|
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) { |
|
|
|
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -239,8 +215,7 @@ public class SysRoleController extends BaseController |
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')") |
|
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT) |
|
|
|
|
@PutMapping("/authUser/selectAll") |
|
|
|
|
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
|
|
|
|
{ |
|
|
|
|
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) { |
|
|
|
|
roleService.checkRoleDataScope(roleId); |
|
|
|
|
return toAjax(roleService.insertAuthUsers(roleId, userIds)); |
|
|
|
|
} |
|
|
|
|