mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 02:46:56 +00:00
(improvement)(headless)Decrease the number of database queries to the s2_domain table. #1472
This commit is contained in:
@@ -119,23 +119,19 @@ public class DomainServiceImpl implements DomainService {
|
||||
public Set<DomainResp> getDomainAuthSet(User user, AuthType authTypeEnum) {
|
||||
List<DomainResp> domainResps = getDomainList();
|
||||
Set<String> orgIds = userService.getUserAllOrgId(user.getName());
|
||||
List<DomainResp> domainWithAuth = Lists.newArrayList();
|
||||
Set<DomainResp> domainWithAuth = Sets.newHashSet();
|
||||
if (authTypeEnum.equals(AuthType.ADMIN)) {
|
||||
domainWithAuth = domainResps.stream()
|
||||
.filter(domainResp -> checkAdminPermission(orgIds, user, domainResp))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
if (authTypeEnum.equals(AuthType.VISIBLE)) {
|
||||
domainWithAuth = domainResps.stream()
|
||||
.filter(domainResp -> checkViewPermission(orgIds, user, domainResp))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
List<Long> domainIds = domainWithAuth.stream().map(DomainResp::getId)
|
||||
.collect(Collectors.toList());
|
||||
//get all child domain
|
||||
return getDomainChildren(domainIds).stream()
|
||||
.peek(domainResp -> domainResp.setHasEditPermission(true))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return domainWithAuth;
|
||||
}
|
||||
|
||||
private Set<DomainResp> getParentDomain(List<Long> ids) {
|
||||
|
||||
@@ -358,9 +358,9 @@ public class ModelServiceImpl implements ModelService {
|
||||
if (modelDO == null) {
|
||||
return null;
|
||||
}
|
||||
Map<Long, DomainResp> domainRespMap = domainService.getDomainList().stream()
|
||||
.collect(Collectors.toMap(DomainResp::getId, d -> d));
|
||||
return ModelConverter.convert(modelDO, domainRespMap);
|
||||
|
||||
DomainResp domainResp = domainService.getDomain(modelDO.getDomainId());
|
||||
return ModelConverter.convert(modelDO, domainResp);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,9 +70,8 @@ public class ModelConverter {
|
||||
return modelResp;
|
||||
}
|
||||
|
||||
public static ModelResp convert(ModelDO modelDO, Map<Long, DomainResp> domainRespMap) {
|
||||
public static ModelResp convert(ModelDO modelDO, DomainResp domainResp) {
|
||||
ModelResp modelResp = convert(modelDO);
|
||||
DomainResp domainResp = domainRespMap.get(modelResp.getDomainId());
|
||||
if (domainResp != null) {
|
||||
String fullBizNamePath = domainResp.getFullPath() + modelResp.getBizName();
|
||||
modelResp.setFullPath(fullBizNamePath);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
s2:
|
||||
|
||||
schema:
|
||||
cache:
|
||||
enable: true
|
||||
|
||||
parser:
|
||||
strategy: ONE_PASS_SELF_CONSISTENCY
|
||||
exemplar-recall:
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
s2:
|
||||
|
||||
schema:
|
||||
cache:
|
||||
enable: false
|
||||
|
||||
parser:
|
||||
strategy: ONE_PASS_SELF_CONSISTENCY
|
||||
exemplar-recall:
|
||||
@@ -15,16 +20,10 @@ s2:
|
||||
information: true
|
||||
date: true
|
||||
|
||||
|
||||
demo:
|
||||
names: S2VisitsDemo,S2ArtistDemo
|
||||
enableLLM: false
|
||||
|
||||
schema:
|
||||
cache:
|
||||
enable: false
|
||||
|
||||
|
||||
authentication:
|
||||
enable: true
|
||||
exclude:
|
||||
|
||||
Reference in New Issue
Block a user