diff --git a/src/main/java/com/sjhy/plugin/entity/TableInfo.java b/src/main/java/com/sjhy/plugin/entity/TableInfo.java index d4de05d..8010c47 100644 --- a/src/main/java/com/sjhy/plugin/entity/TableInfo.java +++ b/src/main/java/com/sjhy/plugin/entity/TableInfo.java @@ -24,6 +24,10 @@ public class TableInfo { * 表名(首字母大写) */ private String name; + /** + * 表名前缀(首字母大写) + */ + private String preName; /** * 注释 */ diff --git a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java index 5f4930f..c6c04b7 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java @@ -117,6 +117,10 @@ public class CodeGenerateServiceImpl implements CodeGenerateService { TemplateUtils.addGlobalConfig(templates); // 生成代码 for (TableInfo tableInfo : tableInfoList) { + // 表名去除前缀 + if (tableInfo.getName().startsWith(tableInfo.getPreName())) { + tableInfo.setName(tableInfo.getName().replace(tableInfo.getPreName(), "")); + } // 构建参数 Map param = getDefaultParam(); // 其他参数 diff --git a/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java index 097b5b4..1081676 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/TableInfoServiceImpl.java @@ -148,6 +148,8 @@ public class TableInfoServiceImpl implements TableInfoService { tableInfo.setSavePackageName(tableInfoConfig.getSavePackageName()); // 选择的保存路径 tableInfo.setSavePath(tableInfoConfig.getSavePath()); + // 选择的表名前缀 + tableInfo.setPreName(tableInfoConfig.getPreName()); // 没有列时不处理 if (CollectionUtil.isEmpty(tableInfoConfig.getFullColumn())) { diff --git a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form index 56a96a4..0748dc9 100644 --- a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form +++ b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form @@ -3,7 +3,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -141,7 +141,7 @@ - + @@ -149,12 +149,12 @@ - + - + @@ -162,12 +162,29 @@ - + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.java b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.java index a84c906..29a8da0 100644 --- a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.java +++ b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.java @@ -18,10 +18,7 @@ import com.sjhy.plugin.entity.Template; import com.sjhy.plugin.entity.TemplateGroup; import com.sjhy.plugin.service.CodeGenerateService; import com.sjhy.plugin.service.TableInfoService; -import com.sjhy.plugin.tool.CacheDataUtils; -import com.sjhy.plugin.tool.CurrGroupUtils; -import com.sjhy.plugin.tool.ModuleUtils; -import com.sjhy.plugin.tool.StringUtils; +import com.sjhy.plugin.tool.*; import javax.swing.*; import java.awt.*; @@ -64,6 +61,10 @@ public class SelectSavePath extends JDialog { * 路径字段 */ private JTextField pathField; + /** + * 前缀字段 + */ + private JTextField preField; /** * 包选择按钮 */ @@ -206,11 +207,11 @@ public class SelectSavePath extends JDialog { if (!StringUtils.isEmpty(basePath) && savePath.startsWith(basePath)) { savePath = savePath.replace(basePath, "."); } - // 保存配置 TableInfo tableInfo = tableInfoService.getTableInfoAndConfig(cacheDataUtils.getSelectDbTable()); tableInfo.setSavePath(savePath); tableInfo.setSavePackageName(packageField.getText()); + tableInfo.setPreName(NameUtils.getInstance().firstUpperCase(preField.getText())); Module module = getSelectModule(); if (module != null) { tableInfo.setSaveModelName(module.getName()); diff --git a/src/main/resources/string.properties b/src/main/resources/string.properties index 6588add..c35b5d1 100644 --- a/src/main/resources/string.properties +++ b/src/main/resources/string.properties @@ -9,6 +9,7 @@ label.module=&Module: label.ok=&OK label.package=&Package: label.path=&Path: +label.removePre=&RemovePre: label.template=Template: label.template.group=&\u6A21\u677F\u7EC4\uFF1A label.type.mapper=&\u7C7B\u578B\u6620\u5C04\u7EC4\uFF1A