From 6ae35089a05b58dc31c243b9bb4f6a80b20c3a7b Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 23 五月 2025 17:44:42 +0800
Subject: [PATCH] 修改接口

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java |   63 ++++++++++++++++---------------
 1 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
index 5c53a61..117d8f6 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
@@ -6,7 +6,9 @@
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import com.alibaba.fastjson.JSON;
 import com.ruoyi.common.basic.PageInfo;
+import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.domain.entity.SysMenu;
 import com.ruoyi.system.dto.SysRoleDTO;
 import com.ruoyi.system.query.SysRoleQuery;
@@ -42,7 +44,7 @@
  */
 @Api(tags = "角色信息")
 @RestController
-@RequestMapping("/system/role")
+@RequestMapping("")
 public class SysRoleController extends BaseController
 {
     @Autowired
@@ -62,26 +64,26 @@
     @Autowired
     private ISysMenuService menuService;
 
-    @PreAuthorize("@ss.hasPermi('system:role')")
+//    @PreAuthorize("@ss.hasPermi('system:role')")
     @ApiOperation(value = "角色列表")
-    @PostMapping("/list")
+    @PostMapping("/system/role/list")
     public AjaxResult list(@RequestBody SysRoleQuery query)
     {
         PageInfo<SysRole> list = roleService.selectPageList(query);
         return AjaxResult.success(list);
     }
 
-    @PreAuthorize("@ss.hasPermi('system:role')")
+//    @PreAuthorize("@ss.hasPermi('system:role')")
     @ApiOperation(value = "角色列表不分页")
-    @PostMapping("/listNotPage")
+    @PostMapping("/system/role/listNotPage")
     public AjaxResult list()
     {
         List<SysRole> list = roleService.selectRoleList(new SysRole());
         return AjaxResult.success(list);
     }
-    @PreAuthorize("@ss.hasPermi('system:role:count')")
+//    @PreAuthorize("@ss.hasPermi('system:role:count')")
     @ApiOperation(value = "角色数量统计")
-    @PostMapping("/roleCount")
+    @PostMapping("/system/role/roleCount")
     public AjaxResult roleCount()
     {
         int all = roleService.selectCount(null);
@@ -108,8 +110,8 @@
     /**
      * 根据角色编号获取详细信息
      */
-     @PreAuthorize("@ss.hasPermi('system:role:query')")
-    @GetMapping(value = "/{roleId}")
+//     @PreAuthorize("@ss.hasPermi('system:role:query')")
+    @GetMapping(value = "/system/role/{roleId}")
     public AjaxResult getInfo(@PathVariable Long roleId)
     {
         roleService.checkRoleDataScope(roleId);
@@ -118,7 +120,7 @@
 
 //    @PreAuthorize("@ss.hasPermi('system:role:detail')")
     @ApiOperation("角色详情")
-    @GetMapping("/roleInfo")
+    @GetMapping("/system/role/roleInfo")
     public AjaxResult roleInfo(@RequestParam Long roleId)
     {
         SysRole role = roleService.selectRoleById(roleId);
@@ -142,7 +144,7 @@
 
 
     @ApiOperation("用户获取权限菜单")
-    @GetMapping("/roleInfoFromUserId")
+    @GetMapping("/system/role/roleInfoFromUserId")
     public AjaxResult roleInfoFromUserId(@RequestParam Long userId)
     {
         return AjaxResult.success(roleService.roleInfoFromUserId(userId));
@@ -152,10 +154,10 @@
     /**
      * 新增角色
      */
-     @PreAuthorize("@ss.hasPermi('system:role:add')")
+//    @PreAuthorize("@ss.hasPermi('system:role:add')")
     @ApiOperation(value = "新增角色")
     @Log(title = "角色信息-新增角色", businessType = BusinessType.INSERT)
-    @PostMapping("/add")
+    @PostMapping("/system/role/add")
     public AjaxResult add(@Validated @RequestBody SysRoleDTO dto)
     {
         Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName());
@@ -170,15 +172,16 @@
     /**
      * 修改保存角色
      */
-     @PreAuthorize("@ss.hasPermi('system:role:edit')")
-    @ApiOperation(value = "编辑角色")
+//    @PreAuthorize("@ss.hasPermi('system:role:edit')")
+    @ApiOperation(value = "编辑角色",response = SysRoleDTO.class)
     @Log(title = "角色信息-编辑角色", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@Validated @RequestBody SysRoleDTO dto)
+    @PostMapping("/api/system/role/edit")
+    public R<String> edit(@RequestBody String param)
     {
+        SysRoleDTO dto = JSON.parseObject(param, SysRoleDTO.class);
         Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName());
         if (flag){
-            return error("修改角色'" + dto.getRoleName() + "'失败,角色名称已存在");
+            return R.fail("修改角色'" + dto.getRoleName() + "'失败,角色名称已存在");
         }
         if (roleService.editRole(dto) > 0)
         {
@@ -190,9 +193,9 @@
                 loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
                 tokenService.setLoginUser(loginUser);
             }
-            return AjaxResult.success();
+            return R.ok();
         }
-        return error("修改角色'" + dto.getRoleName() + "'失败,请联系管理员");
+        return R.fail("修改角色'" + dto.getRoleName() + "'失败,请联系管理员");
     }
 
     /**
@@ -200,7 +203,7 @@
      */
     // @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
-    @PutMapping("/dataScope")
+    @PutMapping("/system/role/dataScope")
     public AjaxResult dataScope(@RequestBody SysRole role)
     {
         roleService.checkRoleAllowed(role);
@@ -214,7 +217,7 @@
     // @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @ApiOperation(value = "状态修改")
     @Log(title = "角色信息-角色状态修改", businessType = BusinessType.UPDATE)
-    @PutMapping("/changeStatus")
+    @PutMapping("/system/role/changeStatus")
     public AjaxResult changeStatus(@RequestBody SysRole role)
     {
         role.setUpdateBy(getUsername());
@@ -228,7 +231,7 @@
     // @PreAuthorize("@ss.hasPermi('system:role:remove')")
     @ApiOperation(value = "删除角色")
     @Log(title = "角色信息-角色删除角色", businessType = BusinessType.DELETE)
-    @DeleteMapping("/deleteById/{ids}")
+    @DeleteMapping("/system/role/deleteById/{ids}")
     public AjaxResult remove(@PathVariable String ids)
     {
         String[] split = ids.split(",");
@@ -243,7 +246,7 @@
      * 获取角色选择框列表
      */
     // @PreAuthorize("@ss.hasPermi('system:role:query')")
-    @GetMapping("/optionselect")
+    @GetMapping("/system/role/optionselect")
     public AjaxResult optionselect()
     {
         return AjaxResult.success(roleService.selectRoleAll());
@@ -253,7 +256,7 @@
      * 查询已分配用户角色列表
      */
     // @PreAuthorize("@ss.hasPermi('system:role:list')")
-    @GetMapping("/authUser/allocatedList")
+    @GetMapping("/system/role/authUser/allocatedList")
     public TableDataInfo allocatedList(SysUser user)
     {
 //        startPage();
@@ -265,7 +268,7 @@
      * 查询未分配用户角色列表
      */
     // @PreAuthorize("@ss.hasPermi('system:role:list')")
-    @GetMapping("/authUser/unallocatedList")
+    @GetMapping("/system/role/authUser/unallocatedList")
     public TableDataInfo unallocatedList(SysUser user)
     {
 //        startPage();
@@ -278,7 +281,7 @@
      */
     // @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.GRANT)
-    @PutMapping("/authUser/cancel")
+    @PutMapping("/system/role/authUser/cancel")
     public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
     {
         return AjaxResult.success(roleService.deleteAuthUser(userRole));
@@ -289,7 +292,7 @@
      */
     // @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.GRANT)
-    @PutMapping("/authUser/cancelAll")
+    @PutMapping("/system/role/authUser/cancelAll")
     public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
     {
         return AjaxResult.success(roleService.deleteAuthUsers(roleId, userIds));
@@ -300,7 +303,7 @@
      */
     // @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "角色管理", businessType = BusinessType.GRANT)
-    @PutMapping("/authUser/selectAll")
+    @PutMapping("/system/role/authUser/selectAll")
     public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
     {
         roleService.checkRoleDataScope(roleId);
@@ -311,7 +314,7 @@
      * 获取对应角色部门树列表
      */
     // @PreAuthorize("@ss.hasPermi('system:role:query')")
-    @GetMapping(value = "/deptTree/{roleId}")
+    @GetMapping(value = "/system/role/deptTree/{roleId}")
     public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
     {
         AjaxResult ajax = AjaxResult.success();

--
Gitblit v1.7.1