优化网友提供的去表前缀PR

This commit is contained in:
makejava 2020-06-11 17:46:20 +08:00
parent 541414a951
commit 415edcdaa3
2 changed files with 7 additions and 3 deletions

View File

@ -118,8 +118,9 @@ public class CodeGenerateServiceImpl implements CodeGenerateService {
// 生成代码
for (TableInfo tableInfo : tableInfoList) {
// 表名去除前缀
if (tableInfo.getName().startsWith(tableInfo.getPreName())) {
tableInfo.setName(tableInfo.getName().replace(tableInfo.getPreName(), ""));
if (tableInfo.getObj().getName().startsWith(tableInfo.getPreName())) {
String newName = tableInfo.getObj().getName().replace(tableInfo.getPreName(), "");
tableInfo.setName(NameUtils.getInstance().getClassName(newName));
}
// 构建参数
Map<String, Object> param = getDefaultParam();

View File

@ -211,7 +211,7 @@ public class SelectSavePath extends JDialog {
TableInfo tableInfo = tableInfoService.getTableInfoAndConfig(cacheDataUtils.getSelectDbTable());
tableInfo.setSavePath(savePath);
tableInfo.setSavePackageName(packageField.getText());
tableInfo.setPreName(NameUtils.getInstance().firstUpperCase(preField.getText()));
tableInfo.setPreName(preField.getText());
Module module = getSelectModule();
if (module != null) {
tableInfo.setSaveModelName(module.getName());
@ -328,6 +328,9 @@ public class SelectSavePath extends JDialog {
if (!StringUtils.isEmpty(tableInfo.getSavePackageName())) {
packageField.setText(tableInfo.getSavePackageName());
}
if (!StringUtils.isEmpty(tableInfo.getPreName())) {
preField.setText(tableInfo.getPreName());
}
String savePath = tableInfo.getSavePath();
if (!StringUtils.isEmpty(savePath)) {
// 判断是否需要拼接项目路径