From af6a08398e2bc22f3c8a3a615cbd9e23190be906 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 12 五月 2022 10:55:44 +0800
Subject: [PATCH] update 优化 文件与图片上传组件 使用id存储回显

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java |   42 +++++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 19 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 c6d887c..5d9a206 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
@@ -5,7 +5,7 @@
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.domain.PageQuery;
 import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -64,9 +64,9 @@
     @ApiOperation("鏍规嵁瑙掕壊缂栧彿鑾峰彇璇︾粏淇℃伅")
     @SaCheckPermission("system:role:query")
     @GetMapping(value = "/{roleId}")
-    public AjaxResult<SysRole> getInfo(@ApiParam("瑙掕壊ID") @PathVariable Long roleId) {
+    public R<SysRole> getInfo(@ApiParam("瑙掕壊ID") @PathVariable Long roleId) {
         roleService.checkRoleDataScope(roleId);
-        return AjaxResult.success(roleService.selectRoleById(roleId));
+        return R.ok(roleService.selectRoleById(roleId));
     }
 
     /**
@@ -76,11 +76,11 @@
     @SaCheckPermission("system:role:add")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult<Void> add(@Validated @RequestBody SysRole role) {
+    public R<Void> add(@Validated @RequestBody SysRole role) {
         if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
-            return AjaxResult.error("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
+            return R.fail("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
         } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
-            return AjaxResult.error("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
+            return R.fail("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
         }
         return toAjax(roleService.insertRole(role));
 
@@ -93,12 +93,13 @@
     @SaCheckPermission("system:role:edit")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult<Void> edit(@Validated @RequestBody SysRole role) {
+    public R<Void> edit(@Validated @RequestBody SysRole role) {
         roleService.checkRoleAllowed(role);
+        roleService.checkRoleDataScope(role.getRoleId());
         if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
-            return AjaxResult.error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
+            return R.fail("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪");
         } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
-            return AjaxResult.error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
+            return R.fail("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
         }
 
         if (roleService.updateRole(role) > 0) {
@@ -109,9 +110,9 @@
                 loginUser.setMenuPermission(permissionService.getMenuPermission(sysUser));
                 LoginHelper.setLoginUser(loginUser);
             }
-            return AjaxResult.success();
+            return R.ok();
         }
-        return AjaxResult.error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑱旂郴绠$悊鍛�");
+        return R.fail("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑱旂郴绠$悊鍛�");
     }
 
     /**
@@ -121,8 +122,9 @@
     @SaCheckPermission("system:role:edit")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE)
     @PutMapping("/dataScope")
-    public AjaxResult<Void> dataScope(@RequestBody SysRole role) {
+    public R<Void> dataScope(@RequestBody SysRole role) {
         roleService.checkRoleAllowed(role);
+        roleService.checkRoleDataScope(role.getRoleId());
         return toAjax(roleService.authDataScope(role));
     }
 
@@ -133,8 +135,9 @@
     @SaCheckPermission("system:role:edit")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE)
     @PutMapping("/changeStatus")
-    public AjaxResult<Void> changeStatus(@RequestBody SysRole role) {
+    public R<Void> changeStatus(@RequestBody SysRole role) {
         roleService.checkRoleAllowed(role);
+        roleService.checkRoleDataScope(role.getRoleId());
         return toAjax(roleService.updateRoleStatus(role));
     }
 
@@ -145,7 +148,7 @@
     @SaCheckPermission("system:role:remove")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.DELETE)
     @DeleteMapping("/{roleIds}")
-    public AjaxResult<Void> remove(@ApiParam("宀椾綅ID涓�") @PathVariable Long[] roleIds) {
+    public R<Void> remove(@ApiParam("宀椾綅ID涓�") @PathVariable Long[] roleIds) {
         return toAjax(roleService.deleteRoleByIds(roleIds));
     }
 
@@ -155,8 +158,8 @@
     @ApiOperation("鑾峰彇瑙掕壊閫夋嫨妗嗗垪琛�")
     @SaCheckPermission("system:role:query")
     @GetMapping("/optionselect")
-    public AjaxResult<List<SysRole>> optionselect() {
-        return AjaxResult.success(roleService.selectRoleAll());
+    public R<List<SysRole>> optionselect() {
+        return R.ok(roleService.selectRoleAll());
     }
 
     /**
@@ -186,7 +189,7 @@
     @SaCheckPermission("system:role:edit")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.GRANT)
     @PutMapping("/authUser/cancel")
-    public AjaxResult<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
+    public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
         return toAjax(roleService.deleteAuthUser(userRole));
     }
 
@@ -201,7 +204,7 @@
     @SaCheckPermission("system:role:edit")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.GRANT)
     @PutMapping("/authUser/cancelAll")
-    public AjaxResult<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
+    public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
         return toAjax(roleService.deleteAuthUsers(roleId, userIds));
     }
 
@@ -216,7 +219,8 @@
     @SaCheckPermission("system:role:edit")
     @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.GRANT)
     @PutMapping("/authUser/selectAll")
-    public AjaxResult<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
+    public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
+        roleService.checkRoleDataScope(roleId);
         return toAjax(roleService.insertAuthUsers(roleId, userIds));
     }
 }

--
Gitblit v1.9.3