Skip to content

Commit

Permalink
增加生成mapper中SQL的数据库名Schema前缀选择开关,增加原生打包的readme说明部分,以及Mac和Win的两种图标
Browse files Browse the repository at this point in the history
  • Loading branch information
it-noob committed Apr 8, 2018
1 parent 7276af8 commit 14af6da
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,23 @@ mybatis-generator-gui是基于[mybatis generator](http://www.mybatis.org/generat
cd target/jfx/app/
java -jar mybatis-generator-gui.jar
```

* 方法二: IDE中运行

Eclipse or IntelliJ IDEA中启动, 找到```com.zzg.mybatis.generator.MainUI```类并运行就可以了

- 方法三:打包为本地原生应用,双击快捷方式即可启动,方便快捷

如果不想打包后的安装包logo为Java的灰色的茶杯,需要在pom文件里将对应操作系统平台的图标注释放开

```bash
#<icon>${project.basedir}/package/windows/mybatis-generator-gui.ico</icon>为windows
#<icon>${project.basedir}/package/macosx/mybatis-generator-gui.icns</icon>为mac
mvn jfx:native
```

​ 另外需要注意,windows系统打包成exe的话需要安装WiXToolset3+的环境;由于打包后会把jre打入安装包,两个平台均100M左右,体积较大请自行打包;打包后的安装包在target/jfx/native目录下


### 文档
更多详细文档请参考本库的Wiki
Expand Down
Binary file added package/macosx/mybatis-generator-gui.icns
Binary file not shown.
Binary file added package/windows/mybatis-generator-gui.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<bundleArguments>
<!-- windows打包开启-->
<icon>${project.basedir}/package/windows/mybatis-generator-gui.ico</icon>
<!-- mac打包开启-->
<icon>${project.basedir}/package/macosx/mybatis-generator-gui.icns</icon>
</bundleArguments>
<mainClass>com.zzg.mybatis.generator.MainUI</mainClass>
<vendor>Owen Zou</vendor>
<verbose>false</verbose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ public void generate() throws Exception {
} else {
tableConfig.setCatalog(selectedDatabaseConfig.getSchema());
}

if (generatorConfig.isUseSchemaPrefix()) {
if (DbType.MySQL.name().equals(selectedDatabaseConfig.getDbType())) {
tableConfig.setSchema(selectedDatabaseConfig.getSchema());
} else if (DbType.Oracle.name().equals(selectedDatabaseConfig.getDbType())) {
//Oracle的schema为用户名,如果连接用户拥有dba等高级权限,若不设schema,会导致把其他用户下同名的表也生成一遍导致mapper中代码重复
tableConfig.setSchema(selectedDatabaseConfig.getUsername());
} else {
tableConfig.setCatalog(selectedDatabaseConfig.getSchema());
}
}
// 针对 postgresql 单独配置
if (DbType.valueOf(selectedDatabaseConfig.getDbType()).getDriverClass() == "org.postgresql.Driver") {
tableConfig.setDelimitIdentifiers(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public class MainUIController extends BaseFXController {
@FXML
private CheckBox useExample;
@FXML
private CheckBox useSchemaPrefix;
@FXML
private TreeView<String> leftDBTree;
// Current selected databaseConfig
private DatabaseConfig selectedDatabaseConfig;
Expand Down Expand Up @@ -321,6 +323,7 @@ public GeneratorConfig getGeneratorConfigFromUI() {
generatorConfig.setUseActualColumnNames(useActualColumnNamesCheckbox.isSelected());
generatorConfig.setEncoding(encodingChoice.getValue());
generatorConfig.setUseExampe(useExample.isSelected());
generatorConfig.setUseSchemaPrefix(useSchemaPrefix.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 @@ -56,6 +56,16 @@ public class GeneratorConfig {

private boolean useTableNameAlias;

private boolean useSchemaPrefix;

public boolean isUseSchemaPrefix() {
return useSchemaPrefix;
}

public void setUseSchemaPrefix(boolean useSchemaPrefix) {
this.useSchemaPrefix = useSchemaPrefix;
}

public boolean isUseExampe() {
return useExampe;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/fxml/MainUI.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,18 @@
<CheckBox fx:id="commentCheckBox" mnemonicParsing="false" selected="true" text="生成实体域注释(来自表注释)" />
</children>
</HBox>
<HBox>
<HBox spacing="18.0">
<children>
<CheckBox fx:id="needToStringHashcodeEquals" mnemonicParsing="false" selected="true" text="生成toString/hashCode/equals方法" />
<CheckBox fx:id="useSchemaPrefix" mnemonicParsing="false" selected="false" text="使用Schema前缀" />
</children>
</HBox>
<HBox spacing="18.0">
<children>
<CheckBox fx:id="annotationCheckBox" mnemonicParsing="false" selected="false" text="生成JPA注解" />
<CheckBox fx:id="useActualColumnNamesCheckbox" mnemonicParsing="false" selected="false" text="使用实际的列名" />
<CheckBox fx:id="useTableNameAliasCheckbox" mnemonicParsing="false" selected="false" text="启用as别名查询" />
<CheckBox fx:id="useExample" mnemonicParsing="false" selected="true" text="使用Example" />
<CheckBox fx:id="useTableNameAliasCheckbox" mnemonicParsing="false" selected="false" text="启用as别名查询" />
<CheckBox fx:id="useExample" mnemonicParsing="false" selected="true" text="使用Example" />
</children>
</HBox>
</children>
Expand Down

0 comments on commit 14af6da

Please sign in to comment.