diff --git a/generator/README.md b/generator/README.md index 3dd4657a1..6f6117e17 100644 --- a/generator/README.md +++ b/generator/README.md @@ -254,6 +254,7 @@ ${key} - ${props[key]} 实体和表的信息: 表名:${tableClass.tableName} +表注释:${tableClass.remarks} 变量名:${tableClass.variableName} 小写名:${tableClass.lowerCaseName} 类名:${tableClass.shortClassName} @@ -411,6 +412,7 @@ fileName - ${tableClass.shortClassName}Test.txt 实体和表的信息: 表名:user_info +表注释:用户信息表 变量名:userInfo 小写名:userinfo 类名:UserInfo diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java b/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java index 6e0bfec64..83aaedddd 100644 --- a/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java +++ b/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java @@ -130,8 +130,11 @@ protected String read(InputStream inputStream) throws IOException { StringBuffer stringBuffer = new StringBuffer(); String line = reader.readLine(); while (line != null) { - stringBuffer.append(line).append("\n"); + stringBuffer.append(line); line = reader.readLine(); + if (line != null) { + stringBuffer.append("\n"); + } } return stringBuffer.toString(); } diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java index a51f74106..c391b4cd1 100644 --- a/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java +++ b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java @@ -46,6 +46,7 @@ public class TableClass implements Serializable { private String fullClassName; private String packageName; private FullyQualifiedJavaType type; + private String remarks; private List pkFields; private List baseFields; @@ -147,4 +148,12 @@ public String getVariableName() { public void setVariableName(String variableName) { this.variableName = variableName; } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } } diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java index 7c0ceca5f..e50acb3ee 100644 --- a/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java +++ b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java @@ -48,6 +48,7 @@ public class TableColumnBuilder { public static TableClass build(IntrospectedTable introspectedTable) { TableClass tableClass = new TableClass(); tableClass.setIntrospectedTable(introspectedTable); + tableClass.setRemarks(introspectedTable.getRemarks()); FullyQualifiedTable fullyQualifiedTable = introspectedTable.getFullyQualifiedTable(); tableClass.setTableName(fullyQualifiedTable.getIntrospectedTableName()); diff --git a/generator/src/main/resources/generator/test-all.ftl b/generator/src/main/resources/generator/test-all.ftl index 8fbafe9c8..52fd6c036 100644 --- a/generator/src/main/resources/generator/test-all.ftl +++ b/generator/src/main/resources/generator/test-all.ftl @@ -16,6 +16,7 @@ ${dateTime?string["yyyy-MM-dd HH:mm:ss"]} **************************************************************************************** 实体和表的信息: 表名:${tableClass.tableName} + 表注释:${tableClass.remarks} 变量名:${tableClass.variableName} 小写名:${tableClass.lowerCaseName} 类名:${tableClass.shortClassName} diff --git a/generator/src/main/resources/generator/test-one.ftl b/generator/src/main/resources/generator/test-one.ftl index a26505448..835399063 100644 --- a/generator/src/main/resources/generator/test-one.ftl +++ b/generator/src/main/resources/generator/test-one.ftl @@ -13,6 +13,7 @@ ${dateTime?string["yyyy-MM-dd HH:mm:ss"]} 实体和表的信息: 表名:${tableClass.tableName} +表注释:${tableClass.remarks} 变量名:${tableClass.variableName} 小写名:${tableClass.lowerCaseName} 类名:${tableClass.shortClassName}