From c271ffc066c35beafe40acfb63679555f1ed7d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Tue, 17 Aug 2021 14:34:29 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=90=8C=E6=AD=A5=20ruoyi=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=99=90=E6=B5=81=20=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/framework/config/RedisConfig.java | 34 ++++++++++--------- ruoyi-ui/src/utils/download.js | 4 +-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java index 8deee6b6..d66d86bf 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java @@ -1,5 +1,6 @@ package com.ruoyi.framework.config; +import cn.hutool.core.util.StrUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.config.properties.RedissonProperties; import org.redisson.Redisson; @@ -16,6 +17,7 @@ import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.script.DefaultRedisScript; import java.io.IOException; import java.util.HashMap; @@ -90,8 +92,7 @@ public class RedisConfig extends CachingConfigurerSupport { } @Bean - public DefaultRedisScript limitScript() - { + public DefaultRedisScript limitScript() { DefaultRedisScript redisScript = new DefaultRedisScript<>(); redisScript.setScriptText(limitScriptText()); redisScript.setResultType(Long.class); @@ -101,20 +102,21 @@ public class RedisConfig extends CachingConfigurerSupport { /** * 限流脚本 */ - private String limitScriptText() - { - return "local key = KEYS[1]\n" + - "local count = tonumber(ARGV[1])\n" + - "local time = tonumber(ARGV[2])\n" + - "local current = redis.call('get', key);\n" + - "if current and tonumber(current) > count then\n" + - " return current;\n" + - "end\n" + - "current = redis.call('incr', key)\n" + - "if tonumber(current) == 1 then\n" + - " redis.call('expire', key, time)\n" + - "end\n" + - "return current;"; + private String limitScriptText() { + return StrUtil.builder() + .append("local key = KEYS[1]\n") + .append("local count = tonumber(ARGV[1])\n") + .append("local time = tonumber(ARGV[2])\n") + .append("local current = redis.call('get', key);\n") + .append("if current and tonumber(current) > count then\n") + .append(" return current;\n") + .append("end\n") + .append("current = redis.call('incr', key)\n") + .append("if tonumber(current) == 1 then\n") + .append(" redis.call('expire', key, time)\n") + .append("end\n") + .append("return current;") + .toString(); } } diff --git a/ruoyi-ui/src/utils/download.js b/ruoyi-ui/src/utils/download.js index 8f66c249..52b07f71 100644 --- a/ruoyi-ui/src/utils/download.js +++ b/ruoyi-ui/src/utils/download.js @@ -44,8 +44,8 @@ export function downLoadExcel(url, params) { for (const key of Object.keys(value)) { if (value[key] !== null && typeof (value[key]) !== 'undefined') { let params = propName + '[' + key + ']'; - let subPart = encodeURIComponent(params) + "=" - urlparams += subPart + encodeURIComponent(value[key]) + "&"; + let subPart = encodeURIComponent(params) + '='; + urlparams += subPart + encodeURIComponent(value[key]) + '&'; } } } else {