修复自动去除表前缀配置无效问题

master
RuoYi 6 years ago committed by Limy
parent 66259d6dfa
commit 5e04beaaa0

@ -22,7 +22,7 @@ public class GenConfig
public static String packageName; public static String packageName;
/** 自动去除表前缀默认是true */ /** 自动去除表前缀默认是true */
public static String autoRemovePre; public static boolean autoRemovePre;
/** 表前缀(类名不会包含表前缀) */ /** 表前缀(类名不会包含表前缀) */
public static String tablePrefix; public static String tablePrefix;
@ -49,13 +49,13 @@ public class GenConfig
GenConfig.packageName = packageName; GenConfig.packageName = packageName;
} }
public static String getAutoRemovePre() public static boolean getAutoRemovePre()
{ {
return autoRemovePre; return autoRemovePre;
} }
@Value("${autoRemovePre}") @Value("${autoRemovePre}")
public void setAutoRemovePre(String autoRemovePre) public void setAutoRemovePre(boolean autoRemovePre)
{ {
GenConfig.autoRemovePre = autoRemovePre; GenConfig.autoRemovePre = autoRemovePre;
} }

@ -19,7 +19,7 @@ public class GenUtils
*/ */
public static void initTable(GenTable genTable, String operName) public static void initTable(GenTable genTable, String operName)
{ {
genTable.setClassName(StringUtils.convertToCamelCase(genTable.getTableName())); genTable.setClassName(convertClassName(genTable.getTableName()));
genTable.setPackageName(GenConfig.getPackageName()); genTable.setPackageName(GenConfig.getPackageName());
genTable.setModuleName(getModuleName(GenConfig.getPackageName())); genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
genTable.setBusinessName(getBusinessName(genTable.getTableName())); genTable.setBusinessName(getBusinessName(genTable.getTableName()));
@ -152,6 +152,23 @@ public class GenUtils
return businessName; 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 author: ruoyi
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: com.ruoyi.system packageName: com.ruoyi.system
# 自动去除表前缀,默认是true # 自动去除表前缀,默认是false
autoRemovePre: true autoRemovePre: false
# 表前缀(类名不会包含表前缀) # 表前缀(类名不会包含表前缀)
tablePrefix: sys_ tablePrefix: sys_
Loading…
Cancel
Save