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")
|
@Mapping(target = "documentVersion", source = "databaseDocument.version")
|
||||||
DatabaseDocumentSimpleResponse of(DatabaseDocumentPojo databaseDocument,
|
DatabaseDocumentSimpleResponse of(DatabaseDocumentPojo databaseDocument,
|
||||||
List<DatabaseDocumentSimpleResponse.TableData> tables,
|
List<DatabaseDocumentSimpleResponse.TableData> tables,
|
||||||
DiffType diffType);
|
DiffType diffType,
|
||||||
|
String projectName);
|
||||||
|
|
||||||
DatabaseDocumentSimpleResponse.TableData of(TableDocumentPojo tables,
|
DatabaseDocumentSimpleResponse.TableData of(TableDocumentPojo tables,
|
||||||
Integer discussionCount,
|
Integer discussionCount,
|
||||||
|
@ -31,6 +32,7 @@ public interface DocumentSimpleResponseConverter {
|
||||||
Map<String, Integer> discussionCountMapByTableName,
|
Map<String, Integer> discussionCountMapByTableName,
|
||||||
Map<String, String> descriptionMapByTableName) {
|
Map<String, String> descriptionMapByTableName) {
|
||||||
return tables.stream()
|
return tables.stream()
|
||||||
|
|
||||||
.map(table -> {
|
.map(table -> {
|
||||||
Integer count = discussionCountMapByTableName.get(table.getName());
|
Integer count = discussionCountMapByTableName.get(table.getName());
|
||||||
String description = descriptionMapByTableName.get(table.getName());
|
String description = descriptionMapByTableName.get(table.getName());
|
||||||
|
|
|
@ -12,6 +12,8 @@ public class DatabaseDocumentSimpleResponse {
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
|
|
||||||
private String schemaName;
|
private String schemaName;
|
||||||
|
|
|
@ -208,6 +208,10 @@ public class DocumentService {
|
||||||
public Optional<DatabaseDocumentSimpleResponse> getSimpleOneByProjectId(Integer projectId,
|
public Optional<DatabaseDocumentSimpleResponse> getSimpleOneByProjectId(Integer projectId,
|
||||||
Long version,
|
Long version,
|
||||||
Long originalVersion) {
|
Long originalVersion) {
|
||||||
|
String projectName = projectDao.selectOptionalById(projectId)
|
||||||
|
.map(ProjectPojo::getName)
|
||||||
|
.orElseThrow(DomainErrors.PROJECT_NOT_FOUND::exception);
|
||||||
|
|
||||||
Optional<DatabaseDocumentPojo> documentOption;
|
Optional<DatabaseDocumentPojo> documentOption;
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
documentOption = databaseDocumentDao.selectNotArchivedByProjectId(projectId);
|
documentOption = databaseDocumentDao.selectNotArchivedByProjectId(projectId);
|
||||||
|
@ -271,10 +275,10 @@ public class DocumentService {
|
||||||
result.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));
|
result.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));
|
||||||
DiffType diffType = result.stream()
|
DiffType diffType = result.stream()
|
||||||
.anyMatch(t -> t.getDiffType() == DiffType.MODIFIED) ? DiffType.MODIFIED : DiffType.NONE;
|
.anyMatch(t -> t.getDiffType() == DiffType.MODIFIED) ? DiffType.MODIFIED : DiffType.NONE;
|
||||||
return documentSimpleResponseConverter.of(document, result, diffType);
|
return documentSimpleResponseConverter.of(document, result, diffType, projectName);
|
||||||
} else {
|
} else {
|
||||||
tableMetas.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));
|
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