瀏覽代碼

fixed github #185 pr

= 7 年之前
父節點
當前提交
e0f11e40ac

+ 3 - 3
mybatis-plus-generate/src/main/java/com/baomidou/mybatisplus/generator/config/rules/NamingStrategy.java

@@ -41,11 +41,11 @@ public enum NamingStrategy {
             return "";
         }
         String tempName = name;
-        StringBuilder result = new StringBuilder();
-        // 大写数字下划线组成转为小写
-        if (StringUtils.isCapitalMode(name)) {
+        // 大写数字下划线组成转为小写 , 允许混合模式转为小写
+        if (StringUtils.isCapitalMode(name) || StringUtils.isMixedMode(name)) {
             tempName = name.toLowerCase();
         }
+        StringBuilder result = new StringBuilder();
         // 用下划线将原始字符串分割
         String camels[] = tempName.split(ConstVal.UNDERLINE);
         for (String camel : camels) {

+ 12 - 0
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/toolkit/StringUtils.java

@@ -374,6 +374,18 @@ public class StringUtils {
         return null != word && word.matches("^[0-9A-Z/_]+$");
     }
 
+    /**
+     * <p>
+     * 是否为驼峰下划线混合命名
+     * </p>
+     *
+     * @param word 待判断字符串
+     * @return
+     */
+    public static boolean isMixedMode(String word) {
+        return Pattern.compile(".*[A-Z]+.*").matcher(word).matches() && Pattern.compile(".*[/_]+.*").matcher(word).matches();
+    }
+
     /**
      * <p>
      * Check if a String ends with a specified suffix.