fix: diff result table show added but overview show none

This commit is contained in:
vran 2022-05-22 14:40:13 +08:00
parent c5af11f68f
commit a00fd2278c
2 changed files with 18 additions and 2 deletions

View File

@ -273,8 +273,16 @@ public class DocumentService {
} }
} }
result.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName)); result.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));
DiffType diffType = result.stream() boolean allAdded = result.stream()
.anyMatch(t -> t.getDiffType() == DiffType.MODIFIED) ? DiffType.MODIFIED : DiffType.NONE; .filter(item -> !item.getDiffType().isNone())
.allMatch(item -> item.getDiffType().isAdded());
DiffType diffType;
if (allAdded) {
diffType = DiffType.ADDED;
} else {
diffType = result.stream()
.anyMatch(t -> t.getDiffType() != DiffType.NONE) ? DiffType.MODIFIED : DiffType.NONE;
}
return documentSimpleResponseConverter.of(document, result, diffType, projectName); return documentSimpleResponseConverter.of(document, result, diffType, projectName);
} else { } else {
tableMetas.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName)); tableMetas.sort(Comparator.comparing(DatabaseDocumentSimpleResponse.TableData::getName));

View File

@ -6,4 +6,12 @@ public enum DiffType {
public static boolean isModified(DiffType type) { public static boolean isModified(DiffType type) {
return type != null && type != NONE; return type != null && type != NONE;
} }
public boolean isAdded() {
return this == ADDED;
}
public boolean isNone() {
return this == NONE;
}
} }