mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
(improvement)(chat) Add domain tree for agent and plugin setting (#718)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -14,6 +14,7 @@ import com.tencent.supersonic.headless.api.pojo.request.ViewFilterReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ExplainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
|
||||
@@ -104,4 +105,9 @@ public class LocalSemanticInterpreter extends BaseSemanticInterpreter {
|
||||
return metricService.queryMetric(pageMetricReq, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemResp> getDomainViewTree() {
|
||||
return schemaService.getDomainViewTree();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.tencent.supersonic.headless.api.pojo.request.QueryStructReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ExplainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
|
||||
@@ -253,8 +254,14 @@ public class RemoteSemanticInterpreter extends BaseSemanticInterpreter {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemResp> getDomainViewTree() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewResp> getViewList(Long domainId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.tencent.supersonic.headless.api.pojo.request.QueryStructReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ExplainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
|
||||
@@ -56,4 +57,6 @@ public interface SemanticInterpreter {
|
||||
|
||||
List<ViewResp> getViewList(Long domainId);
|
||||
|
||||
List<ItemResp> getDomainViewTree();
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.tencent.supersonic.headless.api.pojo.request.PageDimensionReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.PageMetricReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -106,4 +107,9 @@ public class ChatConfigController {
|
||||
return semanticInterpreter.getMetricPage(pageMetricReq, user);
|
||||
}
|
||||
|
||||
@GetMapping("/getDomainViewTree")
|
||||
public List<ItemResp> getDomainViewTree() {
|
||||
return semanticInterpreter.getDomainViewTree();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ItemResp {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String name;
|
||||
|
||||
private TypeEnums type;
|
||||
|
||||
private List<ItemResp> children = Lists.newArrayList();
|
||||
|
||||
public ItemResp(Long id, Long parentId, String name, TypeEnums type) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.tencent.supersonic.headless.api.pojo.request.SchemaItemQueryReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.ViewFilterReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemUseResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
|
||||
@@ -40,4 +41,6 @@ public interface SchemaService {
|
||||
SemanticSchemaResp fetchSemanticSchema(SchemaFilterReq schemaFilterReq);
|
||||
|
||||
List<ItemUseResp> getStatInfo(ItemUseReq itemUseReq) throws ExecutionException;
|
||||
|
||||
List<ItemResp> getDomainViewTree();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ItemUseResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricSchemaResp;
|
||||
@@ -307,6 +308,34 @@ public class SchemaServiceImpl implements SchemaService {
|
||||
return statUtils.getStatInfo(itemUseReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemResp> getDomainViewTree() {
|
||||
List<DomainResp> domainResps = domainService.getDomainList();
|
||||
List<ItemResp> itemResps = domainResps.stream().map(domain ->
|
||||
new ItemResp(domain.getId(), domain.getParentId(), domain.getName(), TypeEnums.DOMAIN))
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, ItemResp> itemRespMap = itemResps.stream()
|
||||
.collect(Collectors.toMap(ItemResp::getId, item -> item));
|
||||
for (ItemResp itemResp : itemResps) {
|
||||
ItemResp parentItem = itemRespMap.get(itemResp.getParentId());
|
||||
if (parentItem == null) {
|
||||
continue;
|
||||
}
|
||||
parentItem.getChildren().add(itemResp);
|
||||
}
|
||||
List<ViewResp> viewResps = viewService.getViewList(new MetaFilter());
|
||||
for (ViewResp viewResp : viewResps) {
|
||||
ItemResp itemResp = itemRespMap.get(viewResp.getDomainId());
|
||||
if (itemResp != null) {
|
||||
ItemResp view = new ItemResp(viewResp.getId(), viewResp.getDomainId(),
|
||||
viewResp.getName(), TypeEnums.VIEW);
|
||||
itemResp.getChildren().add(view);
|
||||
}
|
||||
}
|
||||
return itemResps.stream().filter(itemResp -> itemResp.getParentId() == 0)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void fillStaticInfo(List<ViewSchemaResp> viewSchemaResps) throws ExecutionException {
|
||||
List<Long> viewIds = viewSchemaResps.stream()
|
||||
.map(ViewSchemaResp::getId).collect(Collectors.toList());
|
||||
|
||||
@@ -15,8 +15,10 @@ import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.ViewDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.mapper.ViewDOMapper;
|
||||
import com.tencent.supersonic.headless.server.pojo.MetaFilter;
|
||||
import com.tencent.supersonic.headless.server.service.DomainService;
|
||||
import com.tencent.supersonic.headless.server.service.ViewService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -29,6 +31,9 @@ import java.util.stream.Collectors;
|
||||
public class ViewServiceImpl
|
||||
extends ServiceImpl<ViewDOMapper, ViewDO> implements ViewService {
|
||||
|
||||
@Autowired
|
||||
private DomainService domainService;
|
||||
|
||||
@Override
|
||||
public ViewResp save(ViewReq viewReq, User user) {
|
||||
viewReq.createdBy(user.getName());
|
||||
|
||||
Reference in New Issue
Block a user