From c7785d1dbcc6a3e19e9a138134442fbc7038cbdf Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 05 八月 2020 09:42:03 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue

---
 ruoyi-ui/src/utils/request.js                                                                  |   20 +++++++--
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java               |   30 ++++++++++++++
 ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java |   13 +++++-
 ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java                            |    5 ++
 README.md                                                                                      |    2 
 5 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 92710b0..1dbc1d6 100644
--- a/README.md
+++ b/README.md
@@ -13,8 +13,8 @@
 * 鏀寔鍔犺浇鍔ㄦ�佹潈闄愯彍鍗曪紝澶氭柟寮忚交鏉炬潈闄愭帶鍒躲��
 * 楂樻晥鐜囧紑鍙戯紝浣跨敤浠g爜鐢熸垚鍣ㄥ彲浠ヤ竴閿敓鎴愬墠鍚庣浠g爜銆�
 * 鎻愪緵浜嗕竴涓狾racle鐗堟湰[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle)锛屼繚鎸佸悓姝ユ洿鏂般��
-* 鎰熻阿[Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin)锛孾eladmin-web](https://gitee.com/elunez/eladmin-web?_from=gitee_search)銆�
 * 涓嶅垎绂荤増鏈紝璇风Щ姝RuoYi](https://gitee.com/y_project/RuoYi)锛屽井鏈嶅姟鐗堟湰锛岃绉绘[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
+* 鎰熻阿[Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin)锛孾eladmin-web](https://gitee.com/elunez/eladmin-web?_from=gitee_search)銆�
 * 闃块噷浜戜紭鎯犲埜锛歔鐐规垜杩涘叆](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link)锛岃吘璁簯浼樻儬鍒革細[鐐规垜棰嗗彇](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)&nbsp;&nbsp;
 
 ## 鍐呯疆鍔熻兘
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 dfe7a2a..a06f848 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
@@ -17,11 +17,17 @@
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysRole;
+import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.service.SysPermissionService;
+import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.system.service.ISysRoleService;
+import com.ruoyi.system.service.ISysUserService;
 
 /**
  * 瑙掕壊淇℃伅
@@ -34,6 +40,15 @@
 {
     @Autowired
     private ISysRoleService roleService;
+
+    @Autowired
+    private TokenService tokenService;
+
+    @Autowired
+    private SysPermissionService permissionService;
+
+    @Autowired
+    private ISysUserService userService;
 
     @PreAuthorize("@ss.hasPermi('system:role:list')")
     @GetMapping("/list")
@@ -103,7 +118,20 @@
             return AjaxResult.error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪");
         }
         role.setUpdateBy(SecurityUtils.getUsername());
-        return toAjax(roleService.updateRole(role));
+
+        if (roleService.updateRole(role) > 0)
+        {
+            // 鏇存柊缂撳瓨鐢ㄦ埛鏉冮檺
+            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+            if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
+            {
+                loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
+                loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
+                tokenService.setLoginUser(loginUser);
+            }
+            return AjaxResult.success();
+        }
+        return AjaxResult.error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑱旂郴绠$悊鍛�");
     }
 
     /**
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
index c9f8d0a..5342919 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
@@ -63,6 +63,11 @@
     public static final String LOGIN_TOKEN_KEY = "login_tokens:";
 
     /**
+     * 闃查噸鎻愪氦 redis key
+     */
+    public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
+
+    /**
      * 楠岃瘉鐮佹湁鏁堟湡锛堝垎閽燂級
      */
     public static final Integer CAPTCHA_EXPIRATION = 2;
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
index 5f78380..36e6c10 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
@@ -5,8 +5,10 @@
 import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletRequest;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
 import com.ruoyi.common.utils.StringUtils;
@@ -26,7 +28,9 @@
 
     public final String REPEAT_TIME = "repeatTime";
 
-    public final String CACHE_REPEAT_KEY = "repeatData";
+    // 浠ょ墝鑷畾涔夋爣璇�
+    @Value("${token.header}")
+    private String header;
 
     @Autowired
     private RedisCache redisCache;
@@ -62,7 +66,10 @@
         // 璇锋眰鍦板潃锛堜綔涓哄瓨鏀綾ache鐨刱ey鍊硷級
         String url = request.getRequestURI();
 
-        Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY);
+        // 鍞竴鏍囪瘑锛堟寚瀹歬ey + 娑堟伅澶达級
+        String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + request.getHeader(header);
+
+        Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
         if (sessionObj != null)
         {
             Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
@@ -77,7 +84,7 @@
         }
         Map<String, Object> cacheMap = new HashMap<String, Object>();
         cacheMap.put(url, nowDataMap);
-        redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS);
+        redisCache.setCacheObject(cache_repeat_key, cacheMap, intervalTime, TimeUnit.SECONDS);
         return false;
     }
 
diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js
index 7a0653d..f62368e 100644
--- a/ruoyi-ui/src/utils/request.js
+++ b/ruoyi-ui/src/utils/request.js
@@ -30,7 +30,7 @@
     // 鏈缃姸鎬佺爜鍒欓粯璁ゆ垚鍔熺姸鎬�
     const code = res.data.code || 200;
     // 鑾峰彇閿欒淇℃伅
-    const message = errorCode[code] || res.data.msg || errorCode['default']
+    const msg = errorCode[code] || res.data.msg || errorCode['default']
     if (code === 401) {
       MessageBox.confirm(
         '鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�',
@@ -47,13 +47,13 @@
       })
     } else if (code === 500) {
       Message({
-        message: message,
+        message: msg,
         type: 'error'
       })
-      return Promise.reject(new Error(message))
+      return Promise.reject(new Error(msg))
     } else if (code !== 200) {
       Notification.error({
-        title: message
+        title: msg
       })
       return Promise.reject('error')
     } else {
@@ -62,8 +62,18 @@
   },
   error => {
     console.log('err' + error)
+    let { message } = error;
+    if (message == "Network Error") {
+      message = "鍚庣鎺ュ彛杩炴帴寮傚父";
+    }
+    else if (message.includes("timeout")) {
+      message = "绯荤粺鎺ュ彛璇锋眰瓒呮椂";
+    }
+    else if (message.includes("Request failed with status code")) {
+      message = "绯荤粺鎺ュ彛" + message.substr(message.length - 3) + "寮傚父";
+    }
     Message({
-      message: error.message,
+      message: message,
       type: 'error',
       duration: 5 * 1000
     })

--
Gitblit v1.9.3