修复自动去除表前缀配置无效问题
parent
5c7f6b7c7d
commit
1b302b9bde
|
@ -22,7 +22,7 @@ public class GenConfig
|
|||
public static String packageName;
|
||||
|
||||
/** 自动去除表前缀,默认是true */
|
||||
public static String autoRemovePre;
|
||||
public static boolean autoRemovePre;
|
||||
|
||||
/** 表前缀(类名不会包含表前缀) */
|
||||
public static String tablePrefix;
|
||||
|
@ -49,13 +49,13 @@ public class GenConfig
|
|||
GenConfig.packageName = packageName;
|
||||
}
|
||||
|
||||
public static String getAutoRemovePre()
|
||||
public static boolean getAutoRemovePre()
|
||||
{
|
||||
return autoRemovePre;
|
||||
}
|
||||
|
||||
@Value("${autoRemovePre}")
|
||||
public void setAutoRemovePre(String autoRemovePre)
|
||||
public void setAutoRemovePre(boolean autoRemovePre)
|
||||
{
|
||||
GenConfig.autoRemovePre = autoRemovePre;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class GenUtils
|
|||
*/
|
||||
public static void initTable(GenTable genTable, String operName)
|
||||
{
|
||||
genTable.setClassName(StringUtils.convertToCamelCase(genTable.getTableName()));
|
||||
genTable.setClassName(convertClassName(genTable.getTableName()));
|
||||
genTable.setPackageName(GenConfig.getPackageName());
|
||||
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
||||
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
||||
|
@ -152,6 +152,23 @@ public class GenUtils
|
|||
return businessName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表名转换成Java类名
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 类名
|
||||
*/
|
||||
public static String convertClassName(String tableName)
|
||||
{
|
||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||
String tablePrefix = GenConfig.getTablePrefix();
|
||||
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
|
||||
{
|
||||
tableName = tableName.replaceFirst(tablePrefix, "");
|
||||
}
|
||||
return StringUtils.convertToCamelCase(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字替换
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@ gen:
|
|||
author: ruoyi
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.ruoyi.system
|
||||
# 自动去除表前缀,默认是true
|
||||
autoRemovePre: true
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: false
|
||||
# 表前缀(类名不会包含表前缀)
|
||||
tablePrefix: sys_
|
Loading…
Reference in New Issue