Browse Source

feature: meta field rename

master
vran 3 years ago
parent
commit
643d182d5f
  1. 2
      core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java
  2. 6
      core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java
  3. 2
      core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java
  4. 6
      core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java
  5. 2
      core/src/main/java/com/databasir/core/render/RenderConfig.java
  6. 6
      core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java
  7. 8
      core/src/main/resources/template/render/markdown/markdown.ftlh

2
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<String> columnNames = Collections.emptyList();

6
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<ColumnMeta> columns = Collections.emptyList();

2
core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java

@ -45,7 +45,7 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository {
List<String> 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))

6
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))

2
core/src/main/java/com/databasir/core/render/RenderConfig.java

@ -56,7 +56,7 @@ public class RenderConfig {
protected LinkedHashMap<String, Function<IndexMeta, String>> indexTitleAndValueMapping() {
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("IsUnique", index -> index.getIsUniqueKey() ? "YES" : "");
mapping.put("Columns", index -> String.join(", ", index.getColumnNames()));

6
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);
}

8
core/src/main/resources/template/render/markdown/markdown.ftlh

@ -3,12 +3,12 @@
| 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'} |
</#list>
<#if config.renderTables>
<#list meta.tables as table>
## ${table.tableName}
## ${table.name}
<#if config.renderColumns>
### Columns
@ -16,7 +16,7 @@
| 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!''} |
| ${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>
</#if>
@ -26,7 +26,7 @@
| 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(', ')} |
| ${index_index+1} | ${index.name} | ${index.isUniqueKey?then('YES', 'NO')} | ${index.isPrimaryKey?then('YES','NO')} | ${index.columnNames?join(', ')} |
</#list>
</#if>

Loading…
Cancel
Save