mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue
Conflicts: README.md ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java ruoyi-ui/src/utils/request.js
This commit is contained in:
		@@ -13,8 +13,8 @@
 | 
			
		||||
* 支持加载动态权限菜单,多方式轻松权限控制。
 | 
			
		||||
* 高效率开发,使用代码生成器可以一键生成前后端代码。
 | 
			
		||||
* 提供了一个Oracle版本[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)  
 | 
			
		||||
 | 
			
		||||
## 内置功能
 | 
			
		||||
 
 | 
			
		||||
@@ -17,11 +17,17 @@ 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.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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 角色信息
 | 
			
		||||
@@ -35,6 +41,15 @@ public class SysRoleController extends BaseController
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ISysRoleService roleService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private TokenService tokenService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private SysPermissionService permissionService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ISysUserService userService;
 | 
			
		||||
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('system:role:list')")
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    public TableDataInfo list(SysRole role)
 | 
			
		||||
@@ -103,7 +118,20 @@ public class SysRoleController extends BaseController
 | 
			
		||||
            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() + "'失败,请联系管理员");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,11 @@ public class Constants
 | 
			
		||||
     */
 | 
			
		||||
    public static final String LOGIN_TOKEN_KEY = "login_tokens:";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 防重提交 redis key
 | 
			
		||||
     */
 | 
			
		||||
    public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 验证码有效期(分钟)
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,10 @@ import java.util.Map;
 | 
			
		||||
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 class SameUrlDataInterceptor extends RepeatSubmitInterceptor
 | 
			
		||||
 | 
			
		||||
    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 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
 | 
			
		||||
        // 请求地址(作为存放cache的key值)
 | 
			
		||||
        String url = request.getRequestURI();
 | 
			
		||||
 | 
			
		||||
        Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY);
 | 
			
		||||
        // 唯一标识(指定key + 消息头)
 | 
			
		||||
        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 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
 | 
			
		||||
        }
 | 
			
		||||
        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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ service.interceptors.response.use(res => {
 | 
			
		||||
    // 未设置状态码则默认成功状态
 | 
			
		||||
    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 @@ service.interceptors.response.use(res => {
 | 
			
		||||
      })
 | 
			
		||||
    } 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 @@ service.interceptors.response.use(res => {
 | 
			
		||||
  },
 | 
			
		||||
  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
 | 
			
		||||
    })
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user