From f72e5445beea756fccf5264e6fb4d0f533840bff Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: 星期四, 04 十二月 2025 14:53:08 +0800
Subject: [PATCH] 修改必填
---
multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysRoleController.java | 75 +++++++++++++++++++++++++++----------
1 files changed, 55 insertions(+), 20 deletions(-)
diff --git a/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysRoleController.java b/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysRoleController.java
index 61a8061..cb34f51 100644
--- a/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysRoleController.java
+++ b/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysRoleController.java
@@ -10,11 +10,16 @@
import com.gkhy.exam.common.domain.model.LoginUser;
import com.gkhy.exam.common.domain.model.LoginUserDetails;
import com.gkhy.exam.common.enums.BusinessType;
+import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.framework.web.service.SysPermissionService;
import com.gkhy.exam.framework.web.service.TokenService;
import com.gkhy.exam.system.domain.SysUserRole;
import com.gkhy.exam.system.service.ISysRoleService;
import com.gkhy.exam.system.service.SysUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -34,6 +39,7 @@
*
* @author expert
*/
+@Api(tags = "角色信息")
@RestController
@RequestMapping("/system/role")
public class SysRoleController
@@ -53,8 +59,9 @@
// @Autowired
// private ISysDeptService deptService;
- @PreAuthorize("@ss.hasPermi('system:role:list')")
+ // @PreAuthorize("hasAnyAuthority('system:role:list')")
@GetMapping("/list")
+ @ApiOperation(value = "获取角色列表")
public CommonResult list(SysRole role)
{
@@ -62,7 +69,7 @@
}
// @Log(title = "角色管理", businessType = BusinessType.EXPORT)
-// @PreAuthorize("@ss.hasPermi('system:role:export')")
+// @PreAuthorize("hasAnyAuthority('system:role:export')")
// @PostMapping("/export")
// public void export(HttpServletResponse response, SysRole role)
// {
@@ -74,8 +81,12 @@
/**
* 根据角色编号获取详细信息
*/
- @PreAuthorize("@ss.hasPermi('system:role:query')")
+ //@PreAuthorize("hasAnyAuthority('system:role:query')")
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "query", name = "roleId", dataType = "int", required = true, value = "roleId"),
+ })
@GetMapping(value = "/{roleId}")
+ @ApiOperation(value = "根据角色编号获取详细信息")
public CommonResult getInfo(@PathVariable Long roleId)
{
roleService.checkRoleDataScope(roleId);
@@ -85,9 +96,10 @@
/**
* 新增角色
*/
- @PreAuthorize("@ss.hasPermi('system:role:add')")
- @Log(title = "角色管理", businessType = BusinessType.INSERT)
+ //@PreAuthorize("hasAnyAuthority('system:role:add')")
+ //@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
+ @ApiOperation(value = "新增角色")
public CommonResult add(@Validated @RequestBody SysRole role)
{
if (!roleService.checkRoleNameUnique(role))
@@ -106,9 +118,10 @@
/**
* 修改保存角色
*/
- @PreAuthorize("@ss.hasPermi('system:role:edit')")
- @Log(title = "角色管理", businessType = BusinessType.UPDATE)
+ //@PreAuthorize("hasAnyAuthority('system:role:edit')")
+ //@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
+ @ApiOperation(value = "修改保存角色")
public CommonResult edit(@Validated @RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
@@ -128,7 +141,7 @@
// 更新缓存用户权限
LoginUserDetails loginUser = getLoginUser();
- if (ObjectUtil.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
+ if (ObjectUtil.isNotNull(loginUser.getUser()) && !SecurityUtils.adminUser())
{
loginUser.setUser(userService.selectUserByUsername(loginUser.getUser().getName()));
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
@@ -142,9 +155,10 @@
/**
* 修改保存数据权限
*/
- @PreAuthorize("@ss.hasPermi('system:role:edit')")
- @Log(title = "角色管理", businessType = BusinessType.UPDATE)
+ //@PreAuthorize("hasAnyAuthority('system:role:edit')")
+ //@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
+ @ApiOperation(value = "修改保存数据权限")
public CommonResult dataScope(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
@@ -155,9 +169,10 @@
/**
* 状态修改
*/
- @PreAuthorize("@ss.hasPermi('system:role:edit')")
- @Log(title = "角色管理", businessType = BusinessType.UPDATE)
+ //@PreAuthorize("hasAnyAuthority('system:role:edit')")
+ // @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
+ @ApiOperation(value = "状态修改")
public CommonResult changeStatus(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
@@ -169,8 +184,12 @@
/**
* 删除角色
*/
- @PreAuthorize("@ss.hasPermi('system:role:remove')")
+ //@PreAuthorize("hasAnyAuthority('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
+ @ApiOperation(value = "删除角色")
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "query", name = "roleIds", dataType = "array", required = true, value = "roleIds"),
+ })
@DeleteMapping("/{roleIds}")
public CommonResult remove(@PathVariable Long[] roleIds)
{
@@ -180,7 +199,8 @@
/**
* 获取角色选择框列表
*/
- @PreAuthorize("@ss.hasPermi('system:role:query')")
+ //@PreAuthorize("hasAnyAuthority('system:role:query')")
+ @ApiOperation(value = "获取角色选择框列表")
@GetMapping("/optionselect")
public CommonResult optionselect()
{
@@ -190,7 +210,8 @@
/**
* 查询已分配用户角色列表
*/
- @PreAuthorize("@ss.hasPermi('system:role:list')")
+ //@PreAuthorize("hasAnyAuthority('system:role:list')")
+ @ApiOperation(value = "查询已分配用户角色列表")
@GetMapping("/authUser/allocatedList")
public CommonResult allocatedList(SysUser user)
{
@@ -202,8 +223,10 @@
/**
* 查询未分配用户角色列表
*/
- @PreAuthorize("@ss.hasPermi('system:role:list')")
+ //@PreAuthorize("hasAnyAuthority('system:role:list')")
@GetMapping("/authUser/unallocatedList")
+ @ApiOperation(value = "查询未分配用户角色列表")
+
public CommonResult unallocatedList(SysUser user)
{
startPage();
@@ -214,9 +237,10 @@
/**
* 取消授权用户
*/
- @PreAuthorize("@ss.hasPermi('system:role:edit')")
+ //@PreAuthorize("hasAnyAuthority('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
+ @ApiOperation(value = "取消授权用户")
public CommonResult cancelAuthUser(@RequestBody SysUserRole userRole)
{
return CommonResult.success(roleService.deleteAuthUser(userRole));
@@ -225,9 +249,14 @@
/**
* 批量取消授权用户
*/
- @PreAuthorize("@ss.hasPermi('system:role:edit')")
+ //@PreAuthorize("hasAnyAuthority('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
+ @ApiOperation(value = "批量取消授权用户")
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "query", name = "userIds", dataType = "array", required = true, value = "用户id数组"),
+ @ApiImplicitParam(paramType = "query", name = "roleId", dataType = "int", required = true, value = "角色id"),
+ })
public CommonResult cancelAuthUserAll(Long roleId, Long[] userIds)
{
return CommonResult.success(roleService.deleteAuthUsers(roleId, userIds));
@@ -236,9 +265,14 @@
/**
* 批量选择用户授权
*/
- @PreAuthorize("@ss.hasPermi('system:role:edit')")
+ //@PreAuthorize("hasAnyAuthority('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
+ @ApiOperation(value = "批量选择用户授权")
+ @ApiImplicitParams({
+ @ApiImplicitParam(paramType = "query", name = "userIds", dataType = "array", required = true, value = "用户id数组"),
+ @ApiImplicitParam(paramType = "query", name = "roleId", dataType = "int", required = true, value = "角色id"),
+ })
public CommonResult selectAuthUserAll(Long roleId, Long[] userIds)
{
roleService.checkRoleDataScope(roleId);
@@ -248,8 +282,9 @@
/**
* 获取对应角色部门树列表
*/
- @PreAuthorize("@ss.hasPermi('system:role:query')")
+ //@PreAuthorize("hasAnyAuthority('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}")
+ @ApiOperation(value = "获取对应角色部门树列表")
public CommonResult deptTree(@PathVariable("roleId") Long roleId)
{
Map<String,Object> ajax = new HashMap<>();
--
Gitblit v1.9.2