feat: add projectName field

This commit is contained in:
vran 2022-05-21 20:00:58 +08:00
parent b7725af8b5
commit b8967a1ec6
3 changed files with 11 additions and 3 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);
}
});
}