|
@@ -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 截取后的列类型
|
|
|
*/
|