From 1590e1068c364d3c614f48e8d9f2ed64d93699e9 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 18:07:02 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/utils/text/CharsetKit.java | 87 -- .../com/ruoyi/common/utils/text/Convert.java | 999 ------------------ .../ruoyi/common/utils/text/StrFormatter.java | 93 -- 3 files changed, 1179 deletions(-) delete mode 100644 ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java delete mode 100644 ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java delete mode 100644 ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java b/ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java deleted file mode 100644 index f273cf75..00000000 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.ruoyi.common.utils.text; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import com.ruoyi.common.utils.StringUtils; - -/** - * 字符集工具类 - * - * @author ruoyi - * - */ -public class CharsetKit -{ - /** ISO-8859-1 */ - public static final String ISO_8859_1 = "ISO-8859-1"; - /** UTF-8 */ - public static final String UTF_8 = "UTF-8"; - /** GBK */ - public static final String GBK = "GBK"; - - /** ISO-8859-1 */ - public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); - /** UTF-8 */ - public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); - /** GBK */ - public static final Charset CHARSET_GBK = Charset.forName(GBK); - - /** - * 转换为Charset对象 - * - * @param charset 字符集,为空则返回默认字符集 - * @return Charset - */ - public static Charset charset(String charset) - { - return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); - } - - /** - * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 - * @param destCharset 目标字符集,默认UTF-8 - * @return 转换后的字符集 - */ - public static String convert(String source, String srcCharset, String destCharset) - { - return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); - } - - /** - * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 - * @param destCharset 目标字符集,默认UTF-8 - * @return 转换后的字符集 - */ - public static String convert(String source, Charset srcCharset, Charset destCharset) - { - if (null == srcCharset) - { - srcCharset = StandardCharsets.ISO_8859_1; - } - - if (null == destCharset) - { - srcCharset = StandardCharsets.UTF_8; - } - - if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) - { - return source; - } - return new String(source.getBytes(srcCharset), destCharset); - } - - /** - * @return 系统字符集编码 - */ - public static String systemCharset() - { - return Charset.defaultCharset().name(); - } -} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java b/ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java deleted file mode 100644 index a9e2f218..00000000 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java +++ /dev/null @@ -1,999 +0,0 @@ -package com.ruoyi.common.utils.text; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.text.NumberFormat; -import java.util.Set; -import com.ruoyi.common.utils.StringUtils; - -/** - * 类型转换器 - * - * @author ruoyi - */ -public class Convert -{ - /** - * 转换为字符串
- * 如果给定的值为null,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static String toStr(Object value, String defaultValue) - { - if (null == value) - { - return defaultValue; - } - if (value instanceof String) - { - return (String) value; - } - return value.toString(); - } - - /** - * 转换为字符串
- * 如果给定的值为null,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static String toStr(Object value) - { - return toStr(value, null); - } - - /** - * 转换为字符
- * 如果给定的值为null,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Character toChar(Object value, Character defaultValue) - { - if (null == value) - { - return defaultValue; - } - if (value instanceof Character) - { - return (Character) value; - } - - final String valueStr = toStr(value, null); - return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); - } - - /** - * 转换为字符
- * 如果给定的值为null,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Character toChar(Object value) - { - return toChar(value, null); - } - - /** - * 转换为byte
- * 如果给定的值为null,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Byte toByte(Object value, Byte defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Byte) - { - return (Byte) value; - } - if (value instanceof Number) - { - return ((Number) value).byteValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Byte.parseByte(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为byte
- * 如果给定的值为null,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Byte toByte(Object value) - { - return toByte(value, null); - } - - /** - * 转换为Short
- * 如果给定的值为null,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Short toShort(Object value, Short defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Short) - { - return (Short) value; - } - if (value instanceof Number) - { - return ((Number) value).shortValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Short.parseShort(valueStr.trim()); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Short
- * 如果给定的值为null,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Short toShort(Object value) - { - return toShort(value, null); - } - - /** - * 转换为Number
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Number toNumber(Object value, Number defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Number) - { - return (Number) value; - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return NumberFormat.getInstance().parse(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Number
- * 如果给定的值为空,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Number toNumber(Object value) - { - return toNumber(value, null); - } - - /** - * 转换为int
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Integer toInt(Object value, Integer defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Integer) - { - return (Integer) value; - } - if (value instanceof Number) - { - return ((Number) value).intValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Integer.parseInt(valueStr.trim()); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为int
- * 如果给定的值为null,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Integer toInt(Object value) - { - return toInt(value, null); - } - - /** - * 转换为Integer数组
- * - * @param str 被转换的值 - * @return 结果 - */ - public static Integer[] toIntArray(String str) - { - return toIntArray(",", str); - } - - /** - * 转换为Long数组
- * - * @param str 被转换的值 - * @return 结果 - */ - public static Long[] toLongArray(String str) - { - return toLongArray(",", str); - } - - /** - * 转换为Integer数组
- * - * @param split 分隔符 - * @param split 被转换的值 - * @return 结果 - */ - public static Integer[] toIntArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Integer[] {}; - } - String[] arr = str.split(split); - final Integer[] ints = new Integer[arr.length]; - for (int i = 0; i < arr.length; i++) - { - final Integer v = toInt(arr[i], 0); - ints[i] = v; - } - return ints; - } - - /** - * 转换为Long数组
- * - * @param split 分隔符 - * @param str 被转换的值 - * @return 结果 - */ - public static Long[] toLongArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Long[] {}; - } - String[] arr = str.split(split); - final Long[] longs = new Long[arr.length]; - for (int i = 0; i < arr.length; i++) - { - final Long v = toLong(arr[i], null); - longs[i] = v; - } - return longs; - } - - /** - * 转换为String数组
- * - * @param str 被转换的值 - * @return 结果 - */ - public static String[] toStrArray(String str) - { - return toStrArray(",", str); - } - - /** - * 转换为String数组
- * - * @param split 分隔符 - * @param split 被转换的值 - * @return 结果 - */ - public static String[] toStrArray(String split, String str) - { - return str.split(split); - } - - /** - * 转换为long
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Long toLong(Object value, Long defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Long) - { - return (Long) value; - } - if (value instanceof Number) - { - return ((Number) value).longValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - // 支持科学计数法 - return new BigDecimal(valueStr.trim()).longValue(); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为long
- * 如果给定的值为null,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Long toLong(Object value) - { - return toLong(value, null); - } - - /** - * 转换为double
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Double toDouble(Object value, Double defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Double) - { - return (Double) value; - } - if (value instanceof Number) - { - return ((Number) value).doubleValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - // 支持科学计数法 - return new BigDecimal(valueStr.trim()).doubleValue(); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为double
- * 如果给定的值为空,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Double toDouble(Object value) - { - return toDouble(value, null); - } - - /** - * 转换为Float
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Float toFloat(Object value, Float defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Float) - { - return (Float) value; - } - if (value instanceof Number) - { - return ((Number) value).floatValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Float.parseFloat(valueStr.trim()); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Float
- * 如果给定的值为空,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Float toFloat(Object value) - { - return toFloat(value, null); - } - - /** - * 转换为boolean
- * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Boolean toBool(Object value, Boolean defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Boolean) - { - return (Boolean) value; - } - String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - valueStr = valueStr.trim().toLowerCase(); - switch (valueStr) - { - case "true": - return true; - case "false": - return false; - case "yes": - return true; - case "ok": - return true; - case "no": - return false; - case "1": - return true; - case "0": - return false; - default: - return defaultValue; - } - } - - /** - * 转换为boolean
- * 如果给定的值为空,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Boolean toBool(Object value) - { - return toBool(value, null); - } - - /** - * 转换为Enum对象
- * 如果给定的值为空,或者转换失败,返回默认值
- * - * @param clazz Enum的Class - * @param value 值 - * @param defaultValue 默认值 - * @return Enum - */ - public static > E toEnum(Class clazz, Object value, E defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (clazz.isAssignableFrom(value.getClass())) - { - @SuppressWarnings("unchecked") - E myE = (E) value; - return myE; - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Enum.valueOf(clazz, valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Enum对象
- * 如果给定的值为空,或者转换失败,返回默认值null
- * - * @param clazz Enum的Class - * @param value 值 - * @return Enum - */ - public static > E toEnum(Class clazz, Object value) - { - return toEnum(clazz, value, null); - } - - /** - * 转换为BigInteger
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static BigInteger toBigInteger(Object value, BigInteger defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof BigInteger) - { - return (BigInteger) value; - } - if (value instanceof Long) - { - return BigInteger.valueOf((Long) value); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return new BigInteger(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为BigInteger
- * 如果给定的值为空,或者转换失败,返回默认值null
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static BigInteger toBigInteger(Object value) - { - return toBigInteger(value, null); - } - - /** - * 转换为BigDecimal
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof BigDecimal) - { - return (BigDecimal) value; - } - if (value instanceof Long) - { - return new BigDecimal((Long) value); - } - if (value instanceof Double) - { - return new BigDecimal((Double) value); - } - if (value instanceof Integer) - { - return new BigDecimal((Integer) value); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return new BigDecimal(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为BigDecimal
- * 如果给定的值为空,或者转换失败,返回默认值
- * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static BigDecimal toBigDecimal(Object value) - { - return toBigDecimal(value, null); - } - - /** - * 将对象转为字符串
- * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 - * @return 字符串 - */ - public static String utf8Str(Object obj) - { - return str(obj, CharsetKit.CHARSET_UTF_8); - } - - /** - * 将对象转为字符串
- * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 - * @param charsetName 字符集 - * @return 字符串 - */ - public static String str(Object obj, String charsetName) - { - return str(obj, Charset.forName(charsetName)); - } - - /** - * 将对象转为字符串
- * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 - * @param charset 字符集 - * @return 字符串 - */ - public static String str(Object obj, Charset charset) - { - if (null == obj) - { - return null; - } - - if (obj instanceof String) - { - return (String) obj; - } - else if (obj instanceof byte[] || obj instanceof Byte[]) - { - return str((Byte[]) obj, charset); - } - else if (obj instanceof ByteBuffer) - { - return str((ByteBuffer) obj, charset); - } - return obj.toString(); - } - - /** - * 将byte数组转为字符串 - * - * @param bytes byte数组 - * @param charset 字符集 - * @return 字符串 - */ - public static String str(byte[] bytes, String charset) - { - return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); - } - - /** - * 解码字节码 - * - * @param data 字符串 - * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 - * @return 解码后的字符串 - */ - public static String str(byte[] data, Charset charset) - { - if (data == null) - { - return null; - } - - if (null == charset) - { - return new String(data); - } - return new String(data, charset); - } - - /** - * 将编码的byteBuffer数据转换为字符串 - * - * @param data 数据 - * @param charset 字符集,如果为空使用当前系统字符集 - * @return 字符串 - */ - public static String str(ByteBuffer data, String charset) - { - if (data == null) - { - return null; - } - - return str(data, Charset.forName(charset)); - } - - /** - * 将编码的byteBuffer数据转换为字符串 - * - * @param data 数据 - * @param charset 字符集,如果为空使用当前系统字符集 - * @return 字符串 - */ - public static String str(ByteBuffer data, Charset charset) - { - if (null == charset) - { - charset = Charset.defaultCharset(); - } - return charset.decode(data).toString(); - } - - // ----------------------------------------------------------------------- 全角半角转换 - /** - * 半角转全角 - * - * @param input String. - * @return 全角字符串. - */ - public static String toSBC(String input) - { - return toSBC(input, null); - } - - /** - * 半角转全角 - * - * @param input String - * @param notConvertSet 不替换的字符集合 - * @return 全角字符串. - */ - public static String toSBC(String input, Set notConvertSet) - { - char c[] = input.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { - // 跳过不替换的字符 - continue; - } - - if (c[i] == ' ') - { - c[i] = '\u3000'; - } - else if (c[i] < '\177') - { - c[i] = (char) (c[i] + 65248); - - } - } - return new String(c); - } - - /** - * 全角转半角 - * - * @param input String. - * @return 半角字符串 - */ - public static String toDBC(String input) - { - return toDBC(input, null); - } - - /** - * 替换全角为半角 - * - * @param text 文本 - * @param notConvertSet 不替换的字符集合 - * @return 替换后的字符 - */ - public static String toDBC(String text, Set notConvertSet) - { - char c[] = text.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { - // 跳过不替换的字符 - continue; - } - - if (c[i] == '\u3000') - { - c[i] = ' '; - } - else if (c[i] > '\uFF00' && c[i] < '\uFF5F') - { - c[i] = (char) (c[i] - 65248); - } - } - String returnString = new String(c); - - return returnString; - } - - /** - * 数字金额大写转换 先写个完整的然后将如零拾替换成零 - * - * @param n 数字 - * @return 中文大写数字 - */ - public static String digitUppercase(double n) - { - String[] fraction = { "角", "分" }; - String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; - String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; - - String head = n < 0 ? "负" : ""; - n = Math.abs(n); - - String s = ""; - for (int i = 0; i < fraction.length; i++) - { - s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); - } - if (s.length() < 1) - { - s = "整"; - } - int integerPart = (int) Math.floor(n); - - for (int i = 0; i < unit[0].length && integerPart > 0; i++) - { - String p = ""; - for (int j = 0; j < unit[1].length && n > 0; j++) - { - p = digit[integerPart % 10] + unit[1][j] + p; - integerPart = integerPart / 10; - } - s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; - } - return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); - } -} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java b/ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java deleted file mode 100644 index d376bc5b..00000000 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.ruoyi.common.utils.text; - -import com.ruoyi.common.utils.StringUtils; - -/** - * 字符串格式化 - * - * @author ruoyi - */ -public class StrFormatter -{ - public static final String EMPTY_JSON = "{}"; - public static final char C_BACKSLASH = '\\'; - public static final char C_DELIM_START = '{'; - public static final char C_DELIM_END = '}'; - - /** - * 格式化字符串
- * 此方法只是简单将占位符 {} 按照顺序替换为参数
- * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
- * 例:
- * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
- * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
- * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
- * - * @param strPattern 字符串模板 - * @param argArray 参数列表 - * @return 结果 - */ - public static String format(final String strPattern, final Object... argArray) - { - if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) - { - return strPattern; - } - final int strPatternLength = strPattern.length(); - - // 初始化定义好的长度以获得更好的性能 - StringBuilder sbuf = new StringBuilder(strPatternLength + 50); - - int handledPosition = 0; - int delimIndex;// 占位符所在位置 - for (int argIndex = 0; argIndex < argArray.length; argIndex++) - { - delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); - if (delimIndex == -1) - { - if (handledPosition == 0) - { - return strPattern; - } - else - { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 - sbuf.append(strPattern, handledPosition, strPatternLength); - return sbuf.toString(); - } - } - else - { - if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) - { - if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) - { - // 转义符之前还有一个转义符,占位符依旧有效 - sbuf.append(strPattern, handledPosition, delimIndex - 1); - sbuf.append(Convert.utf8Str(argArray[argIndex])); - handledPosition = delimIndex + 2; - } - else - { - // 占位符被转义 - argIndex--; - sbuf.append(strPattern, handledPosition, delimIndex - 1); - sbuf.append(C_DELIM_START); - handledPosition = delimIndex + 1; - } - } - else - { - // 正常占位符 - sbuf.append(strPattern, handledPosition, delimIndex); - sbuf.append(Convert.utf8Str(argArray[argIndex])); - handledPosition = delimIndex + 2; - } - } - } - // append the characters following the last {} pair. - // 加入最后一个占位符后所有的字符 - sbuf.append(strPattern, handledPosition, strPattern.length()); - - return sbuf.toString(); - } -} From baea48be6888aee5781468c2224b0dd36c87b52a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 18:10:32 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8C=85=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/project/tool/gen/controller/GenController.java | 2 +- .../project/tool/gen/service/GenTableColumnServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java index 986f777d..f9d1bd99 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java @@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.utils.text.Convert; +import com.ruoyi.common.core.text.Convert; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.controller.BaseController; diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java index ab804ac4..38c6359f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java @@ -3,7 +3,7 @@ package com.ruoyi.project.tool.gen.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.common.utils.text.Convert; +import com.ruoyi.common.core.text.Convert; import com.ruoyi.project.tool.gen.domain.GenTableColumn; import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper; From ab992f4848d663b0ca5dc65883b05ad950eae778 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 21:15:50 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=B2=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=8F=90=E4=BA=A4=E6=B3=A8=E8=A7=A3=E6=97=A0=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/filter/RepeatableFilter.java | 48 +++++++++++ .../filter/RepeatedlyRequestWrapper.java | 84 +++++++++++++++++++ .../common/{xss => filter}/XssFilter.java | 2 +- .../XssHttpServletRequestWrapper.java | 2 +- .../ruoyi/framework/config/FilterConfig.java | 18 +++- .../impl/SameUrlDataInterceptor.java | 31 +++++-- 6 files changed, 172 insertions(+), 13 deletions(-) create mode 100644 ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java create mode 100644 ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java rename ruoyi/src/main/java/com/ruoyi/common/{xss => filter}/XssFilter.java (95%) rename ruoyi/src/main/java/com/ruoyi/common/{xss => filter}/XssHttpServletRequestWrapper.java (95%) diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java new file mode 100644 index 00000000..c3348141 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java @@ -0,0 +1,48 @@ +package com.ruoyi.common.filter; + +import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; + +import com.ruoyi.common.enums.HttpMethod; + +/** + * Repeatable 过滤器 + * + * @author ruoyi + */ +public class RepeatableFilter implements Filter +{ + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + HttpServletRequest req = (HttpServletRequest) request; + if (HttpMethod.PUT.name().equals(req.getMethod()) || HttpMethod.POST.name().equals(req.getMethod())) + { + RepeatedlyRequestWrapper repeatedlyRequest = new RepeatedlyRequestWrapper((HttpServletRequest) request); + chain.doFilter(repeatedlyRequest, response); + } + else + { + chain.doFilter(request, response); + } + } + + @Override + public void destroy() + { + + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java new file mode 100644 index 00000000..f059d375 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java @@ -0,0 +1,84 @@ +package com.ruoyi.common.filter; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import com.ruoyi.common.utils.StringUtils; + +/** + * 构建可重复读取inputStream的request + * + * @author ruoyi + */ +public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper +{ + private final byte[] body; + + public RepeatedlyRequestWrapper(HttpServletRequest request) throws IOException + { + super(request); + body = readBytes(request.getReader(), "utf-8"); + } + + @Override + public BufferedReader getReader() throws IOException + { + return new BufferedReader(new InputStreamReader(getInputStream())); + } + + @Override + public ServletInputStream getInputStream() throws IOException + { + final ByteArrayInputStream bais = new ByteArrayInputStream(body); + return new ServletInputStream() + { + + @Override + public boolean isFinished() + { + return false; + } + + @Override + public boolean isReady() + { + return false; + } + + @Override + public void setReadListener(ReadListener listener) + { + + } + + @Override + public int read() throws IOException + { + return bais.read(); + } + }; + } + + /** + * 通过BufferedReader和字符编码集转换成byte数组 + */ + private byte[] readBytes(BufferedReader br, String encoding) throws IOException + { + String str = null, retStr = ""; + while ((str = br.readLine()) != null) + { + retStr += str; + } + if (StringUtils.isNotBlank(retStr)) + { + return retStr.getBytes(Charset.forName(encoding)); + } + return null; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/xss/XssFilter.java b/ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/xss/XssFilter.java rename to ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java index d307fbc9..14954125 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/xss/XssFilter.java +++ b/ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java @@ -1,4 +1,4 @@ -package com.ruoyi.common.xss; +package com.ruoyi.common.filter; import java.io.IOException; import java.util.ArrayList; diff --git a/ruoyi/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java b/ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java rename to ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java index 1b90c886..12ef5517 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java +++ b/ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java @@ -1,4 +1,4 @@ -package com.ruoyi.common.xss; +package com.ruoyi.common.filter; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java b/ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java index 92d010e8..8b178342 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java @@ -7,8 +7,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import com.ruoyi.common.filter.RepeatableFilter; +import com.ruoyi.common.filter.XssFilter; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.xss.XssFilter; /** * Filter配置 @@ -36,11 +37,24 @@ public class FilterConfig registration.setFilter(new XssFilter()); registration.addUrlPatterns(StringUtils.split(urlPatterns, ",")); registration.setName("xssFilter"); - registration.setOrder(Integer.MAX_VALUE); + registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE); Map initParameters = new HashMap(); initParameters.put("excludes", excludes); initParameters.put("enabled", enabled); registration.setInitParameters(initParameters); return registration; } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + public FilterRegistrationBean someFilterRegistration() + { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new RepeatableFilter()); + registration.addUrlPatterns("/*"); + registration.setName("repeatableFilter"); + registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE); + return registration; + } + } diff --git a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java index 9d915c6e..2c3e14eb 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -2,14 +2,19 @@ package com.ruoyi.framework.interceptor.impl; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.filter.RepeatedlyRequestWrapper; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.http.HttpHelper; import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; +import com.ruoyi.framework.redis.RedisCache; /** - * 判断请求url和数据是否和上一次相同, + * 判断请求url和数据是否和上一次相同, * 如果和上次相同,则是重复提交表单。 有效时间为10秒内。 * * @author ruoyi @@ -23,6 +28,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor public final String SESSION_REPEAT_KEY = "repeatData"; + @Autowired + private RedisCache redisCache; + /** * 间隔时间,单位:秒 默认10秒 * @@ -39,8 +47,14 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor @Override public boolean isRepeatSubmit(HttpServletRequest request) { - // 本次参数及系统时间 - String nowParams = JSONObject.toJSONString(request.getParameterMap()); + RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; + String nowParams = HttpHelper.getBodyString(repeatedlyRequest); + + // body参数为空,获取Parameter的数据 + if (StringUtils.isEmpty(nowParams)) + { + nowParams = JSONObject.toJSONString(request.getParameterMap()); + } Map nowDataMap = new HashMap(); nowDataMap.put(REPEAT_PARAMS, nowParams); nowDataMap.put(REPEAT_TIME, System.currentTimeMillis()); @@ -48,8 +62,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor // 请求地址(作为存放session的key值) String url = request.getRequestURI(); - HttpSession session = request.getSession(); - Object sessionObj = session.getAttribute(SESSION_REPEAT_KEY); + Object sessionObj = redisCache.getCacheObject(SESSION_REPEAT_KEY); if (sessionObj != null) { Map sessionMap = (Map) sessionObj; @@ -62,9 +75,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor } } } - Map sessionMap = new HashMap(); - sessionMap.put(url, nowDataMap); - session.setAttribute(SESSION_REPEAT_KEY, sessionMap); + Map cacheMap = new HashMap(); + cacheMap.put(url, nowDataMap); + redisCache.setCacheObject(SESSION_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS); return false; } From 02062f31e93c00d05a9f445183a45020b7585f06 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 21:18:41 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E9=80=9A=E7=94=A8http=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/utils/http/HttpHelper.java | 56 +++++++++++++++++++ .../impl/SameUrlDataInterceptor.java | 6 +- 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java b/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java new file mode 100644 index 00000000..e7f50b7e --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java @@ -0,0 +1,56 @@ +package com.ruoyi.common.utils.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import javax.servlet.ServletRequest; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 通用http工具封装 + * + * @author ruoyi + */ +public class HttpHelper +{ + private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); + + public static String getBodyString(ServletRequest request) + { + + StringBuilder sb = new StringBuilder(); + BufferedReader reader = null; + try (InputStream inputStream = request.getInputStream()) + { + reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); + String line = ""; + while ((line = reader.readLine()) != null) + { + sb.append(line); + } + } + catch (IOException e) + { + LOGGER.warn("getBodyString出现问题!"); + } + finally + { + if (reader != null) + { + try + { + reader.close(); + } + catch (IOException e) + { + LOGGER.error(ExceptionUtils.getFullStackTrace(e)); + } + } + } + return sb.toString(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java index 2c3e14eb..fd5fa19e 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -26,7 +26,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor public final String REPEAT_TIME = "repeatTime"; - public final String SESSION_REPEAT_KEY = "repeatData"; + public final String CACHE_REPEAT_KEY = "repeatData"; @Autowired private RedisCache redisCache; @@ -62,7 +62,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor // 请求地址(作为存放session的key值) String url = request.getRequestURI(); - Object sessionObj = redisCache.getCacheObject(SESSION_REPEAT_KEY); + Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY); if (sessionObj != null) { Map sessionMap = (Map) sessionObj; @@ -77,7 +77,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor } Map cacheMap = new HashMap(); cacheMap.put(url, nowDataMap); - redisCache.setCacheObject(SESSION_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS); + redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS); return false; } From 7604d59e498cc05f6a5f3744d449c9023d3b571b Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 21:24:26 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=85=AC=E5=91=8A=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/system/controller/SysNoticeController.java | 6 +++--- .../com/ruoyi/project/system/mapper/SysNoticeMapper.java | 2 +- .../com/ruoyi/project/system/service/ISysNoticeService.java | 2 +- .../project/system/service/impl/SysNoticeServiceImpl.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java index 24350533..9f003927 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java @@ -84,9 +84,9 @@ public class SysNoticeController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:notice:remove')") @Log(title = "通知公告", businessType = BusinessType.DELETE) - @DeleteMapping("/{noticeId}") - public AjaxResult remove(@PathVariable Long noticeId) + @DeleteMapping("/{noticeIds}") + public AjaxResult remove(@PathVariable Long[] noticeIds) { - return toAjax(noticeService.deleteNoticeById(noticeId)); + return toAjax(noticeService.deleteNoticeByIds(noticeIds)); } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java b/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java index 2046c7a8..3a9370fd 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java @@ -56,5 +56,5 @@ public interface SysNoticeMapper * @param noticeIds 需要删除的公告ID * @return 结果 */ - public int deleteNoticeByIds(Long noticeIds); + public int deleteNoticeByIds(Long[] noticeIds); } \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java index f45e3911..98bd8902 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java @@ -56,5 +56,5 @@ public interface ISysNoticeService * @param noticeIds 需要删除的公告ID * @return 结果 */ - public int deleteNoticeByIds(Long noticeIds); + public int deleteNoticeByIds(Long[] noticeIds); } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java index ee29660e..8d0f372f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java @@ -84,7 +84,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param noticeIds 需要删除的公告ID * @return 结果 */ - public int deleteNoticeByIds(Long noticeIds) + public int deleteNoticeByIds(Long[] noticeIds) { return noticeMapper.deleteNoticeByIds(noticeIds); } From c0cd030d0fde1df50632b05260b8707d57a47896 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 21:41:57 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E8=A1=A8=E5=89=8D=E7=BC=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/project/tool/gen/util/GenUtils.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java index 59040132..48bbe0b4 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java +++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java @@ -166,12 +166,32 @@ public class GenUtils if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { String[] searchList = StringUtils.split(tablePrefix, ","); - String[] replacementList = emptyList(searchList.length); - tableName = StringUtils.replaceEach(tableName, searchList, replacementList); + tableName = replaceFirst(tableName, searchList); } return StringUtils.convertToCamelCase(tableName); } + /** + * 批量替换前缀 + * + * @param replacementm 替换值 + * @param searchList 替换列表 + * @return + */ + public static String replaceFirst(String replacementm, String[] searchList) + { + String text = StringUtils.EMPTY; + for (String searchString : searchList) + { + if (replacementm.startsWith(searchString)) + { + text = replacementm.replaceFirst(searchString, ""); + break; + } + } + return text; + } + /** * 关键字替换 * @@ -219,20 +239,4 @@ public class GenUtils return 0; } } - - /** - * 获取空数组列表 - * - * @param length 长度 - * @return 数组信息 - */ - public static String[] emptyList(int length) - { - String[] values = new String[length]; - for (int i = 0; i < length; i++) - { - values[i] = StringUtils.EMPTY; - } - return values; - } } \ No newline at end of file From 109c64e7c20e044ee3fa650f0d0599aeb64633e8 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 22:14:58 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E8=A1=A8=E5=89=8D=E7=BC=80=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/filter/RepeatableFilter.java | 15 ++++--- .../filter/RepeatedlyRequestWrapper.java | 44 +++++++------------ .../ruoyi/project/tool/gen/util/GenUtils.java | 2 +- 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java index c3348141..a1125e34 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java +++ b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java @@ -9,8 +9,6 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; -import com.ruoyi.common.enums.HttpMethod; - /** * Repeatable 过滤器 * @@ -28,15 +26,18 @@ public class RepeatableFilter implements Filter public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest) request; - if (HttpMethod.PUT.name().equals(req.getMethod()) || HttpMethod.POST.name().equals(req.getMethod())) + ServletRequest requestWrapper = null; + if (request instanceof HttpServletRequest) { - RepeatedlyRequestWrapper repeatedlyRequest = new RepeatedlyRequestWrapper((HttpServletRequest) request); - chain.doFilter(repeatedlyRequest, response); + requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); + } + if (null == requestWrapper) + { + chain.doFilter(request, response); } else { - chain.doFilter(request, response); + chain.doFilter(requestWrapper, response); } } diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java index f059d375..bd7097f5 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java +++ b/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java @@ -4,12 +4,12 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.nio.charset.Charset; import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; -import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.http.HttpHelper; /** * 构建可重复读取inputStream的request @@ -20,10 +20,13 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper { private final byte[] body; - public RepeatedlyRequestWrapper(HttpServletRequest request) throws IOException + public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException { super(request); - body = readBytes(request.getReader(), "utf-8"); + request.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding("UTF-8"); + + body = HttpHelper.getBodyString(request).getBytes("UTF-8"); } @Override @@ -35,10 +38,18 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper @Override public ServletInputStream getInputStream() throws IOException { + final ByteArrayInputStream bais = new ByteArrayInputStream(body); + return new ServletInputStream() { + @Override + public int read() throws IOException + { + return bais.read(); + } + @Override public boolean isFinished() { @@ -52,33 +63,10 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper } @Override - public void setReadListener(ReadListener listener) + public void setReadListener(ReadListener readListener) { } - - @Override - public int read() throws IOException - { - return bais.read(); - } }; } - - /** - * 通过BufferedReader和字符编码集转换成byte数组 - */ - private byte[] readBytes(BufferedReader br, String encoding) throws IOException - { - String str = null, retStr = ""; - while ((str = br.readLine()) != null) - { - retStr += str; - } - if (StringUtils.isNotBlank(retStr)) - { - return retStr.getBytes(Charset.forName(encoding)); - } - return null; - } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java index 48bbe0b4..047cd2d5 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java +++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java @@ -180,7 +180,7 @@ public class GenUtils */ public static String replaceFirst(String replacementm, String[] searchList) { - String text = StringUtils.EMPTY; + String text = replacementm; for (String searchString : searchList) { if (replacementm.startsWith(searchString)) From af7aa35884672434d76c06146d1f412e0682f1c8 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 14 Mar 2020 10:58:51 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=85=E5=A1=AB=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/system/menu/index.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index 40bb428b..5fac75ff 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -210,6 +210,9 @@ export default { ], orderNum: [ { required: true, message: "菜单顺序不能为空", trigger: "blur" } + ], + path: [ + { required: true, message: "路由地址不能为空", trigger: "blur" } ] } }; From 61142595c4e32a64edb2d9cd20311648691c1873 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 15 Mar 2020 19:53:09 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E5=90=91=E8=B7=AF=E5=BE=84=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/router/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index b2653638..65557f9b 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -32,7 +32,7 @@ export const constantRoutes = [ hidden: true, children: [ { - path: '/redirect/:path*', + path: '/redirect/:path(.*)', component: () => import('@/views/redirect') } ] From 56339214b667d8b77968d00d25061fa40efaa897 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 15 Mar 2020 20:00:01 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E5=8D=87=E7=BA=A7element-ui=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=B02.13.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/package.json | 4 +- .../views/components/icons/element-icons.js | 73 +------------------ 2 files changed, 3 insertions(+), 74 deletions(-) diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 69920443..b16824b7 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -44,7 +44,7 @@ "axios": "0.18.1", "clipboard": "2.0.4", "echarts": "4.2.1", - "element-ui": "2.11.1", + "element-ui": "2.13.0", "file-saver": "2.0.1", "js-beautify": "^1.10.2", "fuse.js": "3.4.4", @@ -56,7 +56,7 @@ "screenfull": "4.2.0", "vue": "2.6.10", "vue-count-to": "1.0.13", - "vue-quill-editor": "3.0.6", + "vue-quill-editor": "3.0.6", "vue-cropper": "0.4.9", "vue-router": "3.0.2", "vue-splitpane": "1.0.4", diff --git a/ruoyi-ui/src/views/components/icons/element-icons.js b/ruoyi-ui/src/views/components/icons/element-icons.js index d9fd6285..ae33ba0e 100644 --- a/ruoyi-ui/src/views/components/icons/element-icons.js +++ b/ruoyi-ui/src/views/components/icons/element-icons.js @@ -1,74 +1,3 @@ -const elementIcons = [ - 'info', - 'error', - 'success', - 'warning', - 'question', - 'back', - 'arrow-left', - 'arrow-down', - 'arrow-right', - 'arrow-up', - 'caret-left', - 'caret-bottom', - 'caret-top', - 'caret-right', - 'd-arrow-left', - 'd-arrow-right', - 'minus', - 'plus', - 'remove', - 'circle-plus', - 'remove-outline', - 'circle-plus-outline', - 'close', - 'check', - 'circle-close', - 'circle-check', - 'circle-close-outline', - 'circle-check-outline', - 'zoom-out', - 'zoom-in', - 'd-caret', - 'sort', - 'sort-down', - 'sort-up', - 'tickets', - 'document', - 'goods', - 'sold-out', - 'news', - 'message', - 'date', - 'printer', - 'time', - 'bell', - 'mobile-phone', - 'service', - 'view', - 'menu', - 'more', - 'more-outline', - 'star-on', - 'star-off', - 'location', - 'location-outline', - 'phone', - 'phone-outline', - 'picture', - 'picture-outline', - 'delete', - 'search', - 'edit', - 'edit-outline', - 'rank', - 'refresh', - 'share', - 'setting', - 'upload', - 'upload2', - 'download', - 'loading' -] +const elementIcons = ['platform-eleme', 'eleme', 'delete-solid', 'delete', 's-tools', 'setting', 'user-solid', 'user', 'phone', 'phone-outline', 'more', 'more-outline', 'star-on', 'star-off', 's-goods', 'goods', 'warning', 'warning-outline', 'question', 'info', 'remove', 'circle-plus', 'success', 'error', 'zoom-in', 'zoom-out', 'remove-outline', 'circle-plus-outline', 'circle-check', 'circle-close', 's-help', 'help', 'minus', 'plus', 'check', 'close', 'picture', 'picture-outline', 'picture-outline-round', 'upload', 'upload2', 'download', 'camera-solid', 'camera', 'video-camera-solid', 'video-camera', 'message-solid', 'bell', 's-cooperation', 's-order', 's-platform', 's-fold', 's-unfold', 's-operation', 's-promotion', 's-home', 's-release', 's-ticket', 's-management', 's-open', 's-shop', 's-marketing', 's-flag', 's-comment', 's-finance', 's-claim', 's-custom', 's-opportunity', 's-data', 's-check', 's-grid', 'menu', 'share', 'd-caret', 'caret-left', 'caret-right', 'caret-bottom', 'caret-top', 'bottom-left', 'bottom-right', 'back', 'right', 'bottom', 'top', 'top-left', 'top-right', 'arrow-left', 'arrow-right', 'arrow-down', 'arrow-up', 'd-arrow-left', 'd-arrow-right', 'video-pause', 'video-play', 'refresh', 'refresh-right', 'refresh-left', 'finished', 'sort', 'sort-up', 'sort-down', 'rank', 'loading', 'view', 'c-scale-to-original', 'date', 'edit', 'edit-outline', 'folder', 'folder-opened', 'folder-add', 'folder-remove', 'folder-delete', 'folder-checked', 'tickets', 'document-remove', 'document-delete', 'document-copy', 'document-checked', 'document', 'document-add', 'printer', 'paperclip', 'takeaway-box', 'search', 'monitor', 'attract', 'mobile', 'scissors', 'umbrella', 'headset', 'brush', 'mouse', 'coordinate', 'magic-stick', 'reading', 'data-line', 'data-board', 'pie-chart', 'data-analysis', 'collection-tag', 'film', 'suitcase', 'suitcase-1', 'receiving', 'collection', 'files', 'notebook-1', 'notebook-2', 'toilet-paper', 'office-building', 'school', 'table-lamp', 'house', 'no-smoking', 'smoking', 'shopping-cart-full', 'shopping-cart-1', 'shopping-cart-2', 'shopping-bag-1', 'shopping-bag-2', 'sold-out', 'sell', 'present', 'box', 'bank-card', 'money', 'coin', 'wallet', 'discount', 'price-tag', 'news', 'guide', 'male', 'female', 'thumb', 'cpu', 'link', 'connection', 'open', 'turn-off', 'set-up', 'chat-round', 'chat-line-round', 'chat-square', 'chat-dot-round', 'chat-dot-square', 'chat-line-square', 'message', 'postcard', 'position', 'turn-off-microphone', 'microphone', 'close-notification', 'bangzhu', 'time', 'odometer', 'crop', 'aim', 'switch-button', 'full-screen', 'copy-document', 'mic', 'stopwatch', 'medal-1', 'medal', 'trophy', 'trophy-1', 'first-aid-kit', 'discover', 'place', 'location', 'location-outline', 'location-information', 'add-location', 'delete-location', 'map-location', 'alarm-clock', 'timer', 'watch-1', 'watch', 'lock', 'unlock', 'key', 'service', 'mobile-phone', 'bicycle', 'truck', 'ship', 'basketball', 'football', 'soccer', 'baseball', 'wind-power', 'light-rain', 'lightning', 'heavy-rain', 'sunrise', 'sunrise-1', 'sunset', 'sunny', 'cloudy', 'partly-cloudy', 'cloudy-and-sunny', 'moon', 'moon-night', 'dish', 'dish-1', 'food', 'chicken', 'fork-spoon', 'knife-fork', 'burger', 'tableware', 'sugar', 'dessert', 'ice-cream', 'hot-water', 'water-cup', 'coffee-cup', 'cold-drink', 'goblet', 'goblet-full', 'goblet-square', 'goblet-square-full', 'refrigerator', 'grape', 'watermelon', 'cherry', 'apple', 'pear', 'orange', 'coffee', 'ice-tea', 'ice-drink', 'milk-tea', 'potato-strips', 'lollipop', 'ice-cream-square', 'ice-cream-round'] export default elementIcons From bc65e59fcb391e69a50f1ef4d26957b2f88f4568 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 15 Mar 2020 20:07:14 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcharts=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E4=BE=A7=E8=BE=B9=E6=A0=8F=E6=88=96=E8=80=85=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E7=AA=97=E5=8F=A3=E6=98=BE=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/dashboard/mixins/resize.js | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/ruoyi-ui/src/views/dashboard/mixins/resize.js b/ruoyi-ui/src/views/dashboard/mixins/resize.js index 55167947..d26194c6 100644 --- a/ruoyi-ui/src/views/dashboard/mixins/resize.js +++ b/ruoyi-ui/src/views/dashboard/mixins/resize.js @@ -3,50 +3,54 @@ import { debounce } from '@/utils' export default { data() { return { - $_sidebarElm: null + $_sidebarElm: null, + $_resizeHandler: null } }, mounted() { - this.$_initResizeEvent() - this.$_initSidebarResizeEvent() - }, - beforeDestroy() { - this.$_destroyResizeEvent() - this.$_destroySidebarResizeEvent() + this.initListener() }, activated() { - this.$_initResizeEvent() - this.$_initSidebarResizeEvent() + if (!this.$_resizeHandler) { + // avoid duplication init + this.initListener() + } + + // when keep-alive chart activated, auto resize + this.resize() + }, + beforeDestroy() { + this.destroyListener() }, deactivated() { - this.$_destroyResizeEvent() - this.$_destroySidebarResizeEvent() + this.destroyListener() }, methods: { - $_resizeHandler() { - return debounce(() => { - if (this.chart) { - this.chart.resize() - } - }, 100)() - }, - $_initResizeEvent() { - window.addEventListener('resize', this.$_resizeHandler) - }, - $_destroyResizeEvent() { - window.removeEventListener('resize', this.$_resizeHandler) - }, + // use $_ for mixins properties + // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential $_sidebarResizeHandler(e) { if (e.propertyName === 'width') { this.$_resizeHandler() } }, - $_initSidebarResizeEvent() { + initListener() { + this.$_resizeHandler = debounce(() => { + this.resize() + }, 100) + window.addEventListener('resize', this.$_resizeHandler) + this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0] this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler) }, - $_destroySidebarResizeEvent() { + destroyListener() { + window.removeEventListener('resize', this.$_resizeHandler) + this.$_resizeHandler = null + this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler) + }, + resize() { + const { chart } = this + chart && chart.resize() } } } From 3b87128461da971dbe949e3c65d7515128a0e5f9 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 15 Mar 2020 20:13:33 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E6=9C=89=E6=97=B6=E4=BC=9A?= =?UTF-8?q?=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/layout/components/Navbar.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index 72bbe063..5c4a3150 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -36,8 +36,8 @@ 布局设置 - - 退出登录 + + 退出登录 From 4bbdc1e87bc4df9e7d41b50388364155720c8723 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 15 Mar 2020 20:25:58 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTagsView=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=EF=BC=8C=E9=BC=A0=E6=A0=87=E6=BB=9A=E8=BD=AE?= =?UTF-8?q?=E6=8C=89=E4=B8=8B=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=85=B3=E9=97=AD=E4=B8=8D=E5=8F=AF=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=9A=84tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/assets/styles/element-ui.scss | 5 +++++ ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue | 2 +- ruoyi-ui/src/layout/components/TagsView/index.vue | 9 ++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ruoyi-ui/src/assets/styles/element-ui.scss b/ruoyi-ui/src/assets/styles/element-ui.scss index 35c224e9..558eea48 100644 --- a/ruoyi-ui/src/assets/styles/element-ui.scss +++ b/ruoyi-ui/src/assets/styles/element-ui.scss @@ -77,3 +77,8 @@ .el-range-editor.el-input__inner { display: inline-flex !important; } + +// to fix el-date-picker css style +.el-range-separator { + box-sizing: content-box; +} diff --git a/ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue b/ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue index 1ca89d2d..1dfd7935 100644 --- a/ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue +++ b/ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue @@ -1,5 +1,5 @@