feat: add projectName field
This commit is contained in:
parent
b7725af8b5
commit
b8967a1ec6
|
@ -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());
|
||||
|
|
|
@ -12,6 +12,8 @@ public class DatabaseDocumentSimpleResponse {
|
|||
|
||||
private Integer id;
|
||||
|
||||
private String projectName;
|
||||
|
||||
private String databaseName;
|
||||
|
||||
private String schemaName;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue