From 5bf2ccdf34a78a453d34c4b933cf5bae53f81e54 Mon Sep 17 00:00:00 2001 From: SanLi <2689170096@qq.com> Date: Thu, 25 Jun 2020 21:37:40 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9Emd=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screw/core/engine/EngineFileType.java | 6 +++- .../template/freemarker/documentation_md.ftl | 27 ++++++++++++++++ .../template/velocity/documentation_md.vm | 31 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 screw-core/src/main/resources/template/freemarker/documentation_md.ftl create mode 100644 screw-core/src/main/resources/template/velocity/documentation_md.vm diff --git a/screw-core/src/main/java/cn/smallbun/screw/core/engine/EngineFileType.java b/screw-core/src/main/java/cn/smallbun/screw/core/engine/EngineFileType.java index 1e7d7a5..961fa60 100644 --- a/screw-core/src/main/java/cn/smallbun/screw/core/engine/EngineFileType.java +++ b/screw-core/src/main/java/cn/smallbun/screw/core/engine/EngineFileType.java @@ -41,7 +41,11 @@ public enum EngineFileType implements Serializable { /** * EXCEL */ - EXCEL(".xsl", "documentation_excel", "EXCEL文件"); + EXCEL(".xsl", "documentation_excel", "EXCEL文件"), + /** + * MD + */ + MD(".md", "documentation_md", "Markdown文件"); /** * 文件后缀 diff --git a/screw-core/src/main/resources/template/freemarker/documentation_md.ftl b/screw-core/src/main/resources/template/freemarker/documentation_md.ftl new file mode 100644 index 0000000..0cdfbcd --- /dev/null +++ b/screw-core/src/main/resources/template/freemarker/documentation_md.ftl @@ -0,0 +1,27 @@ +# ${title!'数据库设计文档'} + +**数据库名:** ${database!''} +**文档版本:** ${version!''} +**文档描述:** ${description!''} +| 表名 | 说明 | +| :-------------------- | :--------- | +<#list tables> + <#items as t> + | [${t.tableName!''}](#${t.tableName!''}) | ${t.remarks!''} | + + +<#list tables><#items as t> +**表名:** ${t.tableName!''} + +**说明:** ${t.remarks!''} + +**数据列:** + +<#list t.columns> +| 序号 | 名称 | 数据类型 | 长度 | 小数位 | 允许空值 | 主键 | 默认值 | 说明 | +| :--: | :--- | :------: | :----: | :----: | :------: | :--: | :----: | :--: | +<#items as c> +| ${c?index+1} | ${c.columnName!''} | ${c.typeName!''} | ${c.columnSize!''} | ${c.decimalDigits!'0'} | ${c.nullable!''} | ${c.primaryKey!''} | ${c.columnDef!''} | ${c.remarks!''} | + + + \ No newline at end of file diff --git a/screw-core/src/main/resources/template/velocity/documentation_md.vm b/screw-core/src/main/resources/template/velocity/documentation_md.vm new file mode 100644 index 0000000..683b053 --- /dev/null +++ b/screw-core/src/main/resources/template/velocity/documentation_md.vm @@ -0,0 +1,31 @@ +# #if(${_data.title}) #else 数据库设计文档 #end + +#if(${_data.database}) +**数据库名:** $!{_data.database} + +#end +#if(${_data.version}) +**文档版本:** $!{_data.version} + +#end +#if(${_data.description}) +**文档描述:** $!{_data.description} +#end +| 表名 | 说明 | +| :-------------------- | :--------- | +#foreach($t in $_data.tables) +| [$!{t.tableName}](#$!{t.tableName}) | $!{t.remarks} | +#end +#foreach($t in $_data.tables) +**表名:** $!{t.tableName} + +**说明:** $!{t.remarks} + +**数据列:** + +| 序号 | 名称 | 数据类型 | 长度 | 小数位 | 允许空值 | 主键 | 默认值 | 说明 | +| :--: | :--- | :------: | :----: | :----: | :------: | :--: | :----: | :--: | +#foreach($c in $t.columns) +| $!{velocityCount} | $!{c.columnName} | $!{c.typeName} | $!{c.columnSize} | #if($!{c.decimalDigits})$!{c.decimalDigits}#else 0#end | $!{c.nullable}| $!{c.primaryKey} | $!{c.columnDef} | $!{c.remarks} | +#end +#end \ No newline at end of file