(improvement)(Headless) When obtaining the domain list, information about whether there is a model under the domain is returned incidentally. (#970)

This commit is contained in:
LXW
2024-05-10 16:15:53 +08:00
committed by GitHub
parent 9de188ae7e
commit b194da05c2
2 changed files with 9 additions and 2 deletions

View File

@@ -27,6 +27,8 @@ public class DomainResp extends SchemaItem {
private boolean hasEditPermission = false;
private boolean hasModel;
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {

View File

@@ -106,15 +106,20 @@ public class DomainServiceImpl implements DomainService {
domainWithAuthAll.addAll(getParentDomain(domainIds));
}
List<ModelResp> modelResps = modelService.getModelAuthList(user, null, AuthType.ADMIN);
List<Long> domainIdsFromModel = modelResps.stream().map(ModelResp::getDomainId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(modelResps)) {
List<Long> domainIds = modelResps.stream().map(ModelResp::getDomainId).collect(Collectors.toList());
domainWithAuthAll.addAll(getParentDomain(domainIds));
domainWithAuthAll.addAll(getParentDomain(domainIdsFromModel));
}
List<DataSetResp> dataSetResps = dataSetService.getDataSets(user);
if (!CollectionUtils.isEmpty(dataSetResps)) {
List<Long> domainIds = dataSetResps.stream().map(DataSetResp::getDomainId).collect(Collectors.toList());
domainWithAuthAll.addAll(getParentDomain(domainIds));
}
for (DomainResp domainResp : domainWithAuthAll) {
if (domainIdsFromModel.contains(domainResp.getId())) {
domainResp.setHasModel(true);
}
}
return new ArrayList<>(domainWithAuthAll).stream()
.sorted(Comparator.comparingLong(DomainResp::getId)).collect(Collectors.toList());
}