From 9d66bfbfcda297f628e6a857e343f98422f4534a Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期五, 22 五月 2026 09:32:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev_New_pro' into dev_New_pro_OA

---
 src/main/java/com/ruoyi/project/system/controller/SysRoleController.java |   86 +++++++++++++++++++------------------------
 1 files changed, 38 insertions(+), 48 deletions(-)

diff --git a/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java b/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java
index 650a3e3..5f65a8d 100644
--- a/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java
+++ b/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java
@@ -1,16 +1,9 @@
 package com.ruoyi.project.system.controller;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import jakarta.servlet.http.HttpServletResponse;
-
-import com.ruoyi.framework.web.domain.R;
-import com.ruoyi.project.system.domain.vo.SysUserDeptVo;
-import com.ruoyi.project.system.mapper.SysUserMapper;
-import com.ruoyi.project.system.service.*;
 import lombok.AllArgsConstructor;
-import org.apache.commons.lang3.ArrayUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -29,15 +22,19 @@
 import com.ruoyi.framework.security.service.SysPermissionService;
 import com.ruoyi.framework.security.service.TokenService;
 import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.page.TableDataInfo;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysRole;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.domain.SysUserRole;
+import com.ruoyi.project.system.service.ISysDeptService;
+import com.ruoyi.project.system.service.ISysRoleService;
+import com.ruoyi.project.system.service.ISysUserService;
 
 /**
  * 瑙掕壊淇℃伅
- *
+ * 
  * @author ruoyi
  */
 @RestController
@@ -75,10 +72,10 @@
      */
     @PreAuthorize("@ss.hasPermi('system:role:query')")
     @GetMapping(value = "/{roleId}")
-    public R<?> getInfo(@PathVariable Long roleId)
+    public AjaxResult getInfo(@PathVariable Long roleId)
     {
         roleService.checkRoleDataScope(roleId);
-        return R.ok(roleService.selectRoleById(roleId));
+        return success(roleService.selectRoleById(roleId));
     }
 
     /**
@@ -87,19 +84,18 @@
     @PreAuthorize("@ss.hasPermi('system:role:add')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.INSERT)
     @PostMapping
-    public R<?> add(@Validated @RequestBody SysRole role)
+    public AjaxResult add(@Validated @RequestBody SysRole role)
     {
         if (!roleService.checkRoleNameUnique(role))
         {
-            return R.fail("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
+            return error("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
         }
         else if (!roleService.checkRoleKeyUnique(role))
         {
-            return R.fail("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
+            return error("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
         }
         role.setCreateBy(getUsername());
-        roleService.insertRole(role);
-        return R.ok();
+        return toAjax(roleService.insertRole(role));
 
     }
 
@@ -109,20 +105,20 @@
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE)
     @PutMapping
-    public R<?> edit(@Validated @RequestBody SysRole role)
+    public AjaxResult edit(@Validated @RequestBody SysRole role)
     {
         roleService.checkRoleAllowed(role);
         roleService.checkRoleDataScope(role.getRoleId());
         if (!roleService.checkRoleNameUnique(role))
         {
-            return R.fail("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
+            return error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
         }
         else if (!roleService.checkRoleKeyUnique(role))
         {
-            return R.fail("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
+            return error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
         }
         role.setUpdateBy(getUsername());
-
+        
         if (roleService.updateRole(role) > 0)
         {
             // 鏇存柊缂撳瓨鐢ㄦ埛鏉冮檺
@@ -133,9 +129,9 @@
                 loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
                 tokenService.setLoginUser(loginUser);
             }
-            return R.ok();
+            return success();
         }
-        return R.fail("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑱旂郴绠$悊鍛�");
+        return error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑱旂郴绠$悊鍛�");
     }
 
     /**
@@ -144,12 +140,11 @@
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE)
     @PutMapping("/dataScope")
-    public R<?> dataScope(@RequestBody SysRole role)
+    public AjaxResult dataScope(@RequestBody SysRole role)
     {
         roleService.checkRoleAllowed(role);
         roleService.checkRoleDataScope(role.getRoleId());
-        roleService.authDataScope(role);
-        return R.ok();
+        return toAjax(roleService.authDataScope(role));
     }
 
     /**
@@ -158,13 +153,12 @@
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE)
     @PutMapping("/changeStatus")
-    public R<?> changeStatus(@RequestBody SysRole role)
+    public AjaxResult changeStatus(@RequestBody SysRole role)
     {
         roleService.checkRoleAllowed(role);
         roleService.checkRoleDataScope(role.getRoleId());
         role.setUpdateBy(getUsername());
-        roleService.updateRoleStatus(role);
-        return R.ok();
+        return toAjax(roleService.updateRoleStatus(role));
     }
 
     /**
@@ -173,10 +167,9 @@
     @PreAuthorize("@ss.hasPermi('system:role:remove')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.DELETE)
     @DeleteMapping("/{roleIds}")
-    public R<?> remove(@PathVariable Long[] roleIds)
+    public AjaxResult remove(@PathVariable Long[] roleIds)
     {
-        roleService.deleteRoleByIds(roleIds);
-        return R.ok();
+        return toAjax(roleService.deleteRoleByIds(roleIds));
     }
 
     /**
@@ -184,9 +177,9 @@
      */
     @PreAuthorize("@ss.hasPermi('system:role:query')")
     @GetMapping("/optionselect")
-    public R<?> optionselect()
+    public AjaxResult optionselect()
     {
-        return R.ok(roleService.selectRoleAll());
+        return success(roleService.selectRoleAll());
     }
 
     /**
@@ -219,10 +212,9 @@
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.GRANT)
     @PutMapping("/authUser/cancel")
-    public R<?> cancelAuthUser(@RequestBody SysUserRole userRole)
+    public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
     {
-        roleService.deleteAuthUser(userRole);
-        return R.ok();
+        return toAjax(roleService.deleteAuthUser(userRole));
     }
 
     /**
@@ -231,10 +223,9 @@
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.GRANT)
     @PutMapping("/authUser/cancelAll")
-    public R<?> cancelAuthUserAll(Long roleId, Long[] userIds)
+    public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
     {
-        roleService.deleteAuthUsers(roleId, userIds);
-        return R.ok();
+        return toAjax(roleService.deleteAuthUsers(roleId, userIds));
     }
 
     /**
@@ -243,11 +234,10 @@
     @PreAuthorize("@ss.hasPermi('system:role:edit')")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.GRANT)
     @PutMapping("/authUser/selectAll")
-    public R<?> selectAuthUserAll(Long roleId, Long[] userIds)
+    public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
     {
         roleService.checkRoleDataScope(roleId);
-        roleService.insertAuthUsers(roleId, userIds);
-        return R.ok();
+        return toAjax(roleService.insertAuthUsers(roleId, userIds));
     }
 
     /**
@@ -255,11 +245,11 @@
      */
     @PreAuthorize("@ss.hasPermi('system:role:query')")
     @GetMapping(value = "/deptTree/{roleId}")
-    public R<?> deptTree(@PathVariable("roleId") Long roleId)
+    public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
     {
-        Map<String, Object> map = new HashMap<>();
-        map.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
-        map.put("depts", deptService.selectDeptTreeList(new SysDept()));
-        return R.ok(map);
+        AjaxResult ajax = AjaxResult.success();
+        ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
+        ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
+        return ajax;
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3