Skip to content

Commit

Permalink
添加不生成Example相关代码的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
earayu committed Aug 13, 2017
1 parent b2347aa commit 72e4e72
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void generate() throws Exception {
TableConfiguration tableConfig = new TableConfiguration(context);
tableConfig.setTableName(generatorConfig.getTableName());
tableConfig.setDomainObjectName(generatorConfig.getDomainObjectName());
if(!generatorConfig.isUseExampe()) {
tableConfig.setUpdateByExampleStatementEnabled(false);
tableConfig.setCountByExampleStatementEnabled(false);
tableConfig.setDeleteByExampleStatementEnabled(false);
tableConfig.setSelectByExampleStatementEnabled(false);
}

// 针对 postgresql 单独配置
if (DbType.valueOf(selectedDatabaseConfig.getDbType()).getDriverClass() == "org.postgresql.Driver") {
Expand Down Expand Up @@ -110,6 +116,7 @@ public void generate() throws Exception {
daoConfig.setTargetPackage(generatorConfig.getDaoPackage());
daoConfig.setTargetProject(generatorConfig.getProjectFolder() + "/" + generatorConfig.getDaoTargetFolder());


context.setId("myid");
context.addTableConfiguration(tableConfig);
context.setJdbcConnectionConfiguration(jdbcConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class MainUIController extends BaseFXController {
@FXML
private CheckBox useActualColumnNamesCheckbox;
@FXML
private CheckBox useExample;
@FXML
private TreeView<String> leftDBTree;
// Current selected databaseConfig
private DatabaseConfig selectedDatabaseConfig;
Expand Down Expand Up @@ -303,6 +305,7 @@ public GeneratorConfig getGeneratorConfigFromUI() {
generatorConfig.setNeedToStringHashcodeEquals(needToStringHashcodeEquals.isSelected());
generatorConfig.setAnnotation(annotationCheckBox.isSelected());
generatorConfig.setUseActualColumnNames(useActualColumnNamesCheckbox.isSelected());
generatorConfig.setUseExampe(useExample.isSelected());
return generatorConfig;
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/zzg/mybatis/generator/model/GeneratorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ public class GeneratorConfig {

private boolean useActualColumnNames;

private boolean useExampe;

private String generateKeys;

public boolean isUseExampe() {
return useExampe;
}

public void setUseExampe(boolean useExampe) {
this.useExampe = useExampe;
}

public String getName() {
return name;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/fxml/MainUI.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
<children>
<CheckBox fx:id="annotationCheckBox" mnemonicParsing="false" selected="false" text="生成JPA注解" />
<CheckBox fx:id="useActualColumnNamesCheckbox" mnemonicParsing="false" selected="false" text="使用实际的列名" />
<CheckBox fx:id="useExample" mnemonicParsing="false" selected="false" text="使用Example" />
</children>
</HBox>
</children>
Expand Down
36 changes: 0 additions & 36 deletions src/test/java/com/zzg/mybatis/generator/util/ConfigHelperTest.java

This file was deleted.

41 changes: 0 additions & 41 deletions src/test/java/com/zzg/mybatis/generator/util/StringUtilTest.java

This file was deleted.

0 comments on commit 72e4e72

Please sign in to comment.