Prechádzať zdrojové kódy

代码生成器修改

Althars123 2 rokov pred
rodič
commit
d9c0071c7e

+ 13 - 17
sdjk-generator/src/main/java/com/miaxis/generator/util/GenUtils.java

@@ -11,7 +11,7 @@ import java.util.Arrays;
 
 /**
  * 代码生成器 工具类
- * 
+ *
  * @author miaxis
  */
 public class GenUtils
@@ -22,8 +22,8 @@ public class GenUtils
     public static void initTable(GenTable genTable, String operName)
     {
         genTable.setClassName(convertClassName(genTable.getTableName()));
-        genTable.setPackageName(GenConfig.getPackageName());
-        genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
+        genTable.setPackageName(GenConfig.getPackageName()+getModuleName(genTable.getTableName()));
+        genTable.setModuleName(getModuleName(genTable.getTableName()));
         genTable.setBusinessName(getBusinessName(genTable.getTableName()));
         genTable.setFunctionName(replaceText(genTable.getTableComment()));
         genTable.setFunctionAuthor(GenConfig.getAuthor());
@@ -121,7 +121,7 @@ public class GenUtils
 
     /**
      * 校验数组是否包含指定值
-     * 
+     *
      * @param arr 数组
      * @param targetValue 值
      * @return 是否包含
@@ -133,21 +133,17 @@ public class GenUtils
 
     /**
      * 获取模块名
-     * 
-     * @param packageName 包名
+     *
      * @return 模块名
      */
-    public static String getModuleName(String packageName)
+    public static String getModuleName(String tableName)
     {
-        int lastIndex = packageName.lastIndexOf(".");
-        int nameLength = packageName.length();
-        String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
-        return moduleName;
+        return tableName.split("_")[0];
     }
 
     /**
      * 获取业务名
-     * 
+     *
      * @param tableName 表名
      * @return 业务名
      */
@@ -161,7 +157,7 @@ public class GenUtils
 
     /**
      * 表名转换成Java类名
-     * 
+     *
      * @param tableName 表名称
      * @return 类名
      */
@@ -179,7 +175,7 @@ public class GenUtils
 
     /**
      * 批量替换前缀
-     * 
+     *
      * @param replacementm 替换值
      * @param searchList 替换列表
      * @return
@@ -200,7 +196,7 @@ public class GenUtils
 
     /**
      * 关键字替换
-     * 
+     *
      * @param text 需要被替换的名字
      * @return 替换后的名字
      */
@@ -211,7 +207,7 @@ public class GenUtils
 
     /**
      * 获取数据库类型字段
-     * 
+     *
      * @param columnType 列类型
      * @return 截取后的列类型
      */
@@ -229,7 +225,7 @@ public class GenUtils
 
     /**
      * 获取字段长度
-     * 
+     *
      * @param columnType 列类型
      * @return 截取后的列类型
      */

+ 1 - 1
sdjk-generator/src/main/resources/generator.yml

@@ -3,7 +3,7 @@ gen:
   # 作者
   author: miaxis
   # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
-  packageName: com.miaxis.xxx
+  packageName: com.miaxis.
   # 自动去除表前缀,默认是false
   autoRemovePre: false
   # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)