feat: remove table column comment
This commit is contained in:
parent
1dc0e10210
commit
acadf15789
|
@ -41,19 +41,16 @@ public interface DocumentResponseConverter {
|
|||
List<TableTriggerDocument> triggers);
|
||||
|
||||
TableDocumentResponse.ColumnDocumentResponse of(TableColumnDocument pojo,
|
||||
Integer discussionCount,
|
||||
String description);
|
||||
|
||||
default List<TableDocumentResponse.ColumnDocumentResponse> of(
|
||||
List<TableColumnDocument> columns,
|
||||
String tableName,
|
||||
Map<String, Integer> discussionCountMapByJoinName,
|
||||
Map<String, String> descriptionMapByJoinName) {
|
||||
return columns.stream()
|
||||
.map(column -> {
|
||||
Integer count = discussionCountMapByJoinName.get(tableName + "." + column.getName());
|
||||
String description = descriptionMapByJoinName.get(tableName + "." + column.getName());
|
||||
return of(column, count, description);
|
||||
return of(column, description);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -70,7 +67,7 @@ public interface DocumentResponseConverter {
|
|||
default TableDocumentResponse ofDiff(TableDocDiff table,
|
||||
Map<String, Integer> discussionCountMap,
|
||||
Map<String, String> descriptionMap) {
|
||||
List<TableDocumentResponse.ColumnDocumentResponse> cols = toColumns(table, discussionCountMap, descriptionMap);
|
||||
List<TableDocumentResponse.ColumnDocumentResponse> cols = toColumns(table, descriptionMap);
|
||||
return ofDiff(table, cols, discussionCountMap, descriptionMap);
|
||||
}
|
||||
|
||||
|
@ -83,30 +80,26 @@ public interface DocumentResponseConverter {
|
|||
Map<String, String> descriptionMap);
|
||||
|
||||
default List<TableDocumentResponse.ColumnDocumentResponse> toColumns(TableDocDiff table,
|
||||
Map<String, Integer> discussionCountMap,
|
||||
Map<String, String> descriptionMap) {
|
||||
return table.getColumns()
|
||||
.stream()
|
||||
.map(col -> toColumn(table.getName(), col, discussionCountMap, descriptionMap))
|
||||
.map(col -> toColumn(table.getName(), col, descriptionMap))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Mapping(target = "description", expression = "java(descriptionMap.get(tableName+\".\"+diff.getName()))")
|
||||
@Mapping(target = "discussionCount", expression = "java(discussionCountMap.get(tableName+\".\"+diff.getName()))")
|
||||
@Mapping(target = "original",
|
||||
expression = "java(toOriginalColumn(tableName, diff.getOriginal(), discussionCountMap, descriptionMap))")
|
||||
expression = "java(toOriginalColumn(tableName, diff.getOriginal(), descriptionMap))")
|
||||
TableDocumentResponse.ColumnDocumentResponse toColumn(String tableName,
|
||||
ColumnDocDiff diff,
|
||||
Map<String, Integer> discussionCountMap,
|
||||
Map<String, String> descriptionMap);
|
||||
|
||||
default TableDocumentResponse.ColumnDocumentResponse toOriginalColumn(String tableName,
|
||||
ColumnDocDiff diff,
|
||||
Map<String, Integer> discussionCountMap,
|
||||
Map<String, String> descriptionMap) {
|
||||
if (diff == null) {
|
||||
return null;
|
||||
}
|
||||
return toColumn(tableName, diff, discussionCountMap, descriptionMap);
|
||||
return toColumn(tableName, diff, descriptionMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,8 +74,6 @@ public class TableDocumentResponse implements DiffAble<TableDocumentResponse> {
|
|||
|
||||
private String defaultValue;
|
||||
|
||||
private Integer discussionCount;
|
||||
|
||||
private LocalDateTime createAt;
|
||||
|
||||
private DiffType diffType;
|
||||
|
|
|
@ -5,10 +5,7 @@ import com.databasir.core.domain.document.data.diff.*;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -37,6 +34,7 @@ public class DocumentDiffChecker {
|
|||
.map(curr -> {
|
||||
List<ColumnDocDiff> columnDiffs =
|
||||
doDiff(Collections.emptyList(), curr.getColumns(), ColumnDocDiff::getName);
|
||||
columnDiffs.sort(Comparator.comparingInt(c -> c.getId()));
|
||||
List<IndexDocDiff> indexDiffs =
|
||||
doDiff(Collections.emptyList(), curr.getIndexes(), IndexDocDiff::getName);
|
||||
List<TriggerDocDiff> triggerDiffs =
|
||||
|
@ -65,6 +63,7 @@ public class DocumentDiffChecker {
|
|||
.map(old -> {
|
||||
List<ColumnDocDiff> columnDiffs =
|
||||
doDiff(old.getColumns(), Collections.emptyList(), ColumnDocDiff::getName);
|
||||
columnDiffs.sort(Comparator.comparingInt(c -> c.getId()));
|
||||
List<IndexDocDiff> indexDiffs =
|
||||
doDiff(old.getIndexes(), Collections.emptyList(), IndexDocDiff::getName);
|
||||
List<TriggerDocDiff> triggerDiffs =
|
||||
|
@ -98,6 +97,7 @@ public class DocumentDiffChecker {
|
|||
|
||||
List<ColumnDocDiff> columnDiffs =
|
||||
doDiff(originalTable.getColumns(), currentTable.getColumns(), ColumnDocDiff::getName);
|
||||
columnDiffs.sort(Comparator.comparingInt(c -> c.getId()));
|
||||
List<IndexDocDiff> indexDiffs =
|
||||
doDiff(originalTable.getIndexes(), currentTable.getIndexes(), IndexDocDiff::getName);
|
||||
List<TriggerDocDiff> triggerDiffs =
|
||||
|
|
|
@ -82,7 +82,7 @@ public class DocumentService {
|
|||
|
||||
return documentOption.map(document -> {
|
||||
var discussionCountMapByTableName =
|
||||
documentDiscussionDao.selectTableDiscussionCount(projectId)
|
||||
documentDiscussionDao.selectAllDiscussionCount(projectId)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(d -> d.getTableName(), d -> d.getCount(), (a, b) -> a));
|
||||
var descriptionMapByTableName =
|
||||
|
@ -218,9 +218,7 @@ public class DocumentService {
|
|||
var discussions = documentDiscussionDao.selectAllDiscussionCount(projectId);
|
||||
Map<String, Integer> discussionCountMapByJoinName = discussions.stream()
|
||||
.collect(Collectors.toMap(
|
||||
d -> String.join(".",
|
||||
d.getTableName(),
|
||||
StringUtils.defaultIfBlank(d.getColumnName(), "")),
|
||||
d -> d.getTableName(),
|
||||
DocumentDiscussionCountPojo::getCount,
|
||||
(a, b) -> a));
|
||||
|
||||
|
@ -246,7 +244,6 @@ public class DocumentService {
|
|||
var columnResponses = documentResponseConverter.of(
|
||||
subColumns,
|
||||
table.getName(),
|
||||
discussionCountMapByJoinName,
|
||||
descriptionMapByJoinName);
|
||||
return documentResponseConverter.of(
|
||||
table,
|
||||
|
@ -276,7 +273,7 @@ public class DocumentService {
|
|||
var discussions = documentDiscussionDao.selectAllDiscussionCount(projectId);
|
||||
Map<String, Integer> discussionCountMapByJoinName = discussions.stream()
|
||||
.collect(Collectors.toMap(
|
||||
d -> String.join(".", d.getTableName(), d.getColumnName()),
|
||||
d -> d.getTableName(),
|
||||
DocumentDiscussionCountPojo::getCount,
|
||||
(a, b) -> a));
|
||||
|
||||
|
|
|
@ -32,21 +32,16 @@ public class DocumentDiscussionDao extends BaseDao<DocumentDiscussion> {
|
|||
.fetchOptionalInto(DocumentDiscussion.class);
|
||||
}
|
||||
|
||||
public List<DocumentDiscussionCountPojo> selectTableDiscussionCount(Integer projectId) {
|
||||
return this.selectDiscussionCount(DOCUMENT_DISCUSSION.PROJECT_ID.eq(projectId)
|
||||
.and(DOCUMENT_DISCUSSION.COLUMN_NAME.isNull()));
|
||||
}
|
||||
|
||||
public List<DocumentDiscussionCountPojo> selectAllDiscussionCount(Integer projectId) {
|
||||
return this.selectDiscussionCount(DOCUMENT_DISCUSSION.PROJECT_ID.eq(projectId));
|
||||
}
|
||||
|
||||
public List<DocumentDiscussionCountPojo> selectDiscussionCount(Condition condition) {
|
||||
return this.getDslContext()
|
||||
.select(DSL.count(), DOCUMENT_DISCUSSION.TABLE_NAME, DOCUMENT_DISCUSSION.COLUMN_NAME)
|
||||
.select(DSL.count(), DOCUMENT_DISCUSSION.TABLE_NAME)
|
||||
.from(DOCUMENT_DISCUSSION)
|
||||
.where(condition)
|
||||
.groupBy(DOCUMENT_DISCUSSION.TABLE_NAME, DOCUMENT_DISCUSSION.COLUMN_NAME)
|
||||
.groupBy(DOCUMENT_DISCUSSION.TABLE_NAME)
|
||||
.fetchInto(DocumentDiscussionCountPojo.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,5 @@ public class DocumentDiscussionCountPojo {
|
|||
|
||||
private String tableName;
|
||||
|
||||
private String columnName;
|
||||
|
||||
private Integer count;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue