From 04c6a363b983ffeca50ca62fdc60593c97c80df6 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Wed, 17 May 2023 14:25:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B3=A8=E9=87=8A=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E7=94=B1=20remarks=20=E6=94=B9=E4=B8=BA=20comment=20?= =?UTF-8?q?=EF=BC=88ALTER=20TABLE=20`user`=20COMMENT=20=3D=20'=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E8=A1=A8';=EF=BC=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/codegen/Generator.java | 2 +- .../codegen/config/JavadocConfig.java | 12 ++++++------ .../codegen/dialect/JdbcDialect.java | 2 +- .../com/mybatisflex/codegen/entity/Column.java | 18 +++++++++--------- .../com/mybatisflex/codegen/entity/Table.java | 12 ++++++------ .../resources/templates/enjoy/controller.tpl | 2 +- .../main/resources/templates/enjoy/entity.tpl | 4 ++-- .../main/resources/templates/enjoy/mapper.tpl | 2 +- .../main/resources/templates/enjoy/service.tpl | 2 +- .../resources/templates/enjoy/serviceImpl.tpl | 2 +- .../resources/templates/enjoy/tableDef.tpl | 2 +- .../codegen/test/GeneratorTest.java | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java index 65af4dde..547cd610 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java @@ -100,7 +100,7 @@ public class Generator { table.setName(tableName); String remarks = rs.getString("REMARKS"); - table.setRemarks(remarks); + table.setComment(remarks); buildPrimaryKey(table); diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/JavadocConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/JavadocConfig.java index 5c25940a..85b81850 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/JavadocConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/JavadocConfig.java @@ -27,7 +27,7 @@ public class JavadocConfig { /** * 表名格式化。 */ - private Function tableRemarkFormat = Function.identity(); + private Function tableCommentFormat = Function.identity(); public String getAuthor() { return author; @@ -53,15 +53,15 @@ public class JavadocConfig { } public String formatTableComment(String comment) { - return tableRemarkFormat.apply(comment); + return tableCommentFormat.apply(comment); } - public Function getTableRemarkFormat() { - return tableRemarkFormat; + public Function getTableCommentFormat() { + return tableCommentFormat; } - public JavadocConfig setTableRemarkFormat(Function tableRemarkFormat) { - this.tableRemarkFormat = tableRemarkFormat; + public JavadocConfig setTableCommentFormat(Function tableCommentFormat) { + this.tableCommentFormat = tableCommentFormat; return this; } diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/dialect/JdbcDialect.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/dialect/JdbcDialect.java index 686fc2bb..33bacbe3 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/dialect/JdbcDialect.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/dialect/JdbcDialect.java @@ -45,7 +45,7 @@ public abstract class JdbcDialect implements IDialect { column.setAutoIncrement(columnMetaData.isAutoIncrement(i)); //注释 - column.setRemarks(columnRemarks.get(column.getName())); + column.setComment(columnRemarks.get(column.getName())); table.addColumn(column); } diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java index 614e5746..6daef109 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Column.java @@ -30,7 +30,7 @@ public class Column { private String property; private String propertyType; - private String remarks; + private String comment; private boolean isPrimaryKey = false; private Boolean isAutoIncrement; @@ -63,12 +63,12 @@ public class Column { this.propertyType = propertyType; } - public String getRemarks() { - return remarks; + public String getComment() { + return comment; } - public void setRemarks(String remarks) { - this.remarks = remarks; + public void setComment(String comment) { + this.comment = comment; } public boolean isPrimaryKey() { @@ -104,12 +104,12 @@ public class Column { } - public String buildRemarks(){ - if (StringUtil.isBlank(remarks)){ + public String buildComment(){ + if (StringUtil.isBlank(comment)){ return ""; }else { StringBuilder sb = new StringBuilder("/**\n") - .append(" * ").append(remarks).append("\n") + .append(" * ").append(comment).append("\n") .append(" */"); return sb.toString(); } @@ -280,7 +280,7 @@ public class Column { return "Column{" + "name='" + name + '\'' + ", className='" + propertyType + '\'' + - ", remarks='" + remarks + '\'' + + ", remarks='" + comment + '\'' + ", isAutoIncrement=" + isAutoIncrement + '}'; } diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java index 263f3cc5..001b0005 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/entity/Table.java @@ -25,7 +25,7 @@ import java.util.stream.Collectors; public class Table { private String name; - private String remarks; + private String comment; private Set primaryKeys; private List columns = new ArrayList<>(); @@ -40,12 +40,12 @@ public class Table { this.name = name; } - public String getRemarks() { - return globalConfig.getJavadocConfig().formatTableComment(remarks); + public String getComment() { + return globalConfig.getJavadocConfig().formatTableComment(comment); } - public void setRemarks(String remarks) { - this.remarks = remarks; + public void setComment(String comment) { + this.comment = comment; } @@ -295,7 +295,7 @@ public class Table { public String toString() { return "Table{" + "name='" + name + '\'' + - ", remarks='" + remarks + '\'' + + ", remarks='" + comment + '\'' + ", primaryKeys='" + primaryKeys + '\'' + ", columns=" + columns + '}'; diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/controller.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/controller.tpl index 15f49655..338c0811 100644 --- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/controller.tpl +++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/controller.tpl @@ -11,7 +11,7 @@ import #(controllerConfig.buildSuperClassImport()) #end /** - * #(table.getRemarks()) 控制层。 + * #(table.getComment()) 控制层。 * * @author #(javadocConfig.getAuthor()) * @since #(javadocConfig.getSince()) diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/entity.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/entity.tpl index 74621465..14fbd65b 100644 --- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/entity.tpl +++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/entity.tpl @@ -5,7 +5,7 @@ import #(importClass); #end /** - * #(table.getRemarks()) 实体类。 + * #(table.getComment()) 实体类。 * * @author #(javadocConfig.getAuthor()) * @since #(javadocConfig.getSince()) @@ -14,7 +14,7 @@ import #(importClass); public class #(table.buildEntityClassName())#(table.buildExtends())#(table.buildImplements()) { #for(column: table.columns) - #(column.buildRemarks()) + #(column.buildComment()) #(column.buildAnnotations())private #(column.propertySimpleType) #(column.property); #end diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/mapper.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/mapper.tpl index 724c81bc..24040c98 100644 --- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/mapper.tpl +++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/mapper.tpl @@ -4,7 +4,7 @@ import #(mapperConfig.buildSuperClassImport()); import #(packageConfig.entityPackage).#(table.buildEntityClassName()); /** - * #(table.getRemarks()) 映射层。 + * #(table.getComment()) 映射层。 * * @author #(javadocConfig.getAuthor()) * @since #(javadocConfig.getSince()) diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/service.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/service.tpl index 678cf3a5..79d3909a 100644 --- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/service.tpl +++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/service.tpl @@ -4,7 +4,7 @@ import #(serviceConfig.buildSuperClassImport()); import #(packageConfig.entityPackage).#(table.buildEntityClassName()); /** - * #(table.getRemarks()) 服务层。 + * #(table.getComment()) 服务层。 * * @author #(javadocConfig.getAuthor()) * @since #(javadocConfig.getSince()) diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl index a2dcdf11..c5b45e48 100644 --- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl +++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl @@ -7,7 +7,7 @@ import #(packageConfig.servicePackage).#(table.buildServiceClassName()); import org.springframework.stereotype.Service; /** - * #(table.getRemarks()) 服务层实现。 + * #(table.getComment()) 服务层实现。 * * @author #(javadocConfig.getAuthor()) * @since #(javadocConfig.getSince()) diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/tableDef.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/tableDef.tpl index 23b5f031..513eaca2 100644 --- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/tableDef.tpl +++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/tableDef.tpl @@ -4,7 +4,7 @@ import com.mybatisflex.core.query.QueryColumn; import com.mybatisflex.core.table.TableDef; /** - * #(table.getRemarks()) 表定义层。 + * #(table.getComment()) 表定义层。 * * @author #(javadocConfig.getAuthor()) * @since #(javadocConfig.getSince()) diff --git a/mybatis-flex-codegen/src/test/java/com/mybatisflex/codegen/test/GeneratorTest.java b/mybatis-flex-codegen/src/test/java/com/mybatisflex/codegen/test/GeneratorTest.java index 5b0475f3..24d51ba7 100644 --- a/mybatis-flex-codegen/src/test/java/com/mybatisflex/codegen/test/GeneratorTest.java +++ b/mybatis-flex-codegen/src/test/java/com/mybatisflex/codegen/test/GeneratorTest.java @@ -103,7 +103,7 @@ public class GeneratorTest { //设置注解生成配置 globalConfig.getJavadocConfig() .setAuthor("王帅") - .setTableRemarkFormat(format); + .setTableCommentFormat(format); //设置生成文件目录和根包 globalConfig.getPackageConfig()