diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java index 72c3081c..3918801a 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java @@ -273,12 +273,14 @@ public class Row extends LinkedHashMap implements UpdateWrapper< } public Object getIgnoreCase(String key) { - String camelKey = null; - if (key.contains("_")) { - camelKey = StringUtil.deleteChar(key, '_'); + Object result = super.get(key); + if (result != null) { + return result; } + + String newKey = StringUtil.deleteChar(key, '_', '-'); for (String innerKey : keySet()) { - if (innerKey.equalsIgnoreCase(key) || (camelKey != null && camelKey.equalsIgnoreCase(innerKey))) { + if (newKey.equalsIgnoreCase(StringUtil.deleteChar(innerKey, '_', '-'))) { return super.get(innerKey); } } @@ -320,7 +322,7 @@ public class Row extends LinkedHashMap implements UpdateWrapper< return defaultValue; } String r = s.toString(); - return r.trim().length() == 0 ? defaultValue : r; + return r.trim().isEmpty() ? defaultValue : r; } public Integer getInt(String key) { diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/StringUtil.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/StringUtil.java index 87ba1a5d..8ec44bad 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/StringUtil.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/StringUtil.java @@ -144,6 +144,20 @@ public class StringUtil { return sb.toString(); } + public static String deleteChar(String string, char deleteChar1, char deleteChar2) { + if (isBlank(string)) { + return ""; + } + char[] chars = string.toCharArray(); + StringBuilder sb = new StringBuilder(string.length()); + for (char aChar : chars) { + if (aChar != deleteChar1 && aChar != deleteChar2) { + sb.append(aChar); + } + } + return sb.toString(); + } + /** * 字符串为 null 或者内部字符全部为 ' ', '\t', '\n', '\r' 这四类字符时返回 true */