|
|
@@ -1,10 +1,12 @@
|
|
|
package com.xunmei.system.controller;
|
|
|
|
|
|
+import com.xunmei.common.core.domain.R;
|
|
|
import com.xunmei.common.core.web.controller.BaseController;
|
|
|
import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.log.annotation.Log;
|
|
|
import com.xunmei.common.log.enums.BusinessType;
|
|
|
+import com.xunmei.common.security.annotation.InnerAuth;
|
|
|
import com.xunmei.common.security.annotation.RequiresPermissions;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.system.api.domain.SysDept;
|
|
|
@@ -29,8 +31,7 @@ import java.util.List;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/role")
|
|
|
-public class SysRoleController extends BaseController
|
|
|
-{
|
|
|
+public class SysRoleController extends BaseController {
|
|
|
@Autowired
|
|
|
private ISysRoleService roleService;
|
|
|
|
|
|
@@ -48,14 +49,12 @@ public class SysRoleController extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 根据角色编号获取详细信息
|
|
|
*/
|
|
|
@RequiresPermissions("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));
|
|
|
}
|
|
|
@@ -66,14 +65,10 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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(SecurityUtils.getUsername());
|
|
|
@@ -87,16 +82,12 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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.getId());
|
|
|
- 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(SecurityUtils.getUsername());
|
|
|
@@ -109,8 +100,7 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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.getId());
|
|
|
return toAjax(roleService.authDataScope(role));
|
|
|
@@ -122,8 +112,7 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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.getId());
|
|
|
role.setUpdateBy(SecurityUtils.getUsername());
|
|
|
@@ -136,8 +125,7 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("system:role:remove")
|
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(roleService.deleteRoleByIds(ids));
|
|
|
}
|
|
|
|
|
|
@@ -146,17 +134,16 @@ public class SysRoleController extends BaseController
|
|
|
*/
|
|
|
@RequiresPermissions("system:role:query")
|
|
|
@GetMapping("/optionselect")
|
|
|
- public AjaxResult optionselect()
|
|
|
- {
|
|
|
+ public AjaxResult optionselect() {
|
|
|
return success(roleService.selectRoleAll());
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询已分配用户角色列表
|
|
|
*/
|
|
|
@RequiresPermissions("system:role:list")
|
|
|
@GetMapping("/authUser/allocatedList")
|
|
|
- public TableDataInfo allocatedList(SysUserVO user)
|
|
|
- {
|
|
|
+ public TableDataInfo allocatedList(SysUserVO user) {
|
|
|
return userService.selectAllocatedList(user);
|
|
|
}
|
|
|
|
|
|
@@ -165,8 +152,7 @@ public class SysRoleController extends BaseController
|
|
|
*/
|
|
|
@RequiresPermissions("system:role:list")
|
|
|
@GetMapping("/authUser/unallocatedList")
|
|
|
- public TableDataInfo unallocatedList(SysUserVO user)
|
|
|
- {
|
|
|
+ public TableDataInfo unallocatedList(SysUserVO user) {
|
|
|
return userService.selectUnallocatedList(user);
|
|
|
}
|
|
|
|
|
|
@@ -176,8 +162,7 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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));
|
|
|
}
|
|
|
|
|
|
@@ -187,8 +172,7 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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));
|
|
|
}
|
|
|
|
|
|
@@ -198,8 +182,7 @@ public class SysRoleController extends BaseController
|
|
|
@RequiresPermissions("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));
|
|
|
}
|
|
|
@@ -209,8 +192,7 @@ public class SysRoleController extends BaseController
|
|
|
*/
|
|
|
@RequiresPermissions("system:role:query")
|
|
|
@GetMapping(value = "/deptTree/{roleId}")
|
|
|
- public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
|
|
|
- {
|
|
|
+ public AjaxResult deptTree(@PathVariable("roleId") Long roleId) {
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
|
|
ajax.put("depts", deptService.selectDeptTreeList(new SysOrg()));
|
|
|
@@ -221,7 +203,14 @@ public class SysRoleController extends BaseController
|
|
|
* 获取所有可用的角色信息
|
|
|
*/
|
|
|
@GetMapping(value = "/all")
|
|
|
- public AjaxResult all(){
|
|
|
+ public AjaxResult all() {
|
|
|
return success(roleService.selectSimpleRoleAll());
|
|
|
}
|
|
|
+
|
|
|
+ @InnerAuth
|
|
|
+ @GetMapping(value = "/getRoleById")
|
|
|
+ public R<SysRole> getRoleById(Long id) {
|
|
|
+ SysRole byId = roleService.getById(id);
|
|
|
+ return R.ok(byId);
|
|
|
+ }
|
|
|
}
|