From 643d182d5fc539c23eb531819f3c68071649981d Mon Sep 17 00:00:00 2001 From: vran Date: Fri, 31 Dec 2021 12:32:11 +0800 Subject: [PATCH] feature: meta field rename --- .../databasir/core/meta/pojo/IndexMeta.java | 2 +- .../databasir/core/meta/pojo/TableMeta.java | 6 ++--- .../impl/jdbc/JdbcIndexMetaRepository.java | 2 +- .../impl/jdbc/JdbcTableMetaRepository.java | 6 ++--- .../databasir/core/render/RenderConfig.java | 2 +- .../core/render/markdown/MarkdownRender.java | 6 ++--- .../template/render/markdown/markdown.ftlh | 26 +++++++++---------- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java b/core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java index c878555..4cc5640 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java +++ b/core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java @@ -10,7 +10,7 @@ import java.util.List; @Builder public class IndexMeta { - private String indexName; + private String name; @Builder.Default private List columnNames = Collections.emptyList(); diff --git a/core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java b/core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java index b98ff2d..9953bbe 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java +++ b/core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java @@ -10,11 +10,11 @@ import java.util.List; @Builder public class TableMeta { - private String tableName; + private String name; - private String tableType; + private String type; - private String tableComment; + private String comment; @Builder.Default private List columns = Collections.emptyList(); diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java b/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java index 745657e..130e9eb 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java +++ b/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java @@ -45,7 +45,7 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository { List columns = new ArrayList<>(); columns.add(columnName); IndexMeta indexMeta = IndexMeta.builder() - .indexName(indexName) + .name(indexName) .columnNames(columns) .isPrimaryKey(Objects.equals("PRIMARY", indexName)) .isUniqueKey(Objects.equals(nonUnique, false)) diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java b/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java index 2f06d68..1e6904b 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java +++ b/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java @@ -50,9 +50,9 @@ public class JdbcTableMetaRepository implements TableMetaRepository { String tableComment = tablesResult.getString("REMARKS"); TableCondition tableCondition = TableCondition.of(condition, tableName); TableMeta tableMeta = TableMeta.builder() - .tableName(tableName) - .tableType(tableType) - .tableComment(tableComment) + .name(tableName) + .type(tableType) + .comment(tableComment) .columns(columnMetaRepository.selectColumns(connection, tableCondition)) .indexes(indexMetaRepository.selectIndexes(connection, tableCondition)) .triggers(triggerMetaRepository.selectTriggers(connection, tableCondition)) diff --git a/core/src/main/java/com/databasir/core/render/RenderConfig.java b/core/src/main/java/com/databasir/core/render/RenderConfig.java index bf26357..bbe84e0 100644 --- a/core/src/main/java/com/databasir/core/render/RenderConfig.java +++ b/core/src/main/java/com/databasir/core/render/RenderConfig.java @@ -56,7 +56,7 @@ public class RenderConfig { protected LinkedHashMap> indexTitleAndValueMapping() { LinkedHashMap> mapping = new LinkedHashMap<>(); - mapping.put("Name", IndexMeta::getIndexName); + mapping.put("Name", IndexMeta::getName); mapping.put("IsPrimary", index -> index.getIsPrimaryKey() ? "YES" : ""); mapping.put("IsUnique", index -> index.getIsUniqueKey() ? "YES" : ""); mapping.put("Columns", index -> String.join(", ", index.getColumnNames())); diff --git a/core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java b/core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java index 44856f3..1e73cdf 100644 --- a/core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java +++ b/core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java @@ -51,10 +51,10 @@ public class MarkdownRender implements Render { private void buildTableName(MarkdownBuilder contentBuilder, TableMeta table) { String tableName; - if (table.getTableComment() == null || table.getTableComment().trim().isEmpty()) { - tableName = table.getTableName(); + if (table.getComment() == null || table.getComment().trim().isEmpty()) { + tableName = table.getName(); } else { - tableName = table.getTableName() + "(" + table.getTableComment() + ")"; + tableName = table.getName() + "(" + table.getComment() + ")"; } contentBuilder.secondTitle(tableName); } diff --git a/core/src/main/resources/template/render/markdown/markdown.ftlh b/core/src/main/resources/template/render/markdown/markdown.ftlh index ab8169c..3a1536c 100644 --- a/core/src/main/resources/template/render/markdown/markdown.ftlh +++ b/core/src/main/resources/template/render/markdown/markdown.ftlh @@ -3,31 +3,31 @@ | seq | name | comment | | ---- | --------------- | ------ | <#list meta.tables as table> -| ${table_index+1} | [${table.tableName}](#${table.tableName}) | ${table.tableComment!'N/A'} | + | ${table_index+1} | [${table.name}](#${table.name}) | ${table.comment!'N/A'} | <#if config.renderTables> <#list meta.tables as table> -## ${table.tableName} + ## ${table.name} - <#if config.renderColumns> -### Columns + <#if config.renderColumns> + ### Columns -| seq | name | type | nullable | auto increment| default | comment | -| ---- | ------ | ------ | ------ | -------- | ------ | ------ | -<#list table.columns as column> -| ${column_index+1} | ${column.name} | ${column.type} | ${column.isNullable?then('YES','')} | ${column.isAutoIncrement?then('YES', '')} | ${column.isNullable?then(column.defaultValue!'NULL', column.defaultValue!'')} | ${column.comment!''} | - - + | seq | name | type | nullable | auto increment| default | comment | + | ---- | ------ | ------ | ------ | -------- | ------ | ------ | + <#list table.columns as column> + | ${column_index+1} | ${column.name} | ${column.type} | ${column.isNullable?then('YES','NO')} | ${column.isAutoIncrement?then('YES', 'NO')} | ${column.isNullable?then(column.defaultValue!'NULL', column.defaultValue!'')} | ${column.comment!''} | + + <#if config.renderIndexes> ### Indexes | seq | name | unique | primary key | columns | | ---- | ---- | -------- | -------- | ------ | -<#list table.indexes as index> -| ${index_index+1} | ${index.indexName} | ${index.isUniqueKey?then('YES', '')} | ${index.isPrimaryKey?then('YES','')} | ${index.columnNames?join(', ')} | - + <#list table.indexes as index> + | ${index_index+1} | ${index.name} | ${index.isUniqueKey?then('YES', 'NO')} | ${index.isPrimaryKey?then('YES','NO')} | ${index.columnNames?join(', ')} | + <#if config.renderTriggers>