feat: use virtual tree & virtual table (#197)

* feat: add projectName field

* feat: use virtual tree & virtual table
This commit is contained in:
vran
2022-05-21 22:04:29 +08:00
committed by GitHub
parent b7725af8b5
commit c5af11f68f
117 changed files with 272 additions and 249 deletions

View File

@@ -21,7 +21,8 @@ public interface DocumentSimpleResponseConverter {
@Mapping(target = "documentVersion", source = "databaseDocument.version")
DatabaseDocumentSimpleResponse of(DatabaseDocumentPojo databaseDocument,
List<DatabaseDocumentSimpleResponse.TableData> tables,
DiffType diffType);
DiffType diffType,
String projectName);
DatabaseDocumentSimpleResponse.TableData of(TableDocumentPojo tables,
Integer discussionCount,
@@ -31,6 +32,7 @@ public interface DocumentSimpleResponseConverter {
Map<String, Integer> discussionCountMapByTableName,
Map<String, String> descriptionMapByTableName) {
return tables.stream()
.map(table -> {
Integer count = discussionCountMapByTableName.get(table.getName());
String description = descriptionMapByTableName.get(table.getName());

View File

@@ -12,6 +12,8 @@ public class DatabaseDocumentSimpleResponse {
private Integer id;
private String projectName;
private String databaseName;
private String schemaName;

View File

@@ -208,6 +208,10 @@ public class DocumentService {
public Optional<DatabaseDocumentSimpleResponse> getSimpleOneByProjectId(Integer projectId,
Long version,
Long originalVersion) {
String projectName = projectDao.selectOptionalById(projectId)
.map(ProjectPojo::getName)
.orElseThrow(DomainErrors.PROJECT_NOT_FOUND::exception);
Optional<DatabaseDocumentPojo> documentOption;
if (version == null) {
documentOption = databaseDocumentDao.selectNotArchivedByProjectId(projectId);
@@ -271,10 +275,10 @@ public class DocumentService {
result.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));
DiffType diffType = result.stream()
.anyMatch(t -> t.getDiffType() == DiffType.MODIFIED) ? DiffType.MODIFIED : DiffType.NONE;
return documentSimpleResponseConverter.of(document, result, diffType);
return documentSimpleResponseConverter.of(document, result, diffType, projectName);
} else {
tableMetas.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));
return documentSimpleResponseConverter.of(document, tableMetas, DiffType.NONE);
return documentSimpleResponseConverter.of(document, tableMetas, DiffType.NONE, projectName);
}
});
}