Skip to content

Commit

Permalink
release as v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntungho committed May 24, 2019
1 parent fefb7b5 commit 5022cea
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# mybatis-builder
An IDEA plugin named Mybatis Builder, support IDEA CE specially.
Mybatis Builder is a visual IDEA plugin that integrated with Mybatis Generator, support IDEA CE specially.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ intellij {
}

group 'com.chuntung'
version '1.0'
version '1.0.1'

repositories {
mavenLocal()
mavenCentral()
jcenter()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public TableInfo getTableInfo(TableInfo param) {

@NotNull
private String formatMappingKey(TableInfo tableInfo) {
return tableInfo.getSchema() + "#" + tableInfo.getTableName();
return tableInfo.getDatabase() + "#" + tableInfo.getTableName();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jetbrains.annotations.NotNull;
import org.mybatis.generator.config.JDBCConnectionConfiguration;
import org.mybatis.generator.config.PropertyHolder;
import org.mybatis.generator.config.PropertyRegistry;
import org.mybatis.generator.internal.util.JavaBeansUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -152,6 +153,8 @@ private String populateSelectedTables(MybatisBuilderService service, GeneratorPa
TableInfo lastTableInfo = service.getLastTableInfo(tableInfo);
if (lastTableInfo != null) {
XmlSerializerUtil.copyBean(lastTableInfo, tableInfo);
// fix v1.0.1 upgrade issue: reset since old version use a different name
tableInfo.setDatabase(database);
}

// pre-gen domain name for reference
Expand Down Expand Up @@ -196,7 +199,7 @@ private void populateConnection(GeneratorParamWrapper paramWrapper, ConnectionIn

private void enableSubPackages(PropertyHolder... holders) {
for (PropertyHolder holder : holders) {
holder.addProperty("enableSubPackages", "true");
holder.addProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES, "true");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ public void addConfigurationProperties(Properties properties) {

@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
field.addJavaDocLine("/**");

StringBuilder sb = new StringBuilder();
sb.append(" * Column name: ").append(introspectedColumn.getActualColumnName());
field.addJavaDocLine(sb.toString());

if (StringUtils.isNotBlank(introspectedColumn.getRemarks())) {
field.addJavaDocLine("/**");
StringBuilder sb = new StringBuilder();
sb.append(" * ");
sb.append(introspectedColumn.getRemarks());
sb.setLength(0);
sb.append(" * Column remark: ").append(introspectedColumn.getRemarks().replace('\n', ' '));
field.addJavaDocLine(sb.toString());
field.addJavaDocLine(" */");
}

field.addJavaDocLine(" */");
}

@Override
Expand All @@ -44,7 +49,13 @@ public void addFieldComment(Field field, IntrospectedTable introspectedTable) {

@Override
public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
topLevelClass.addJavaDocLine("/**");

StringBuilder sb = new StringBuilder();
sb.append(" * Table name: ").append(introspectedTable.getFullyQualifiedTable());
topLevelClass.addJavaDocLine(sb.toString());

topLevelClass.addJavaDocLine(" */");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class GeneratorParamWrapper implements Cloneable {
private String endingDelimiter = "`";
private Boolean trimStrings = true;
private Boolean springRepositorySupport = true;
// TODO selectWithLockSupport = true;

private JDBCConnectionConfiguration jdbcConfig = new JDBCConnectionConfiguration();
private JavaModelGeneratorConfiguration javaModelConfig = new JavaModelGeneratorConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void generate() throws InvalidConfigurationException, InterruptedExceptio

// java model config, trim strings
if (Boolean.TRUE.equals(paramWrapper.getTrimStrings())) {
paramWrapper.getJavaModelConfig().addProperty("trimStrings", "true");
paramWrapper.getJavaModelConfig().addProperty(PropertyRegistry.MODEL_GENERATOR_TRIM_STRINGS, "true");
}
context.setJavaModelGeneratorConfiguration(paramWrapper.getJavaModelConfig());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public class SpringRepositoryPlugin extends PluginAdapter {
public SpringRepositoryPlugin() {
}

@Override
public boolean validate(List<String> list) {
return true;
}

@Override
public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
interfaze.addImportedType(this.annotationRepository);
interfaze.addAnnotation(this.annotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

// table info
public class TableInfo {
private String schema;
private String database;
private String tableName;
private String domainName;
private String keyColumn;

public TableInfo() {
}

public TableInfo(String schema, String tableName) {
this.schema = schema;
public TableInfo(String database, String tableName) {
this.database = database;
this.tableName = tableName;
}

public String getSchema() {
return schema;
public String getDatabase() {
return database;
}

public void setSchema(String schema) {
this.schema = schema;
public void setDatabase(String database) {
this.database = database;
}

public String getTableName() {
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<idea-plugin>
<id>com.chuntung.plugin.mybatisbuilder</id>
<name>Mybatis Builder</name>
<version>1.0</version>
<version>1.0.1</version>
<vendor email="[email protected]" url="https://chuntung.com/mybatis-builder">Tony Ho</vendor>

<description><![CDATA[
Expand All @@ -21,6 +21,9 @@
<li>Support Spring @Repository Annotation.</li>
</ul>
</li>
<li>v1.0.1<br>
Improve UI Operation.
</li>
</ul>
]]>
</change-notes>
Expand Down

0 comments on commit 5022cea

Please sign in to comment.