mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 13:47:09 +00:00
(improvement)(launcher) Optimize Demo to distinguish domain and model sets (#1056)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package com.tencent.supersonic.headless.server.persistence.repository;
|
||||
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.CanvasDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CanvasRepository {
|
||||
|
||||
List<CanvasDO> getCanvasList(Long domainId);
|
||||
|
||||
CanvasDO getCanvasById(Long id);
|
||||
|
||||
void deleteCanvas(Long id);
|
||||
|
||||
void createCanvas(CanvasDO canvasDO);
|
||||
|
||||
void updateCanvas(CanvasDO canvasDO);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.tencent.supersonic.headless.server.persistence.repository.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.CanvasDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.mapper.CanvasDOMapper;
|
||||
import com.tencent.supersonic.headless.server.persistence.repository.CanvasRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CanvasRepositoryImpl implements CanvasRepository {
|
||||
|
||||
|
||||
private CanvasDOMapper canvasDOMapper;
|
||||
|
||||
public CanvasRepositoryImpl(CanvasDOMapper canvasDOMapper) {
|
||||
this.canvasDOMapper = canvasDOMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CanvasDO> getCanvasList(Long domainId) {
|
||||
QueryWrapper<CanvasDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(CanvasDO::getDomainId, domainId);
|
||||
return canvasDOMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanvasDO getCanvasById(Long id) {
|
||||
return canvasDOMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCanvas(Long id) {
|
||||
canvasDOMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCanvas(CanvasDO canvasDO) {
|
||||
canvasDOMapper.insert(canvasDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCanvas(CanvasDO canvasDO) {
|
||||
canvasDOMapper.updateById(canvasDO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,8 +75,8 @@ public class SqlInfoProcessor implements ResultProcessor {
|
||||
}
|
||||
SqlInfo sqlInfo = parseInfo.getSqlInfo();
|
||||
if (semanticQuery instanceof LLMSqlQuery) {
|
||||
keyPipelineLog.info("SqlInfoProcessor results:\nParsed S2SQL:{}\nCorrected S2SQL:{}\nFinal SQL:{}", sqlInfo.getS2SQL(),
|
||||
sqlInfo.getCorrectS2SQL(), explainSql);
|
||||
keyPipelineLog.info("SqlInfoProcessor results:\nParsed S2SQL:{}\nCorrected S2SQL:{}\nFinal SQL:{}",
|
||||
sqlInfo.getS2SQL(), sqlInfo.getCorrectS2SQL(), explainSql);
|
||||
}
|
||||
sqlInfo.setQuerySQL(explainSql);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.CanvasReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.CanvasSchemaResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.CanvasDO;
|
||||
import com.tencent.supersonic.headless.server.service.impl.CanvasServiceImpl;
|
||||
import com.tencent.supersonic.headless.server.service.CanvasService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -23,11 +24,8 @@ import java.util.List;
|
||||
@RequestMapping("/api/semantic/viewInfo")
|
||||
public class CanvasController {
|
||||
|
||||
private CanvasServiceImpl canvasService;
|
||||
|
||||
public CanvasController(CanvasServiceImpl canvasService) {
|
||||
this.canvasService = canvasService;
|
||||
}
|
||||
@Autowired
|
||||
private CanvasService canvasService;
|
||||
|
||||
@PostMapping("/createOrUpdateViewInfo")
|
||||
public CanvasDO createOrUpdateCanvas(@RequestBody CanvasReq canvasReq, HttpServletRequest request,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.server.service;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.CanvasReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.CanvasSchemaResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.CanvasDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CanvasService {
|
||||
|
||||
List<CanvasDO> getCanvasList(Long domainId);
|
||||
|
||||
List<CanvasSchemaResp> getCanvasSchema(Long domainId, User user);
|
||||
|
||||
CanvasDO createOrUpdateCanvas(CanvasReq canvasReq, User user);
|
||||
|
||||
void deleteCanvas(Long id);
|
||||
}
|
||||
@@ -1,49 +1,49 @@
|
||||
package com.tencent.supersonic.headless.server.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.CanvasReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.CanvasSchemaResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.CanvasSchemaResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.CanvasDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.repository.CanvasRepository;
|
||||
import com.tencent.supersonic.headless.server.persistence.mapper.CanvasDOMapper;
|
||||
import com.tencent.supersonic.headless.server.pojo.MetaFilter;
|
||||
import com.tencent.supersonic.headless.server.service.CanvasService;
|
||||
import com.tencent.supersonic.headless.server.service.DimensionService;
|
||||
import com.tencent.supersonic.headless.server.service.MetricService;
|
||||
import com.tencent.supersonic.headless.server.service.ModelService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CanvasServiceImpl {
|
||||
|
||||
private CanvasRepository canvasRepository;
|
||||
public class CanvasServiceImpl extends ServiceImpl<CanvasDOMapper, CanvasDO> implements CanvasService {
|
||||
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
|
||||
@Autowired
|
||||
private DimensionService dimensionService;
|
||||
|
||||
@Autowired
|
||||
private MetricService metricService;
|
||||
|
||||
public CanvasServiceImpl(CanvasRepository canvasRepository, ModelService modelService,
|
||||
MetricService metricService, DimensionService dimensionService) {
|
||||
this.canvasRepository = canvasRepository;
|
||||
this.dimensionService = dimensionService;
|
||||
this.metricService = metricService;
|
||||
this.modelService = modelService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CanvasDO> getCanvasList(Long domainId) {
|
||||
return canvasRepository.getCanvasList(domainId);
|
||||
QueryWrapper<CanvasDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CanvasDO::getDomainId, domainId);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CanvasSchemaResp> getCanvasSchema(Long domainId, User user) {
|
||||
List<CanvasSchemaResp> canvasSchemaResps = Lists.newArrayList();
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, domainId, AuthType.ADMIN);
|
||||
@@ -62,28 +62,26 @@ public class CanvasServiceImpl {
|
||||
return canvasSchemaResps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanvasDO createOrUpdateCanvas(CanvasReq canvasReq, User user) {
|
||||
if (canvasReq.getId() == null) {
|
||||
canvasReq.createdBy(user.getName());
|
||||
CanvasDO viewInfoDO = new CanvasDO();
|
||||
BeanUtils.copyProperties(canvasReq, viewInfoDO);
|
||||
viewInfoDO.setCreatedAt(new Date());
|
||||
viewInfoDO.setCreatedBy(user.getName());
|
||||
viewInfoDO.setUpdatedAt(new Date());
|
||||
viewInfoDO.setUpdatedBy(user.getName());
|
||||
canvasRepository.createCanvas(viewInfoDO);
|
||||
save(viewInfoDO);
|
||||
return viewInfoDO;
|
||||
}
|
||||
Long id = canvasReq.getId();
|
||||
CanvasDO viewInfoDO = canvasRepository.getCanvasById(id);
|
||||
CanvasDO viewInfoDO = getById(id);
|
||||
canvasReq.updatedBy(user.getName());
|
||||
BeanUtils.copyProperties(canvasReq, viewInfoDO);
|
||||
viewInfoDO.setUpdatedAt(new Date());
|
||||
viewInfoDO.setUpdatedBy(user.getName());
|
||||
canvasRepository.updateCanvas(viewInfoDO);
|
||||
updateById(viewInfoDO);
|
||||
return viewInfoDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCanvas(Long id) {
|
||||
canvasRepository.deleteCanvas(id);
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,12 +10,10 @@ import com.tencent.supersonic.headless.api.pojo.request.DomainReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.DomainUpdateReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.DataSetResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.DomainDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.repository.DomainRepository;
|
||||
import com.tencent.supersonic.headless.server.service.DomainService;
|
||||
import com.tencent.supersonic.headless.server.service.ModelService;
|
||||
import com.tencent.supersonic.headless.server.service.DataSetService;
|
||||
import com.tencent.supersonic.headless.server.utils.DomainConvert;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.util.Sets;
|
||||
@@ -43,17 +41,13 @@ public class DomainServiceImpl implements DomainService {
|
||||
private final DomainRepository domainRepository;
|
||||
private final ModelService modelService;
|
||||
private final UserService userService;
|
||||
private final DataSetService dataSetService;
|
||||
|
||||
|
||||
public DomainServiceImpl(DomainRepository domainRepository,
|
||||
@Lazy ModelService modelService,
|
||||
UserService userService,
|
||||
@Lazy DataSetService dataSetService) {
|
||||
UserService userService) {
|
||||
this.domainRepository = domainRepository;
|
||||
this.modelService = modelService;
|
||||
this.userService = userService;
|
||||
this.dataSetService = dataSetService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,11 +106,6 @@ public class DomainServiceImpl implements DomainService {
|
||||
if (!CollectionUtils.isEmpty(modelResps)) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user