diff --git a/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java b/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java
index 4c87ecd4..1112115d 100644
--- a/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java
+++ b/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java
@@ -63,6 +63,9 @@ public void generate() throws Exception {
TableConfiguration tableConfig = new TableConfiguration(context);
tableConfig.setTableName(generatorConfig.getTableName());
tableConfig.setDomainObjectName(generatorConfig.getDomainObjectName());
+ //添加GeneratedKey主键生成
+ tableConfig.setGeneratedKey(new GeneratedKey(generatorConfig.getGenerateKeys(), selectedDatabaseConfig.getDbType(), true, null));
+
if (generatorConfig.getMapperName() != null) {
tableConfig.setMapperName(generatorConfig.getMapperName());
}
@@ -113,6 +116,13 @@ public void generate() throws Exception {
commentConfig.addProperty("annotations", "true");
}
context.setCommentGeneratorConfiguration(commentConfig);
+
+ //实体添加序列化
+ PluginConfiguration serializablePluginConfiguration = new PluginConfiguration();
+ serializablePluginConfiguration.addProperty("type", "org.mybatis.generator.plugins.SerializablePlugin");
+ serializablePluginConfiguration.setConfigurationType("org.mybatis.generator.plugins.SerializablePlugin");
+ context.addPluginConfiguration(serializablePluginConfiguration);
+
// limit/offset插件
if (generatorConfig.isOffsetLimit()) {
PluginConfiguration pluginConfiguration = new PluginConfiguration();
diff --git a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java
index e4f519d8..e1ebfa7d 100644
--- a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java
+++ b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java
@@ -65,6 +65,8 @@ public class MainUIController extends BaseFXController {
@FXML
private TextField domainObjectNameField;
@FXML
+ private TextField generateKeysField; //添加输入框
+ @FXML
private TextField modelTargetProject;
@FXML
private TextField mappingTargetProject;
@@ -274,6 +276,7 @@ public GeneratorConfig getGeneratorConfigFromUI() {
generatorConfig.setConnectorJarPath(connectorPathField.getText());
generatorConfig.setProjectFolder(projectFolderField.getText());
generatorConfig.setModelPackage(modelTargetPackage.getText());
+ generatorConfig.setGenerateKeys(generateKeysField.getText());
generatorConfig.setModelPackageTargetFolder(modelTargetProject.getText());
generatorConfig.setDaoPackage(daoTargetPackage.getText());
generatorConfig.setDaoTargetFolder(daoTargetProject.getText());
@@ -292,6 +295,7 @@ public void setGeneratorConfigIntoUI(GeneratorConfig generatorConfig) {
connectorPathField.setText(generatorConfig.getConnectorJarPath());
projectFolderField.setText(generatorConfig.getProjectFolder());
modelTargetPackage.setText(generatorConfig.getModelPackage());
+ generateKeysField.setText(generatorConfig.getGenerateKeys());
modelTargetProject.setText(generatorConfig.getModelPackageTargetFolder());
daoTargetPackage.setText(generatorConfig.getDaoPackage());
daoTargetProject.setText(generatorConfig.getDaoTargetFolder());
diff --git a/src/main/java/com/zzg/mybatis/generator/model/GeneratorConfig.java b/src/main/java/com/zzg/mybatis/generator/model/GeneratorConfig.java
index 6e241efe..85aae2bb 100644
--- a/src/main/java/com/zzg/mybatis/generator/model/GeneratorConfig.java
+++ b/src/main/java/com/zzg/mybatis/generator/model/GeneratorConfig.java
@@ -2,160 +2,173 @@
/**
*
- * GeneratorConfig is the Config of mybatis generator config exclude database config
+ * GeneratorConfig is the Config of mybatis generator config exclude database
+ * config
*
* Created by Owen on 6/16/16.
*/
public class GeneratorConfig {
- /**
- * 本配置的名称
- */
- private String name;
+ /**
+ * 本配置的名称
+ */
+ private String name;
- private String connectorJarPath;
+ private String connectorJarPath;
- private String projectFolder;
+ private String projectFolder;
- private String modelPackage;
+ private String modelPackage;
- private String modelPackageTargetFolder;
+ private String modelPackageTargetFolder;
- private String daoPackage;
+ private String daoPackage;
- private String daoTargetFolder;
+ private String daoTargetFolder;
- private String mapperName;
+ private String mapperName;
- private String mappingXMLPackage;
+ private String mappingXMLPackage;
- private String mappingXMLTargetFolder;
+ private String mappingXMLTargetFolder;
- private String tableName;
+ private String tableName;
- private String domainObjectName;
+ private String domainObjectName;
- private boolean offsetLimit;
+ private boolean offsetLimit;
- private boolean comment;
+ private boolean comment;
- private boolean annotation;
+ private boolean annotation;
- public String getName() {
- return name;
- }
+ private String generateKeys;
- public void setName(String name) {
- this.name = name;
- }
+ public String getName() {
+ return name;
+ }
- public String getTableName() {
- return tableName;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
+ public String getTableName() {
+ return tableName;
+ }
- public String getDomainObjectName() {
- return domainObjectName;
- }
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
- public void setDomainObjectName(String domainObjectName) {
- this.domainObjectName = domainObjectName;
- }
+ public String getDomainObjectName() {
+ return domainObjectName;
+ }
- public String getConnectorJarPath() {
- return connectorJarPath;
- }
+ public void setDomainObjectName(String domainObjectName) {
+ this.domainObjectName = domainObjectName;
+ }
- public void setConnectorJarPath(String connectorJarPath) {
- this.connectorJarPath = connectorJarPath;
- }
+ public String getConnectorJarPath() {
+ return connectorJarPath;
+ }
- public String getProjectFolder() {
- return projectFolder;
- }
+ public void setConnectorJarPath(String connectorJarPath) {
+ this.connectorJarPath = connectorJarPath;
+ }
- public void setProjectFolder(String projectFolder) {
- this.projectFolder = projectFolder;
- }
+ public String getProjectFolder() {
+ return projectFolder;
+ }
- public String getModelPackage() {
- return modelPackage;
- }
+ public void setProjectFolder(String projectFolder) {
+ this.projectFolder = projectFolder;
+ }
- public void setModelPackage(String modelPackage) {
- this.modelPackage = modelPackage;
- }
+ public String getModelPackage() {
+ return modelPackage;
+ }
- public String getModelPackageTargetFolder() {
- return modelPackageTargetFolder;
- }
+ public void setModelPackage(String modelPackage) {
+ this.modelPackage = modelPackage;
+ }
- public void setModelPackageTargetFolder(String modelPackageTargetFolder) {
- this.modelPackageTargetFolder = modelPackageTargetFolder;
- }
+ public String getModelPackageTargetFolder() {
+ return modelPackageTargetFolder;
+ }
- public String getDaoPackage() {
- return daoPackage;
- }
+ public void setModelPackageTargetFolder(String modelPackageTargetFolder) {
+ this.modelPackageTargetFolder = modelPackageTargetFolder;
+ }
- public void setDaoPackage(String daoPackage) {
- this.daoPackage = daoPackage;
- }
+ public String getDaoPackage() {
+ return daoPackage;
+ }
- public String getDaoTargetFolder() {
- return daoTargetFolder;
- }
+ public void setDaoPackage(String daoPackage) {
+ this.daoPackage = daoPackage;
+ }
- public void setDaoTargetFolder(String daoTargetFolder) {
- this.daoTargetFolder = daoTargetFolder;
- }
+ public String getDaoTargetFolder() {
+ return daoTargetFolder;
+ }
- public String getMappingXMLPackage() {
- return mappingXMLPackage;
- }
+ public void setDaoTargetFolder(String daoTargetFolder) {
+ this.daoTargetFolder = daoTargetFolder;
+ }
- public void setMappingXMLPackage(String mappingXMLPackage) {
- this.mappingXMLPackage = mappingXMLPackage;
- }
+ public String getMappingXMLPackage() {
+ return mappingXMLPackage;
+ }
- public String getMappingXMLTargetFolder() {
- return mappingXMLTargetFolder;
- }
+ public void setMappingXMLPackage(String mappingXMLPackage) {
+ this.mappingXMLPackage = mappingXMLPackage;
+ }
- public void setMappingXMLTargetFolder(String mappingXMLTargetFolder) {
- this.mappingXMLTargetFolder = mappingXMLTargetFolder;
- }
+ public String getMappingXMLTargetFolder() {
+ return mappingXMLTargetFolder;
+ }
- public boolean isOffsetLimit() {
- return offsetLimit;
- }
+ public void setMappingXMLTargetFolder(String mappingXMLTargetFolder) {
+ this.mappingXMLTargetFolder = mappingXMLTargetFolder;
+ }
- public void setOffsetLimit(boolean offsetLimit) {
- this.offsetLimit = offsetLimit;
- }
+ public boolean isOffsetLimit() {
+ return offsetLimit;
+ }
- public boolean isComment() {
- return comment;
- }
+ public void setOffsetLimit(boolean offsetLimit) {
+ this.offsetLimit = offsetLimit;
+ }
- public void setComment(boolean comment) {
- this.comment = comment;
- }
+ public boolean isComment() {
+ return comment;
+ }
- public boolean isAnnotation(){return annotation;}
+ public void setComment(boolean comment) {
+ this.comment = comment;
+ }
- public void setAnnotation(boolean annotation){
- this.annotation=annotation;
- }
+ public boolean isAnnotation() {
+ return annotation;
+ }
- public String getMapperName() {
- return mapperName;
- }
+ public void setAnnotation(boolean annotation) {
+ this.annotation = annotation;
+ }
- public void setMapperName(String mapperName) {
- this.mapperName = mapperName;
- }
+ public String getMapperName() {
+ return mapperName;
+ }
+
+ public void setMapperName(String mapperName) {
+ this.mapperName = mapperName;
+ }
+
+ public String getGenerateKeys() {
+ return generateKeys;
+ }
+
+ public void setGenerateKeys(String generateKeys) {
+ this.generateKeys = generateKeys;
+ }
}
diff --git a/src/main/resources/fxml/MainUI.fxml b/src/main/resources/fxml/MainUI.fxml
index d96ef902..1f5c04c4 100644
--- a/src/main/resources/fxml/MainUI.fxml
+++ b/src/main/resources/fxml/MainUI.fxml
@@ -120,8 +120,24 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -135,8 +151,8 @@
-
-
+
+
@@ -144,13 +160,13 @@
-
-
+
+
-
-
+
+
@@ -158,13 +174,13 @@
-
-
+
+
-
-
+
+
@@ -172,16 +188,16 @@
-
-
+
+
-
+
-
+
-
+
@@ -195,7 +211,7 @@
-
+