feature: meta field rename
This commit is contained in:
parent
75a5412c2b
commit
643d182d5f
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||||
@Builder
|
@Builder
|
||||||
public class IndexMeta {
|
public class IndexMeta {
|
||||||
|
|
||||||
private String indexName;
|
private String name;
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<String> columnNames = Collections.emptyList();
|
private List<String> columnNames = Collections.emptyList();
|
||||||
|
|
|
@ -10,11 +10,11 @@ import java.util.List;
|
||||||
@Builder
|
@Builder
|
||||||
public class TableMeta {
|
public class TableMeta {
|
||||||
|
|
||||||
private String tableName;
|
private String name;
|
||||||
|
|
||||||
private String tableType;
|
private String type;
|
||||||
|
|
||||||
private String tableComment;
|
private String comment;
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<ColumnMeta> columns = Collections.emptyList();
|
private List<ColumnMeta> columns = Collections.emptyList();
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository {
|
||||||
List<String> columns = new ArrayList<>();
|
List<String> columns = new ArrayList<>();
|
||||||
columns.add(columnName);
|
columns.add(columnName);
|
||||||
IndexMeta indexMeta = IndexMeta.builder()
|
IndexMeta indexMeta = IndexMeta.builder()
|
||||||
.indexName(indexName)
|
.name(indexName)
|
||||||
.columnNames(columns)
|
.columnNames(columns)
|
||||||
.isPrimaryKey(Objects.equals("PRIMARY", indexName))
|
.isPrimaryKey(Objects.equals("PRIMARY", indexName))
|
||||||
.isUniqueKey(Objects.equals(nonUnique, false))
|
.isUniqueKey(Objects.equals(nonUnique, false))
|
||||||
|
|
|
@ -50,9 +50,9 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
|
||||||
String tableComment = tablesResult.getString("REMARKS");
|
String tableComment = tablesResult.getString("REMARKS");
|
||||||
TableCondition tableCondition = TableCondition.of(condition, tableName);
|
TableCondition tableCondition = TableCondition.of(condition, tableName);
|
||||||
TableMeta tableMeta = TableMeta.builder()
|
TableMeta tableMeta = TableMeta.builder()
|
||||||
.tableName(tableName)
|
.name(tableName)
|
||||||
.tableType(tableType)
|
.type(tableType)
|
||||||
.tableComment(tableComment)
|
.comment(tableComment)
|
||||||
.columns(columnMetaRepository.selectColumns(connection, tableCondition))
|
.columns(columnMetaRepository.selectColumns(connection, tableCondition))
|
||||||
.indexes(indexMetaRepository.selectIndexes(connection, tableCondition))
|
.indexes(indexMetaRepository.selectIndexes(connection, tableCondition))
|
||||||
.triggers(triggerMetaRepository.selectTriggers(connection, tableCondition))
|
.triggers(triggerMetaRepository.selectTriggers(connection, tableCondition))
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class RenderConfig {
|
||||||
|
|
||||||
protected LinkedHashMap<String, Function<IndexMeta, String>> indexTitleAndValueMapping() {
|
protected LinkedHashMap<String, Function<IndexMeta, String>> indexTitleAndValueMapping() {
|
||||||
LinkedHashMap<String, Function<IndexMeta, String>> mapping = new LinkedHashMap<>();
|
LinkedHashMap<String, Function<IndexMeta, String>> mapping = new LinkedHashMap<>();
|
||||||
mapping.put("Name", IndexMeta::getIndexName);
|
mapping.put("Name", IndexMeta::getName);
|
||||||
mapping.put("IsPrimary", index -> index.getIsPrimaryKey() ? "YES" : "");
|
mapping.put("IsPrimary", index -> index.getIsPrimaryKey() ? "YES" : "");
|
||||||
mapping.put("IsUnique", index -> index.getIsUniqueKey() ? "YES" : "");
|
mapping.put("IsUnique", index -> index.getIsUniqueKey() ? "YES" : "");
|
||||||
mapping.put("Columns", index -> String.join(", ", index.getColumnNames()));
|
mapping.put("Columns", index -> String.join(", ", index.getColumnNames()));
|
||||||
|
|
|
@ -51,10 +51,10 @@ public class MarkdownRender implements Render {
|
||||||
|
|
||||||
private void buildTableName(MarkdownBuilder contentBuilder, TableMeta table) {
|
private void buildTableName(MarkdownBuilder contentBuilder, TableMeta table) {
|
||||||
String tableName;
|
String tableName;
|
||||||
if (table.getTableComment() == null || table.getTableComment().trim().isEmpty()) {
|
if (table.getComment() == null || table.getComment().trim().isEmpty()) {
|
||||||
tableName = table.getTableName();
|
tableName = table.getName();
|
||||||
} else {
|
} else {
|
||||||
tableName = table.getTableName() + "(" + table.getTableComment() + ")";
|
tableName = table.getName() + "(" + table.getComment() + ")";
|
||||||
}
|
}
|
||||||
contentBuilder.secondTitle(tableName);
|
contentBuilder.secondTitle(tableName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
| seq | name | comment |
|
| seq | name | comment |
|
||||||
| ---- | --------------- | ------ |
|
| ---- | --------------- | ------ |
|
||||||
<#list meta.tables as table>
|
<#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'} |
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
<#if config.renderTables>
|
<#if config.renderTables>
|
||||||
<#list meta.tables as table>
|
<#list meta.tables as table>
|
||||||
## ${table.tableName}
|
## ${table.name}
|
||||||
|
|
||||||
<#if config.renderColumns>
|
<#if config.renderColumns>
|
||||||
### Columns
|
### Columns
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
| seq | name | type | nullable | auto increment| default | comment |
|
| seq | name | type | nullable | auto increment| default | comment |
|
||||||
| ---- | ------ | ------ | ------ | -------- | ------ | ------ |
|
| ---- | ------ | ------ | ------ | -------- | ------ | ------ |
|
||||||
<#list table.columns as column>
|
<#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!''} |
|
| ${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!''} |
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
| seq | name | unique | primary key | columns |
|
| seq | name | unique | primary key | columns |
|
||||||
| ---- | ---- | -------- | -------- | ------ |
|
| ---- | ---- | -------- | -------- | ------ |
|
||||||
<#list table.indexes as index>
|
<#list table.indexes as index>
|
||||||
| ${index_index+1} | ${index.indexName} | ${index.isUniqueKey?then('YES', '')} | ${index.isPrimaryKey?then('YES','')} | ${index.columnNames?join(', ')} |
|
| ${index_index+1} | ${index.name} | ${index.isUniqueKey?then('YES', 'NO')} | ${index.isPrimaryKey?then('YES','NO')} | ${index.columnNames?join(', ')} |
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue