From 99e7820bc74818d8f0b97d865db3f65761e7424a Mon Sep 17 00:00:00 2001 From: Ricky <11748854@qq.com> Date: Mon, 31 Aug 2020 10:48:52 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E4=BC=A0=E7=A9=BA=E6=97=B6=E6=9F=A5=E8=AF=A2=E5=85=A8?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/constant/Constants.java | 10 ++++++++++ .../ruoyi/common/core/controller/BaseController.java | 7 ++----- .../java/com/ruoyi/common/core/page/TableSupport.java | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) 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 109511b18..0433be867 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 @@ -51,11 +51,21 @@ public class Constants * 当前记录起始索引 */ public static final String PAGE_NUM = "pageNum"; + + /** + * 当前记录起始索引默认值 + */ + public static final int PAGE_NUM_DEFAULT_VALUE = 1; /** * 每页显示记录数 */ public static final String PAGE_SIZE = "pageSize"; + + /** + * 每页显示记录数默认值 + */ + public static final int PAGE_SIZE_DEFAULT_VALUE = 10; /** * 排序列 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index f21285364..627405e0a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -56,11 +56,8 @@ public class BaseController PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) - { - String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - PageHelper.startPage(pageNum, pageSize, orderBy); - } + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.startPage(pageNum, pageSize, orderBy); } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java index 0efd82b32..4589439f6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java @@ -16,8 +16,8 @@ public class TableSupport public static PageDomain getPageDomain() { PageDomain pageDomain = new PageDomain(); - pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM)); - pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE)); + pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM, Constants.PAGE_NUM_DEFAULT_VALUE)); + pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE, Constants.PAGE_SIZE_DEFAULT_VALUE)); pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN)); pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC)); return pageDomain; From 1f0d4abee104d48aa6a9e6617bddfe23db4e6f33 Mon Sep 17 00:00:00 2001 From: wsy <28511238@qq.com> Date: Wed, 2 Sep 2020 15:38:03 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=A1=A8=E7=9A=84=E5=AD=97=E6=AE=B5=E6=98=AF=E9=A6=96?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E5=A4=A7=E5=86=99=E7=9A=84=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E6=B2=A1=E6=9C=89=E7=94=A8=E4=B8=8B=E5=88=92=E7=BA=BF?= =?UTF-8?q?=E5=88=86=E5=89=B2=EF=BC=88=E6=AF=94=E5=A6=82=E5=AD=97=E6=AE=B5?= =?UTF-8?q?PrjID=EF=BC=89=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E7=94=A8=E5=A4=A7=E5=86=99=E9=A6=96=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?domain=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D=E3=80=82=20=E8=80=8C?= =?UTF-8?q?=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84controller=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9Ejson?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E4=BC=9A=E5=AF=B9=E9=A6=96?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E8=87=AA=E5=8A=A8=E8=BD=AC=E5=B0=8F=E5=86=99?= =?UTF-8?q?(=E8=BF=94=E5=9B=9E=E7=9A=84json=E4=B8=AD=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=98=AFprjID)=EF=BC=8C=20=E8=80=8C=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=AD=97=E6=AE=B5=E7=94=A8=E7=9A=84=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E5=A4=A7=E5=86=99=E9=A6=96=E5=AD=97=E6=AF=8D=E7=9A=84=E5=90=8D?= =?UTF-8?q?=E5=AD=97=EF=BC=88PrjID=EF=BC=89=EF=BC=8C=E4=BA=8E=E6=98=AF?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E5=B0=B1=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=BF=99=E4=BA=9B=E5=AD=97=E6=AE=B5=E4=BA=86?= =?UTF-8?q?=E3=80=82=20=E5=9C=A8ruoyi-fast=204.3.1=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E8=BF=98=E6=B2=A1=E6=9C=89=E2=80=9Cif=20(s.i?= =?UTF-8?q?ndexOf(SEPARATOR)=20=3D=3D=20-1)=20return=20s=E2=80=9D=20?= =?UTF-8?q?=E8=BF=99=E5=8F=A5=E8=AF=9D=EF=BC=8C=E8=BD=AC=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D=E6=98=AF=E5=85=A8=E5=B0=8F?= =?UTF-8?q?=E5=86=99=E7=9A=84=EF=BC=88prjid=EF=BC=89=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E4=BB=A5=E5=89=8D=E5=90=8E=E7=AB=AF=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?=E9=83=BD=E6=98=AF=E4=B8=80=E6=A0=B7=E7=9A=84=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E4=BA=A7=E7=94=9F=E5=AE=9E=E9=99=85=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/StringUtils.java | 822 +++++++++--------- 1 file changed, 414 insertions(+), 408 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java index 51174f1ea..ea774ff91 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -1,408 +1,414 @@ -package com.ruoyi.common.utils; - -import java.util.Collection; -import java.util.Map; -import com.ruoyi.common.core.text.StrFormatter; - -/** - * 字符串工具类 - * - * @author ruoyi - */ -public class StringUtils extends org.apache.commons.lang3.StringUtils -{ - /** 空字符串 */ - private static final String NULLSTR = ""; - - /** 下划线 */ - private static final char SEPARATOR = '_'; - - /** - * 获取参数不为空值 - * - * @param value defaultValue 要判断的value - * @return value 返回值 - */ - public static T nvl(T value, T defaultValue) - { - return value != null ? value : defaultValue; - } - - /** - * * 判断一个Collection是否为空, 包含List,Set,Queue - * - * @param coll 要判断的Collection - * @return true:为空 false:非空 - */ - public static boolean isEmpty(Collection coll) - { - return isNull(coll) || coll.isEmpty(); - } - - /** - * * 判断一个Collection是否非空,包含List,Set,Queue - * - * @param coll 要判断的Collection - * @return true:非空 false:空 - */ - public static boolean isNotEmpty(Collection coll) - { - return !isEmpty(coll); - } - - /** - * * 判断一个对象数组是否为空 - * - * @param objects 要判断的对象数组 - ** @return true:为空 false:非空 - */ - public static boolean isEmpty(Object[] objects) - { - return isNull(objects) || (objects.length == 0); - } - - /** - * * 判断一个对象数组是否非空 - * - * @param objects 要判断的对象数组 - * @return true:非空 false:空 - */ - public static boolean isNotEmpty(Object[] objects) - { - return !isEmpty(objects); - } - - /** - * * 判断一个Map是否为空 - * - * @param map 要判断的Map - * @return true:为空 false:非空 - */ - public static boolean isEmpty(Map map) - { - return isNull(map) || map.isEmpty(); - } - - /** - * * 判断一个Map是否为空 - * - * @param map 要判断的Map - * @return true:非空 false:空 - */ - public static boolean isNotEmpty(Map map) - { - return !isEmpty(map); - } - - /** - * * 判断一个字符串是否为空串 - * - * @param str String - * @return true:为空 false:非空 - */ - public static boolean isEmpty(String str) - { - return isNull(str) || NULLSTR.equals(str.trim()); - } - - /** - * * 判断一个字符串是否为非空串 - * - * @param str String - * @return true:非空串 false:空串 - */ - public static boolean isNotEmpty(String str) - { - return !isEmpty(str); - } - - /** - * * 判断一个对象是否为空 - * - * @param object Object - * @return true:为空 false:非空 - */ - public static boolean isNull(Object object) - { - return object == null; - } - - /** - * * 判断一个对象是否非空 - * - * @param object Object - * @return true:非空 false:空 - */ - public static boolean isNotNull(Object object) - { - return !isNull(object); - } - - /** - * * 判断一个对象是否是数组类型(Java基本型别的数组) - * - * @param object 对象 - * @return true:是数组 false:不是数组 - */ - public static boolean isArray(Object object) - { - return isNotNull(object) && object.getClass().isArray(); - } - - /** - * 去空格 - */ - public static String trim(String str) - { - return (str == null ? "" : str.trim()); - } - - /** - * 截取字符串 - * - * @param str 字符串 - * @param start 开始 - * @return 结果 - */ - public static String substring(final String str, int start) - { - if (str == null) - { - return NULLSTR; - } - - if (start < 0) - { - start = str.length() + start; - } - - if (start < 0) - { - start = 0; - } - if (start > str.length()) - { - return NULLSTR; - } - - return str.substring(start); - } - - /** - * 截取字符串 - * - * @param str 字符串 - * @param start 开始 - * @param end 结束 - * @return 结果 - */ - public static String substring(final String str, int start, int end) - { - if (str == null) - { - return NULLSTR; - } - - if (end < 0) - { - end = str.length() + end; - } - if (start < 0) - { - start = str.length() + start; - } - - if (end > str.length()) - { - end = str.length(); - } - - if (start > end) - { - return NULLSTR; - } - - if (start < 0) - { - start = 0; - } - if (end < 0) - { - end = 0; - } - - return str.substring(start, 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 template 文本模板,被替换的部分用 {} 表示 - * @param params 参数值 - * @return 格式化后的文本 - */ - public static String format(String template, Object... params) - { - if (isEmpty(params) || isEmpty(template)) - { - return template; - } - return StrFormatter.format(template, params); - } - - /** - * 下划线转驼峰命名 - */ - public static String toUnderScoreCase(String str) - { - if (str == null) - { - return null; - } - StringBuilder sb = new StringBuilder(); - // 前置字符是否大写 - boolean preCharIsUpperCase = true; - // 当前字符是否大写 - boolean curreCharIsUpperCase = true; - // 下一字符是否大写 - boolean nexteCharIsUpperCase = true; - for (int i = 0; i < str.length(); i++) - { - char c = str.charAt(i); - if (i > 0) - { - preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); - } - else - { - preCharIsUpperCase = false; - } - - curreCharIsUpperCase = Character.isUpperCase(c); - - if (i < (str.length() - 1)) - { - nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); - } - - if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) - { - sb.append(SEPARATOR); - } - else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) - { - sb.append(SEPARATOR); - } - sb.append(Character.toLowerCase(c)); - } - return sb.toString(); - } - - /** - * 是否包含字符串 - * - * @param str 验证字符串 - * @param strs 字符串组 - * @return 包含返回true - */ - public static boolean inStringIgnoreCase(String str, String... strs) - { - if (str != null && strs != null) - { - for (String s : strs) - { - if (str.equalsIgnoreCase(trim(s))) - { - return true; - } - } - } - return false; - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld - * - * @param name 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String convertToCamelCase(String name) - { - StringBuilder result = new StringBuilder(); - // 快速检查 - if (name == null || name.isEmpty()) - { - // 没必要转换 - return ""; - } - else if (!name.contains("_")) - { - // 不含下划线,仅将首字母大写 - return name.substring(0, 1).toUpperCase() + name.substring(1); - } - // 用下划线将原始字符串分割 - String[] camels = name.split("_"); - for (String camel : camels) - { - // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) - { - continue; - } - // 首字母大写 - result.append(camel.substring(0, 1).toUpperCase()); - result.append(camel.substring(1).toLowerCase()); - } - return result.toString(); - } - - /** - * 驼峰式命名法 - * 例如:user_name->userName - */ - public static String toCamelCase(String s) - { - if (s == null) - { - return null; - } - if (s.indexOf(SEPARATOR) == -1) - { - return s; - } - s = s.toLowerCase(); - StringBuilder sb = new StringBuilder(s.length()); - boolean upperCase = false; - for (int i = 0; i < s.length(); i++) - { - char c = s.charAt(i); - - if (c == SEPARATOR) - { - upperCase = true; - } - else if (upperCase) - { - sb.append(Character.toUpperCase(c)); - upperCase = false; - } - else - { - sb.append(c); - } - } - return sb.toString(); - } - - @SuppressWarnings("unchecked") - public static T cast(Object obj) - { - return (T) obj; - } -} +package com.ruoyi.common.utils; + +import java.util.Collection; +import java.util.Map; +import com.ruoyi.common.core.text.StrFormatter; + +/** + * 字符串工具类 + * + * @author ruoyi + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils +{ + /** 空字符串 */ + private static final String NULLSTR = ""; + + /** 下划线 */ + private static final char SEPARATOR = '_'; + + /** + * 获取参数不为空值 + * + * @param value defaultValue 要判断的value + * @return value 返回值 + */ + public static T nvl(T value, T defaultValue) + { + return value != null ? value : defaultValue; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) + { + return isNull(coll) || coll.isEmpty(); + } + + /** + * * 判断一个Collection是否非空,包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Collection coll) + { + return !isEmpty(coll); + } + + /** + * * 判断一个对象数组是否为空 + * + * @param objects 要判断的对象数组 + ** @return true:为空 false:非空 + */ + public static boolean isEmpty(Object[] objects) + { + return isNull(objects) || (objects.length == 0); + } + + /** + * * 判断一个对象数组是否非空 + * + * @param objects 要判断的对象数组 + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Object[] objects) + { + return !isEmpty(objects); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Map map) + { + return isNull(map) || map.isEmpty(); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Map map) + { + return !isEmpty(map); + } + + /** + * * 判断一个字符串是否为空串 + * + * @param str String + * @return true:为空 false:非空 + */ + public static boolean isEmpty(String str) + { + return isNull(str) || NULLSTR.equals(str.trim()); + } + + /** + * * 判断一个字符串是否为非空串 + * + * @param str String + * @return true:非空串 false:空串 + */ + public static boolean isNotEmpty(String str) + { + return !isEmpty(str); + } + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) + { + return object == null; + } + + /** + * * 判断一个对象是否非空 + * + * @param object Object + * @return true:非空 false:空 + */ + public static boolean isNotNull(Object object) + { + return !isNull(object); + } + + /** + * * 判断一个对象是否是数组类型(Java基本型别的数组) + * + * @param object 对象 + * @return true:是数组 false:不是数组 + */ + public static boolean isArray(Object object) + { + return isNotNull(object) && object.getClass().isArray(); + } + + /** + * 去空格 + */ + public static String trim(String str) + { + return (str == null ? "" : str.trim()); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @return 结果 + */ + public static String substring(final String str, int start) + { + if (str == null) + { + return NULLSTR; + } + + if (start < 0) + { + start = str.length() + start; + } + + if (start < 0) + { + start = 0; + } + if (start > str.length()) + { + return NULLSTR; + } + + return str.substring(start); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @param end 结束 + * @return 结果 + */ + public static String substring(final String str, int start, int end) + { + if (str == null) + { + return NULLSTR; + } + + if (end < 0) + { + end = str.length() + end; + } + if (start < 0) + { + start = str.length() + start; + } + + if (end > str.length()) + { + end = str.length(); + } + + if (start > end) + { + return NULLSTR; + } + + if (start < 0) + { + start = 0; + } + if (end < 0) + { + end = 0; + } + + return str.substring(start, 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 template 文本模板,被替换的部分用 {} 表示 + * @param params 参数值 + * @return 格式化后的文本 + */ + public static String format(String template, Object... params) + { + if (isEmpty(params) || isEmpty(template)) + { + return template; + } + return StrFormatter.format(template, params); + } + + /** + * 下划线转驼峰命名 + */ + public static String toUnderScoreCase(String str) + { + if (str == null) + { + return null; + } + StringBuilder sb = new StringBuilder(); + // 前置字符是否大写 + boolean preCharIsUpperCase = true; + // 当前字符是否大写 + boolean curreCharIsUpperCase = true; + // 下一字符是否大写 + boolean nexteCharIsUpperCase = true; + for (int i = 0; i < str.length(); i++) + { + char c = str.charAt(i); + if (i > 0) + { + preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); + } + else + { + preCharIsUpperCase = false; + } + + curreCharIsUpperCase = Character.isUpperCase(c); + + if (i < (str.length() - 1)) + { + nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); + } + + if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) + { + sb.append(SEPARATOR); + } + else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) + { + sb.append(SEPARATOR); + } + sb.append(Character.toLowerCase(c)); + } + return sb.toString(); + } + + /** + * 是否包含字符串 + * + * @param str 验证字符串 + * @param strs 字符串组 + * @return 包含返回true + */ + public static boolean inStringIgnoreCase(String str, String... strs) + { + if (str != null && strs != null) + { + for (String s : strs) + { + if (str.equalsIgnoreCase(trim(s))) + { + return true; + } + } + } + return false; + } + + /** + * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld + * + * @param name 转换前的下划线大写方式命名的字符串 + * @return 转换后的驼峰式命名的字符串 + */ + public static String convertToCamelCase(String name) + { + StringBuilder result = new StringBuilder(); + // 快速检查 + if (name == null || name.isEmpty()) + { + // 没必要转换 + return ""; + } + else if (!name.contains("_")) + { + // 不含下划线,仅将首字母大写 + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + // 用下划线将原始字符串分割 + String[] camels = name.split("_"); + for (String camel : camels) + { + // 跳过原始字符串中开头、结尾的下换线或双重下划线 + if (camel.isEmpty()) + { + continue; + } + // 首字母大写 + result.append(camel.substring(0, 1).toUpperCase()); + result.append(camel.substring(1).toLowerCase()); + } + return result.toString(); + } + + /** + * 驼峰式命名法 + * 例如:user_name->userName + */ + public static String toCamelCase(String s) + { + if (s == null) + { + return null; + } + if (s.indexOf(SEPARATOR) == -1) + { + if (s.length()>0 && Character.isUpperCase(s.charAt(0))) { + StringBuilder sb = new StringBuilder(s.length()); + sb.append(Character.toLowerCase(s.charAt(0))); + sb.append(s.substring(1)); + return sb.toString(); + } + return s; + } + s = s.toLowerCase(); + StringBuilder sb = new StringBuilder(s.length()); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + + if (c == SEPARATOR) + { + upperCase = true; + } + else if (upperCase) + { + sb.append(Character.toUpperCase(c)); + upperCase = false; + } + else + { + sb.append(c); + } + } + return sb.toString(); + } + + @SuppressWarnings("unchecked") + public static T cast(Object obj) + { + return (T) obj; + } +} From 4f2a32e733d0a73ff719c07713c36e8730983991 Mon Sep 17 00:00:00 2001 From: wsy <28511238@qq.com> Date: Fri, 25 Sep 2020 09:43:58 +0800 Subject: [PATCH 3/5] =?UTF-8?q?Revert=20"=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E4=BC=A0=E7=A9=BA=E6=97=B6=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=85=A8=E8=A1=A8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 99e7820bc74818d8f0b97d865db3f65761e7424a. --- .../main/java/com/ruoyi/common/constant/Constants.java | 10 ---------- .../ruoyi/common/core/controller/BaseController.java | 7 +++++-- .../java/com/ruoyi/common/core/page/TableSupport.java | 4 ++-- 3 files changed, 7 insertions(+), 14 deletions(-) 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 0433be867..109511b18 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 @@ -51,21 +51,11 @@ public class Constants * 当前记录起始索引 */ public static final String PAGE_NUM = "pageNum"; - - /** - * 当前记录起始索引默认值 - */ - public static final int PAGE_NUM_DEFAULT_VALUE = 1; /** * 每页显示记录数 */ public static final String PAGE_SIZE = "pageSize"; - - /** - * 每页显示记录数默认值 - */ - public static final int PAGE_SIZE_DEFAULT_VALUE = 10; /** * 排序列 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index 627405e0a..f21285364 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -56,8 +56,11 @@ public class BaseController PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); - String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - PageHelper.startPage(pageNum, pageSize, orderBy); + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.startPage(pageNum, pageSize, orderBy); + } } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java index 4589439f6..0efd82b32 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java @@ -16,8 +16,8 @@ public class TableSupport public static PageDomain getPageDomain() { PageDomain pageDomain = new PageDomain(); - pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM, Constants.PAGE_NUM_DEFAULT_VALUE)); - pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE, Constants.PAGE_SIZE_DEFAULT_VALUE)); + pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM)); + pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE)); pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN)); pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC)); return pageDomain; From dff48b64ec7dabcec1149c18568e0e6824a5a704 Mon Sep 17 00:00:00 2001 From: wsy <28511238@qq.com> Date: Fri, 25 Sep 2020 09:46:26 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Revert=20"=E5=A6=82=E6=9E=9C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=A1=A8=E7=9A=84=E5=AD=97=E6=AE=B5=E6=98=AF?= =?UTF-8?q?=E9=A6=96=E5=AD=97=E6=AF=8D=E5=A4=A7=E5=86=99=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E6=B2=A1=E6=9C=89=E7=94=A8=E4=B8=8B=E5=88=92?= =?UTF-8?q?=E7=BA=BF=E5=88=86=E5=89=B2=EF=BC=88=E6=AF=94=E5=A6=82=E5=AD=97?= =?UTF-8?q?=E6=AE=B5PrjID=EF=BC=89=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=94=A8=E5=A4=A7=E5=86=99=E9=A6=96=E5=AD=97?= =?UTF-8?q?=E6=AF=8D=E4=BD=9C=E4=B8=BA=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84domain=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D=E3=80=82=20?= =?UTF-8?q?=E8=80=8C=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84controller=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9Ejson=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=AF=B9=E9=A6=96=E5=AD=97=E6=AF=8D=E8=87=AA=E5=8A=A8=E8=BD=AC?= =?UTF-8?q?=E5=B0=8F=E5=86=99(=E8=BF=94=E5=9B=9E=E7=9A=84json=E4=B8=AD?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=98=AFprjID)=EF=BC=8C=20=E8=80=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84=E5=89=8D=E7=AB=AF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=BB=91=E5=AE=9A=E5=AD=97=E6=AE=B5=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E5=A4=A7=E5=86=99=E9=A6=96=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E7=9A=84=E5=90=8D=E5=AD=97=EF=BC=88PrjID=EF=BC=89=EF=BC=8C?= =?UTF-8?q?=E4=BA=8E=E6=98=AF=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E5=B0=B1?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E6=98=BE=E7=A4=BA=E8=BF=99=E4=BA=9B=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BA=86=E3=80=82=20=E5=9C=A8ruoyi-fast=204.3.1?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E5=9B=A0=E4=B8=BA=E8=BF=98=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E2=80=9Cif=20(s.indexOf(SEPARATOR)=20=3D=3D=20-1)=20return=20s?= =?UTF-8?q?=E2=80=9D=20=E8=BF=99=E5=8F=A5=E8=AF=9D=EF=BC=8C=E8=BD=AC?= =?UTF-8?q?=E5=87=BA=E6=9D=A5=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D=E6=98=AF?= =?UTF-8?q?=E5=85=A8=E5=B0=8F=E5=86=99=E7=9A=84=EF=BC=88prjid=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E6=89=80=E4=BB=A5=E5=89=8D=E5=90=8E=E7=AB=AF=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E9=83=BD=E6=98=AF=E4=B8=80=E6=A0=B7=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E4=BA=A7=E7=94=9F=E5=AE=9E=E9=99=85=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1f0d4abe --- .../com/ruoyi/common/utils/StringUtils.java | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java index ea774ff91..19b825c8b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -6,7 +6,7 @@ import com.ruoyi.common.core.text.StrFormatter; /** * 字符串工具类 - * + * * @author ruoyi */ public class StringUtils extends org.apache.commons.lang3.StringUtils @@ -19,7 +19,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 获取参数不为空值 - * + * * @param value defaultValue 要判断的value * @return value 返回值 */ @@ -30,7 +30,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个Collection是否为空, 包含List,Set,Queue - * + * * @param coll 要判断的Collection * @return true:为空 false:非空 */ @@ -41,7 +41,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个Collection是否非空,包含List,Set,Queue - * + * * @param coll 要判断的Collection * @return true:非空 false:空 */ @@ -52,7 +52,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个对象数组是否为空 - * + * * @param objects 要判断的对象数组 ** @return true:为空 false:非空 */ @@ -63,7 +63,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个对象数组是否非空 - * + * * @param objects 要判断的对象数组 * @return true:非空 false:空 */ @@ -74,7 +74,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个Map是否为空 - * + * * @param map 要判断的Map * @return true:为空 false:非空 */ @@ -85,7 +85,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个Map是否为空 - * + * * @param map 要判断的Map * @return true:非空 false:空 */ @@ -96,7 +96,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个字符串是否为空串 - * + * * @param str String * @return true:为空 false:非空 */ @@ -107,7 +107,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个字符串是否为非空串 - * + * * @param str String * @return true:非空串 false:空串 */ @@ -118,7 +118,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个对象是否为空 - * + * * @param object Object * @return true:为空 false:非空 */ @@ -129,7 +129,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个对象是否非空 - * + * * @param object Object * @return true:非空 false:空 */ @@ -140,7 +140,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * * 判断一个对象是否是数组类型(Java基本型别的数组) - * + * * @param object 对象 * @return true:是数组 false:不是数组 */ @@ -159,7 +159,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 截取字符串 - * + * * @param str 字符串 * @param start 开始 * @return 结果 @@ -190,7 +190,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 截取字符串 - * + * * @param str 字符串 * @param start 开始 * @param end 结束 @@ -242,7 +242,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils * 通常使用: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 template 文本模板,被替换的部分用 {} 表示 * @param params 参数值 * @return 格式化后的文本 @@ -306,7 +306,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 是否包含字符串 - * + * * @param str 验证字符串 * @param strs 字符串组 * @return 包含返回true @@ -328,7 +328,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld - * + * * @param name 转换前的下划线大写方式命名的字符串 * @return 转换后的驼峰式命名的字符串 */ @@ -374,12 +374,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } if (s.indexOf(SEPARATOR) == -1) { - if (s.length()>0 && Character.isUpperCase(s.charAt(0))) { - StringBuilder sb = new StringBuilder(s.length()); - sb.append(Character.toLowerCase(s.charAt(0))); - sb.append(s.substring(1)); - return sb.toString(); - } return s; } s = s.toLowerCase(); From d9f139411d27a7f4afb94ee4336d114b4a148f81 Mon Sep 17 00:00:00 2001 From: wsy <28511238@qq.com> Date: Fri, 25 Sep 2020 09:59:06 +0800 Subject: [PATCH 5/5] =?UTF-8?q?*=EF=BC=89=E5=A6=82=E6=9E=9C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=A1=A8=E7=9A=84=E5=AD=97=E6=AE=B5=E6=98=AF?= =?UTF-8?q?=E9=A6=96=E5=AD=97=E6=AF=8D=E5=A4=A7=E5=86=99=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E6=B2=A1=E6=9C=89=E7=94=A8=E4=B8=8B=E5=88=92?= =?UTF-8?q?=E7=BA=BF=E5=88=86=E5=89=B2=EF=BC=88=E6=AF=94=E5=A6=82=E5=AD=97?= =?UTF-8?q?=E6=AE=B5PrjID=EF=BC=89=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=94=A8=E5=A4=A7=E5=86=99=E9=A6=96=E5=AD=97?= =?UTF-8?q?=E6=AF=8D=E4=BD=9C=E4=B8=BA=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84domain=E7=9A=84=E5=B1=9E=E6=80=A7=E5=90=8D=E3=80=82=20?= =?UTF-8?q?=20=20=E8=80=8C=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84controller=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9Ejson=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E5=AF=B9=E9=A6=96=E5=AD=97=E6=AF=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=BD=AC=E5=B0=8F=E5=86=99(=E8=BF=94=E5=9B=9E=E7=9A=84json?= =?UTF-8?q?=E4=B8=AD=E5=B1=9E=E6=80=A7=E6=98=AFprjID)=EF=BC=8C=20=20=20?= =?UTF-8?q?=E8=80=8C=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E9=A1=B5=E9=9D=A2=E7=BB=91=E5=AE=9A=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E8=BF=98=E6=98=AF=E5=A4=A7=E5=86=99=E9=A6=96?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E7=9A=84=E5=90=8D=E5=AD=97=EF=BC=88PrjID?= =?UTF-8?q?=EF=BC=89=EF=BC=8C=E4=BA=8E=E6=98=AF=E5=89=8D=E7=AB=AF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=B0=B1=E4=B8=8D=E4=BC=9A=E6=98=BE=E7=A4=BA=E8=BF=99?= =?UTF-8?q?=E4=BA=9B=E5=AD=97=E6=AE=B5=E4=BA=86=E3=80=82=20=20=20=E5=9C=A8?= =?UTF-8?q?ruoyi-fast=204.3.1=E4=B8=AD=EF=BC=8C=E5=9B=A0=E4=B8=BA=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E2=80=9Cif=20(s.indexOf(SEPARATOR)=20=3D=3D?= =?UTF-8?q?=20-1)=20return=20s=E2=80=9D=20=E8=BF=99=E5=8F=A5=E8=AF=9D?= =?UTF-8?q?=EF=BC=8C=E8=BD=AC=E5=87=BA=E6=9D=A5=E7=9A=84=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=90=8D=E6=98=AF=E5=85=A8=E5=B0=8F=E5=86=99=E7=9A=84=EF=BC=88?= =?UTF-8?q?prjid=EF=BC=89=EF=BC=8C=E6=89=80=E4=BB=A5=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E7=94=9F=E6=88=90=E7=9A=84=E9=83=BD=E6=98=AF=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=EF=BC=8C=E6=9C=AA=E4=BA=A7=E7=94=9F=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/StringUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java index 19b825c8b..01eebe8e4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -374,6 +374,12 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } if (s.indexOf(SEPARATOR) == -1) { + if (s.length()>0 && Character.isUpperCase(s.charAt(0))) { + StringBuilder sb = new StringBuilder(s.length()); + sb.append(Character.toLowerCase(s.charAt(0))); + sb.append(s.substring(1)); + return sb.toString(); + } return s; } s = s.toLowerCase();