diff --git a/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java b/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java index 15f90c7c..41038fc6 100644 --- a/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java +++ b/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java @@ -71,6 +71,10 @@ public static List getTableNames(DatabaseConfig config) throws Exception while (rs.next()) { tables.add(rs.getString(3)); } + + if (tables.size()>1) { + Collections.sort(tables); + } return tables; } finally { connection.close(); diff --git a/src/main/java/com/zzg/mybatis/generator/util/MyStringUtils.java b/src/main/java/com/zzg/mybatis/generator/util/MyStringUtils.java index 66dac9ee..33f4f58c 100644 --- a/src/main/java/com/zzg/mybatis/generator/util/MyStringUtils.java +++ b/src/main/java/com/zzg/mybatis/generator/util/MyStringUtils.java @@ -14,21 +14,27 @@ public class MyStringUtils { */ public static String dbStringToCamelStyle(String str) { if (str != null) { - str = str.toLowerCase(); - StringBuilder sb = new StringBuilder(); - sb.append(String.valueOf(str.charAt(0)).toUpperCase()); - for (int i = 1; i < str.length(); i++) { - char c = str.charAt(i); - if (c != '_') { - sb.append(c); - } else { - if (i + 1 < str.length()) { - sb.append(String.valueOf(str.charAt(i + 1)).toUpperCase()); - i++; + if (str.contains("_")) { + str = str.toLowerCase(); + StringBuilder sb = new StringBuilder(); + sb.append(String.valueOf(str.charAt(0)).toUpperCase()); + for (int i = 1; i < str.length(); i++) { + char c = str.charAt(i); + if (c != '_') { + sb.append(c); + } else { + if (i + 1 < str.length()) { + sb.append(String.valueOf(str.charAt(i + 1)).toUpperCase()); + i++; + } } } + return sb.toString(); + } else { + String firstChar = String.valueOf(str.charAt(0)).toUpperCase(); + String otherChars = str.substring(1); + return firstChar + otherChars; } - return sb.toString(); } return null; }