From 12c8fa0b2db5f13075fe4a424a296496e3078884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E9=A3=9E!?= <2214508668@qq.com> Date: Tue, 3 Sep 2019 12:39:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0-=E7=94=9F=E6=88=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8E=BB=E9=99=A4=E8=A1=A8=E5=89=8D=E7=BC=80=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sjhy/plugin/entity/TableInfo.java | 4 +++ .../service/impl/CodeGenerateServiceImpl.java | 4 +++ .../service/impl/TableInfoServiceImpl.java | 2 ++ .../com/sjhy/plugin/ui/SelectSavePath.form | 33 ++++++++++++++----- .../com/sjhy/plugin/ui/SelectSavePath.java | 11 ++++--- src/main/resources/string.properties | 1 + 6 files changed, 42 insertions(+), 13 deletions(-) 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 ed4cee0..616c2c8 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java @@ -123,6 +123,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 37bb9af..0df4696 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 05e32b9..e49d74b 100644 --- a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.java +++ b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.java @@ -16,10 +16,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.*; @@ -60,6 +57,10 @@ public class SelectSavePath extends JDialog { * 路径字段 */ private JTextField pathField; + /** + * 前缀字段 + */ + private JTextField preField; /** * 包选择按钮 */ @@ -202,11 +203,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 4646362..2b43b80 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