[improvement][project] global refactor , code format , support llm , support fuzzy detect ,support query filter and so on.

This commit is contained in:
lexluo
2023-07-08 15:00:03 +08:00
parent 5ffd617431
commit 404163f391
329 changed files with 21050 additions and 5036 deletions

View File

@@ -5,6 +5,8 @@ import com.tencent.supersonic.semantic.api.core.request.DatabaseReq;
import com.tencent.supersonic.semantic.api.core.response.DatabaseResp;
import com.tencent.supersonic.semantic.api.core.response.QueryResultWithSchemaResp;
import com.tencent.supersonic.semantic.api.core.response.SqlParserResp;
import com.tencent.supersonic.semantic.core.domain.adaptor.engineadapter.EngineAdaptor;
import com.tencent.supersonic.semantic.core.domain.adaptor.engineadapter.EngineAdaptorFactory;
import com.tencent.supersonic.semantic.core.domain.dataobject.DatabaseDO;
import com.tencent.supersonic.semantic.core.domain.repository.DatabaseRepository;
import com.tencent.supersonic.semantic.core.domain.utils.DatabaseConverter;
@@ -24,9 +26,8 @@ import org.springframework.stereotype.Service;
@Service
public class DatabaseServiceImpl implements DatabaseService {
private DatabaseRepository databaseRepository;
private final SqlUtils sqlUtils;
private DatabaseRepository databaseRepository;
public DatabaseServiceImpl(DatabaseRepository databaseRepository, SqlUtils sqlUtils) {
this.databaseRepository = databaseRepository;
@@ -53,6 +54,7 @@ public class DatabaseServiceImpl implements DatabaseService {
return DatabaseConverter.convert(databaseDO);
}
@Override
public DatabaseResp getDatabase(Long id) {
DatabaseDO databaseDO = databaseRepository.getDatabase(id);
@@ -74,8 +76,6 @@ public class DatabaseServiceImpl implements DatabaseService {
@Override
public QueryResultWithSchemaResp executeSql(String sql, DatabaseResp databaseResp) {
SqlUtils sqlUtils = this.sqlUtils.init(databaseResp);
return queryWithColumns(sql, databaseResp);
}
@@ -93,7 +93,7 @@ public class DatabaseServiceImpl implements DatabaseService {
private QueryResultWithSchemaResp queryWithColumns(String sql, DatabaseResp databaseResp) {
QueryResultWithSchemaResp queryResultWithColumns = new QueryResultWithSchemaResp();
SqlUtils sqlUtils = this.sqlUtils.init(databaseResp);
log.info("query SQL: {}" , sql);
log.info("query SQL: {}", sql);
sqlUtils.queryInternal(sql, queryResultWithColumns);
return queryResultWithColumns;
}
@@ -103,4 +103,31 @@ public class DatabaseServiceImpl implements DatabaseService {
return databaseDOS.stream().findFirst();
}
@Override
public QueryResultWithSchemaResp getDbNames(Long id) {
DatabaseResp databaseResp = getDatabase(id);
EngineAdaptor engineAdaptor = EngineAdaptorFactory.getEngineAdaptor(databaseResp.getType());
String metaQueryTpl = engineAdaptor.getDbMetaQueryTpl();
return queryWithColumns(metaQueryTpl, databaseResp);
}
@Override
public QueryResultWithSchemaResp getTables(Long id, String db) {
DatabaseResp databaseResp = getDatabase(id);
EngineAdaptor engineAdaptor = EngineAdaptorFactory.getEngineAdaptor(databaseResp.getType());
String metaQueryTpl = engineAdaptor.getTableMetaQueryTpl();
String metaQuerySql = String.format(metaQueryTpl, db);
return queryWithColumns(metaQuerySql, databaseResp);
}
@Override
public QueryResultWithSchemaResp getColumns(Long id, String db, String table) {
DatabaseResp databaseResp = getDatabase(id);
EngineAdaptor engineAdaptor = EngineAdaptorFactory.getEngineAdaptor(databaseResp.getType());
String metaQueryTpl = engineAdaptor.getColumnMetaQueryTpl();
String metaQuerySql = String.format(metaQueryTpl, db, table);
return queryWithColumns(metaQuerySql, databaseResp);
}
}

View File

@@ -63,8 +63,6 @@ public class DatasourceServiceImpl implements DatasourceService {
private DatasourceRepository datasourceRepository;
private DatasourceYamlManager datasourceYamlManager;
private DatabaseService databaseService;
private DimensionService dimensionService;
@@ -73,19 +71,13 @@ public class DatasourceServiceImpl implements DatasourceService {
private DateInfoRepository dateInfoRepository;
private DomainService domainService;
public DatasourceServiceImpl(DatasourceRepository datasourceRepository,
DatasourceYamlManager datasourceYamlManager,
DomainService domainService,
DatabaseService databaseService,
@Lazy DimensionService dimensionService,
@Lazy MetricService metricService,
DateInfoRepository dateInfoRepository) {
this.domainService = domainService;
this.datasourceRepository = datasourceRepository;
this.datasourceYamlManager = datasourceYamlManager;
this.databaseService = databaseService;
this.dimensionService = dimensionService;
this.metricService = metricService;
@@ -107,10 +99,6 @@ public class DatasourceServiceImpl implements DatasourceService {
datasource.setId(datasourceDesc.getId());
batchCreateDimension(datasource, user);
batchCreateMetric(datasource, user);
List<DimensionResp> dimensionDescsExist = dimensionService.getDimensionsByDatasource(datasource.getId());
DatabaseResp databaseResp = databaseService.getDatabase(datasource.getDatabaseId());
datasourceYamlManager.generateYamlFile(datasource, databaseResp,
domainService.getDomainFullPath(datasource.getDomainId()), dimensionDescsExist);
return datasourceDesc;
}
@@ -124,10 +112,6 @@ public class DatasourceServiceImpl implements DatasourceService {
batchCreateDimension(datasource, user);
batchCreateMetric(datasource, user);
List<DimensionResp> dimensionDescsExist = dimensionService.getDimensionsByDatasource(datasource.getId());
DatabaseResp databaseResp = databaseService.getDatabase(datasource.getDatabaseId());
datasourceYamlManager.generateYamlFile(datasource, databaseResp,
domainService.getDomainFullPath(datasource.getDomainId()), dimensionDescsExist);
DatasourceDO datasourceDO = updateDatasource(datasource, user);
return DatasourceConverter.convert(datasourceDO);
}
@@ -207,8 +191,6 @@ public class DatasourceServiceImpl implements DatasourceService {
}
private void preCheck(DatasourceReq datasourceReq) {
List<Dim> dims = datasourceReq.getDimensions();
if (CollectionUtils.isEmpty(dims)) {
@@ -245,8 +227,6 @@ public class DatasourceServiceImpl implements DatasourceService {
}
@Override
public Map<Long, DatasourceResp> getDatasourceMap() {
Map<Long, DatasourceResp> map = new HashMap<>();
@@ -264,9 +244,16 @@ public class DatasourceServiceImpl implements DatasourceService {
if (datasourceDO == null) {
return;
}
checkDelete(datasourceDO.getDomainId(), id);
datasourceRepository.deleteDatasource(id);
datasourceYamlManager.deleteYamlFile(datasourceDO.getBizName(),
domainService.getDomainFullPath(datasourceDO.getDomainId()));
}
private void checkDelete(Long domainId, Long datasourceId) {
List<MetricResp> metricResps = metricService.getMetrics(domainId, datasourceId);
List<DimensionResp> dimensionResps = dimensionService.getDimensionsByDatasource(datasourceId);
if (!CollectionUtils.isEmpty(metricResps) || !CollectionUtils.isEmpty(dimensionResps)) {
throw new RuntimeException("exist dimension or metric on this datasource, please check");
}
}
@@ -315,6 +302,7 @@ public class DatasourceServiceImpl implements DatasourceService {
}
@Override
public ItemDateResp getDateDate(ItemDateFilter dimension, ItemDateFilter metric) {
List<DateInfoReq> itemDates = new ArrayList<>();
List<DateInfoDO> dimensions = dateInfoRepository.getDateInfos(dimension);
@@ -355,10 +343,10 @@ public class DatasourceServiceImpl implements DatasourceService {
String startDate1 = item.getStartDate();
String endDate1 = item.getEndDate();
List<String> unavailableDateList1 = item.getUnavailableDateList();
if (Strings.isNotEmpty(startDate1) && startDate1.compareTo(startDate) < 0) {
if (Strings.isNotEmpty(startDate1) && startDate1.compareTo(startDate) > 0) {
startDate = startDate1;
}
if (Strings.isNotEmpty(endDate1) && startDate1.compareTo(endDate1) > 0) {
if (Strings.isNotEmpty(endDate1) && endDate1.compareTo(endDate) < 0) {
endDate = endDate1;
}
if (!CollectionUtils.isEmpty(unavailableDateList1)) {

View File

@@ -11,7 +11,6 @@ import com.tencent.supersonic.semantic.api.core.response.DatasourceResp;
import com.tencent.supersonic.semantic.api.core.response.DimensionResp;
import com.tencent.supersonic.common.enums.SensitiveLevelEnum;
import com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO;
import com.tencent.supersonic.semantic.core.domain.manager.DimensionYamlManager;
import com.tencent.supersonic.semantic.core.domain.repository.DimensionRepository;
import com.tencent.supersonic.semantic.core.domain.utils.DimensionConverter;
import com.tencent.supersonic.semantic.core.domain.DatasourceService;
@@ -19,7 +18,6 @@ import com.tencent.supersonic.semantic.core.domain.DimensionService;
import com.tencent.supersonic.semantic.core.domain.DomainService;
import com.tencent.supersonic.semantic.core.domain.pojo.Dimension;
import com.tencent.supersonic.semantic.core.domain.pojo.DimensionFilter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,59 +35,54 @@ public class DimensionServiceImpl implements DimensionService {
private DimensionRepository dimensionRepository;
private DimensionYamlManager dimensionYamlManager;
private DatasourceService datasourceService;
private DomainService domainService;
public DimensionServiceImpl(DimensionRepository dimensionRepository,
DimensionYamlManager dimensionYamlManager,
DomainService domainService,
DatasourceService datasourceService) {
this.domainService = domainService;
this.dimensionRepository = dimensionRepository;
this.dimensionYamlManager = dimensionYamlManager;
this.datasourceService = datasourceService;
}
@Override
public void createDimension(DimensionReq dimensionReq, User user) throws Exception {
public void createDimension(DimensionReq dimensionReq, User user) {
checkExist(Lists.newArrayList(dimensionReq));
Dimension dimension = DimensionConverter.convert(dimensionReq);
log.info("[create dimension] object:{}", JSONObject.toJSONString(dimension));
saveDimensionAndGenerateYaml(dimension, user);
dimension.createdBy(user.getName());
saveDimension(dimension);
}
@Override
public void createDimensionBatch(List<DimensionReq> dimensionReqs, User user) throws Exception {
public void createDimensionBatch(List<DimensionReq> dimensionReqs, User user) {
if (CollectionUtils.isEmpty(dimensionReqs)) {
return;
}
Long domainId = dimensionReqs.get(0).getDomainId();
List<DimensionResp> dimensionDescs = getDimensions(domainId);
Map<String, DimensionResp> dimensionDescMap = dimensionDescs.stream()
List<DimensionResp> dimensionResps = getDimensions(domainId);
Map<String, DimensionResp> dimensionRespMap = dimensionResps.stream()
.collect(Collectors.toMap(DimensionResp::getBizName, a -> a, (k1, k2) -> k1));
List<Dimension> dimensions = dimensionReqs.stream().map(DimensionConverter::convert)
.collect(Collectors.toList());
List<Dimension> dimensionToInsert = dimensions.stream()
.filter(dimension -> !dimensionDescMap.containsKey(dimension.getBizName()))
.filter(dimension -> !dimensionRespMap.containsKey(dimension.getBizName()))
.collect(Collectors.toList());
log.info("[create dimension] object:{}", JSONObject.toJSONString(dimensions));
saveDimensionBatch(dimensionToInsert, user);
generateYamlFile(dimensions.get(0).getDatasourceId(), dimensions.get(0).getDomainId());
}
@Override
public void updateDimension(DimensionReq dimensionReq, User user) throws Exception {
public void updateDimension(DimensionReq dimensionReq, User user) {
Dimension dimension = DimensionConverter.convert(dimensionReq);
dimension.updatedBy(user.getName());
log.info("[update dimension] object:{}", JSONObject.toJSONString(dimension));
updateDimension(dimension);
generateYamlFile(dimension.getDatasourceId(), dimension.getDomainId());
}
protected void updateDimension(Dimension dimension) {
@@ -100,13 +93,13 @@ public class DimensionServiceImpl implements DimensionService {
@Override
public DimensionResp getDimension(String bizName, Long domainId) {
List<DimensionResp> dimensionDescs = getDimensions(domainId);
if (CollectionUtils.isEmpty(dimensionDescs)) {
List<DimensionResp> dimensionResps = getDimensions(domainId);
if (CollectionUtils.isEmpty(dimensionResps)) {
return null;
}
for (DimensionResp dimensionDesc : dimensionDescs) {
if (dimensionDesc.getBizName().equalsIgnoreCase(bizName)) {
return dimensionDesc;
for (DimensionResp dimensionResp : dimensionResps) {
if (dimensionResp.getBizName().equalsIgnoreCase(bizName)) {
return dimensionResp;
}
}
return null;
@@ -132,16 +125,16 @@ public class DimensionServiceImpl implements DimensionService {
@Override
public List<DimensionResp> getDimensions(List<Long> ids) {
List<DimensionResp> dimensionDescs = Lists.newArrayList();
List<DimensionResp> dimensionResps = Lists.newArrayList();
List<DimensionDO> dimensionDOS = dimensionRepository.getDimensionListByIds(ids);
Map<Long, String> fullDomainPathMap = domainService.getDomainFullPath();
if (!CollectionUtils.isEmpty(dimensionDOS)) {
dimensionDescs = dimensionDOS.stream()
.map(dimensionDO -> DimensionConverter.convert2DimensionDesc(dimensionDO, fullDomainPathMap,
dimensionResps = dimensionDOS.stream()
.map(dimensionDO -> DimensionConverter.convert2DimensionResp(dimensionDO, fullDomainPathMap,
new HashMap<>()))
.collect(Collectors.toList());
}
return dimensionDescs;
return dimensionResps;
}
@Override
@@ -149,52 +142,46 @@ public class DimensionServiceImpl implements DimensionService {
return convertList(getDimensionDOS(domainId), datasourceService.getDatasourceMap());
}
public List<Dimension> getDimensionList(Long datasourceId) {
List<Dimension> dimensions = Lists.newArrayList();
List<DimensionDO> dimensionDOS = dimensionRepository.getDimensionListOfDatasource(datasourceId);
if (!CollectionUtils.isEmpty(dimensionDOS)) {
dimensions = dimensionDOS.stream().map(DimensionConverter::convert2Dimension).collect(Collectors.toList());
}
return dimensions;
@Override
public List<DimensionResp> getDimensions() {
return convertList(getDimensionDOS(), datasourceService.getDatasourceMap());
}
@Override
public List<DimensionResp> getDimensionsByDatasource(Long datasourceId) {
List<DimensionResp> dimensionDescs = Lists.newArrayList();
List<DimensionResp> dimensionResps = Lists.newArrayList();
List<DimensionDO> dimensionDOS = dimensionRepository.getDimensionListOfDatasource(datasourceId);
if (!CollectionUtils.isEmpty(dimensionDOS)) {
dimensionDescs = dimensionDOS.stream()
.map(dimensionDO -> DimensionConverter.convert2DimensionDesc(dimensionDO, new HashMap<>(),
dimensionResps = dimensionDOS.stream()
.map(dimensionDO -> DimensionConverter.convert2DimensionResp(dimensionDO, new HashMap<>(),
new HashMap<>()))
.collect(Collectors.toList());
}
return dimensionDescs;
return dimensionResps;
}
private List<DimensionResp> convertList(List<DimensionDO> dimensionDOS,
Map<Long, DatasourceResp> datasourceDescMap) {
List<DimensionResp> dimensionDescs = Lists.newArrayList();
Map<Long, DatasourceResp> datasourceRespMap) {
List<DimensionResp> dimensionResps = Lists.newArrayList();
Map<Long, String> fullDomainPathMap = domainService.getDomainFullPath();
if (!CollectionUtils.isEmpty(dimensionDOS)) {
dimensionDescs = dimensionDOS.stream()
.map(dimensionDO -> DimensionConverter.convert2DimensionDesc(dimensionDO, fullDomainPathMap,
datasourceDescMap))
dimensionResps = dimensionDOS.stream()
.map(dimensionDO -> DimensionConverter.convert2DimensionResp(dimensionDO, fullDomainPathMap,
datasourceRespMap))
.collect(Collectors.toList());
}
return dimensionDescs;
return dimensionResps;
}
@Override
public List<DimensionResp> getHighSensitiveDimension(Long domainId) {
List<DimensionResp> dimensionDescs = getDimensions(domainId);
if (CollectionUtils.isEmpty(dimensionDescs)) {
return dimensionDescs;
List<DimensionResp> dimensionResps = getDimensions(domainId);
if (CollectionUtils.isEmpty(dimensionResps)) {
return dimensionResps;
}
return dimensionDescs.stream()
.filter(dimensionDesc -> SensitiveLevelEnum.HIGH.getCode().equals(dimensionDesc.getSensitiveLevel()))
return dimensionResps.stream()
.filter(dimensionResp -> SensitiveLevelEnum.HIGH.getCode().equals(dimensionResp.getSensitiveLevel()))
.collect(Collectors.toList());
}
@@ -203,13 +190,17 @@ public class DimensionServiceImpl implements DimensionService {
return dimensionRepository.getDimensionListOfDomain(domainId);
}
protected List<DimensionDO> getDimensionDOS() {
return dimensionRepository.getDimensionList();
}
@Override
public List<DimensionResp> getAllHighSensitiveDimension() {
List<DimensionResp> dimensionDescs = Lists.newArrayList();
List<DimensionResp> dimensionResps = Lists.newArrayList();
List<DimensionDO> dimensionDOS = dimensionRepository.getAllDimensionList();
if (CollectionUtils.isEmpty(dimensionDOS)) {
return dimensionDescs;
return dimensionResps;
}
return convertList(dimensionDOS.stream()
.filter(dimensionDO -> SensitiveLevelEnum.HIGH.getCode().equals(dimensionDO.getSensitiveLevel()))
@@ -217,8 +208,7 @@ public class DimensionServiceImpl implements DimensionService {
}
//保存并获取自增ID
private void saveDimension(Dimension dimension) {
public void saveDimension(Dimension dimension) {
DimensionDO dimensionDO = DimensionConverter.convert2DimensionDO(dimension);
log.info("[save dimension] dimensionDO:{}", JSONObject.toJSONString(dimensionDO));
dimensionRepository.createDimension(dimensionDO);
@@ -238,52 +228,30 @@ public class DimensionServiceImpl implements DimensionService {
}
@Override
public void deleteDimension(Long id) throws Exception {
public void deleteDimension(Long id) {
DimensionDO dimensionDO = dimensionRepository.getDimensionById(id);
if (dimensionDO == null) {
throw new RuntimeException(String.format("the dimension %s not exist", id));
}
dimensionRepository.deleteDimension(id);
generateYamlFile(dimensionDO.getDatasourceId(), dimensionDO.getDomainId());
}
protected void generateYamlFile(Long datasourceId, Long domainId) throws Exception {
String datasourceBizName = datasourceService.getSourceBizNameById(datasourceId);
List<Dimension> dimensionList = getDimensionList(datasourceId);
String fullPath = domainService.getDomainFullPath(domainId);
dimensionYamlManager.generateYamlFile(dimensionList, fullPath, datasourceBizName);
}
private void checkExist(List<DimensionReq> dimensionReqs) {
Long domainId = dimensionReqs.get(0).getDomainId();
List<DimensionResp> dimensionDescs = getDimensions(domainId);
List<DimensionResp> dimensionResps = getDimensions(domainId);
for (DimensionReq dimensionReq : dimensionReqs) {
for (DimensionResp dimensionDesc : dimensionDescs) {
if (dimensionDesc.getName().equalsIgnoreCase(dimensionReq.getBizName())) {
for (DimensionResp dimensionResp : dimensionResps) {
if (dimensionResp.getName().equalsIgnoreCase(dimensionReq.getBizName())) {
throw new RuntimeException(String.format("exist same dimension name:%s", dimensionReq.getName()));
}
if (dimensionDesc.getBizName().equalsIgnoreCase(dimensionReq.getBizName())) {
if (dimensionResp.getBizName().equalsIgnoreCase(dimensionReq.getBizName())) {
throw new RuntimeException(
String.format("exist same dimension bizName:%s", dimensionReq.getBizName()));
}
}
}
}
private void saveDimensionAndGenerateYaml(Dimension dimension, User user) throws Exception {
dimension.createdBy(user.getName());
saveDimension(dimension);
generateYamlFile(dimension.getDatasourceId(), dimension.getDomainId());
}
}

View File

@@ -3,24 +3,25 @@ package com.tencent.supersonic.semantic.core.application;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.common.util.mapper.BeanMapper;
import com.tencent.supersonic.semantic.api.core.request.DomainReq;
import com.tencent.supersonic.semantic.api.core.request.DomainSchemaFilterReq;
import com.tencent.supersonic.semantic.api.core.request.DomainUpdateReq;
import com.tencent.supersonic.semantic.api.core.response.DatasourceResp;
import com.tencent.supersonic.semantic.api.core.response.DimSchemaResp;
import com.tencent.supersonic.semantic.api.core.response.DimensionResp;
import com.tencent.supersonic.semantic.api.core.response.DomainResp;
import com.tencent.supersonic.semantic.api.core.response.DomainSchemaResp;
import com.tencent.supersonic.semantic.api.core.response.MetricResp;
import com.tencent.supersonic.semantic.api.core.response.MetricSchemaResp;
import com.tencent.supersonic.common.util.mapper.BeanMapper;
import com.tencent.supersonic.semantic.core.domain.dataobject.DomainDO;
import com.tencent.supersonic.semantic.core.domain.repository.DomainRepository;
import com.tencent.supersonic.semantic.core.domain.utils.DomainConvert;
import com.tencent.supersonic.semantic.core.domain.DatasourceService;
import com.tencent.supersonic.semantic.core.domain.DimensionService;
import com.tencent.supersonic.semantic.core.domain.DomainService;
import com.tencent.supersonic.semantic.core.domain.MetricService;
import com.tencent.supersonic.semantic.core.domain.dataobject.DomainDO;
import com.tencent.supersonic.semantic.core.domain.pojo.Domain;
import com.tencent.supersonic.semantic.core.domain.repository.DomainRepository;
import com.tencent.supersonic.semantic.core.domain.utils.DomainConvert;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -42,14 +43,15 @@ public class DomainServiceImpl implements DomainService {
private final DomainRepository domainRepository;
private final MetricService metricService;
private final DimensionService dimensionService;
private final DatasourceService datasourceService;
public DomainServiceImpl(DomainRepository domainRepository,
@Lazy MetricService metricService,
@Lazy DimensionService dimensionService) {
public DomainServiceImpl(DomainRepository domainRepository, @Lazy MetricService metricService,
@Lazy DimensionService dimensionService, @Lazy DatasourceService datasourceService) {
this.domainRepository = domainRepository;
this.metricService = metricService;
this.dimensionService = dimensionService;
this.datasourceService = datasourceService;
}
@@ -80,9 +82,20 @@ public class DomainServiceImpl implements DomainService {
@Override
public void deleteDomain(Long id) {
checkDelete(id);
domainRepository.deleteDomain(id);
}
private void checkDelete(Long id) {
List<MetricResp> metricResps = metricService.getMetrics(id);
List<DimensionResp> dimensionResps = dimensionService.getDimensions(id);
List<DatasourceResp> datasourceResps = datasourceService.getDatasourceList(id);
if (!CollectionUtils.isEmpty(metricResps) || !CollectionUtils.isEmpty(datasourceResps)
|| !CollectionUtils.isEmpty(dimensionResps)) {
throw new RuntimeException("exist datasource, dimension or metric in this domain, please check");
}
}
@Override
public String getDomainBizName(Long id) {
if (id == null) {
@@ -99,7 +112,7 @@ public class DomainServiceImpl implements DomainService {
@Override
public List<DomainResp> getDomainList() {
return convertList(domainRepository.getDomainList());
return convertList(domainRepository.getDomainList(), new HashMap<>(), new HashMap<>());
}
@@ -115,7 +128,11 @@ public class DomainServiceImpl implements DomainService {
List<DomainDO> domainDOS = domainRepository.getDomainList();
List<String> orgIds = Lists.newArrayList();
log.info("orgIds:{},userName:{}", orgIds, userName);
return convertList(domainDOS).stream()
Map<Long, List<MetricResp>> metricDomainMap = metricService.getMetrics().stream()
.collect(Collectors.groupingBy(MetricResp::getDomainId));
Map<Long, List<DimensionResp>> dimensionDomainMap = dimensionService.getDimensions().stream()
.collect(Collectors.groupingBy(DimensionResp::getDomainId));
return convertList(domainDOS, metricDomainMap, dimensionDomainMap).stream()
.filter(domainDesc -> checkAdminPermission(orgIds, userName, domainDesc))
.collect(Collectors.toList());
}
@@ -125,7 +142,7 @@ public class DomainServiceImpl implements DomainService {
List<DomainDO> domainDOS = domainRepository.getDomainList();
List<String> orgIds = Lists.newArrayList();
log.info("orgIds:{},userName:{}", orgIds, userName);
return convertList(domainDOS).stream()
return convertList(domainDOS, new HashMap<>(), new HashMap<>()).stream()
.filter(domainDesc -> checkViewerPermission(orgIds, userName, domainDesc))
.collect(Collectors.toList());
}
@@ -160,23 +177,23 @@ public class DomainServiceImpl implements DomainService {
}
private List<DomainResp> convertList(List<DomainDO> domainDOS) {
private List<DomainResp> convertList(List<DomainDO> domainDOS, Map<Long, List<MetricResp>> metricDomainMap,
Map<Long, List<DimensionResp>> dimensionDomainMap) {
List<DomainResp> domainDescs = Lists.newArrayList();
if (CollectionUtils.isEmpty(domainDOS)) {
return domainDescs;
}
Map<Long, String> fullDomainPathMap = getDomainFullPath();
return domainDOS.stream()
.map(domainDO -> DomainConvert.convert(domainDO, fullDomainPathMap))
.map(domainDO -> DomainConvert.convert(domainDO, fullDomainPathMap, dimensionDomainMap,
metricDomainMap))
.collect(Collectors.toList());
}
@Override
public Map<Long, DomainResp> getDomainMap() {
return getDomainList().stream().collect(Collectors.toMap(DomainResp::getId, a -> a, (k1, k2) -> k1));
}

View File

@@ -13,7 +13,6 @@ import com.tencent.supersonic.semantic.api.core.response.DomainResp;
import com.tencent.supersonic.semantic.api.core.response.MetricResp;
import com.tencent.supersonic.common.enums.SensitiveLevelEnum;
import com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO;
import com.tencent.supersonic.semantic.core.domain.manager.MetricYamlManager;
import com.tencent.supersonic.semantic.core.domain.pojo.MetricFilter;
import com.tencent.supersonic.semantic.core.domain.repository.MetricRepository;
import com.tencent.supersonic.semantic.core.domain.utils.MetricConverter;
@@ -27,6 +26,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -38,30 +38,26 @@ public class MetricServiceImpl implements MetricService {
private MetricRepository metricRepository;
private MetricYamlManager metricYamlManager;
private DomainService domainService;
public MetricServiceImpl(MetricRepository metricRepository,
MetricYamlManager metricYamlManager,
DomainService domainService) {
this.domainService = domainService;
this.metricRepository = metricRepository;
this.metricYamlManager = metricYamlManager;
}
@Override
public void creatExprMetric(MetricReq metricReq, User user) throws Exception {
public void creatExprMetric(MetricReq metricReq, User user) {
checkExist(Lists.newArrayList(metricReq));
Metric metric = MetricConverter.convert(metricReq);
metric.createdBy(user.getName());
log.info("[create metric] object:{}", JSONObject.toJSONString(metric));
saveMetricAndGenerateYaml(metric);
saveMetric(metric);
}
@Override
public void createMetricBatch(List<MetricReq> metricReqs, User user) throws Exception {
public void createMetricBatch(List<MetricReq> metricReqs, User user) {
if (CollectionUtils.isEmpty(metricReqs)) {
return;
}
@@ -74,8 +70,6 @@ public class MetricServiceImpl implements MetricService {
.filter(metric -> !metricDescMap.containsKey(metric.getBizName())).collect(Collectors.toList());
log.info("[insert metric] object:{}", JSONObject.toJSONString(metricToInsert));
saveMetricBatch(metricToInsert, user);
generateYamlFile(metrics.get(0).getDomainId());
}
@@ -84,6 +78,11 @@ public class MetricServiceImpl implements MetricService {
return convertList(metricRepository.getMetricList(domainId));
}
@Override
public List<MetricResp> getMetrics() {
return convertList(metricRepository.getMetricList());
}
@Override
public List<MetricResp> getMetrics(Long domainId, Long datasourceId) {
List<MetricResp> metricResps = convertList(metricRepository.getMetricList(domainId));
@@ -136,27 +135,15 @@ public class MetricServiceImpl implements MetricService {
}
@Override
public void updateExprMetric(MetricReq metricReq, User user) throws Exception {
public void updateExprMetric(MetricReq metricReq, User user) {
preCheckMetric(metricReq);
Metric metric = MetricConverter.convert(metricReq);
metric.updatedBy(user.getName());
log.info("[update metric] object:{}", JSONObject.toJSONString(metric));
updateMetric(metric);
generateYamlFile(metric.getDomainId());
}
public List<Metric> getMetricList(Long domainId) {
List<Metric> metrics = Lists.newArrayList();
List<MetricDO> metricDOS = metricRepository.getMetricList(domainId);
if (!CollectionUtils.isEmpty(metricDOS)) {
metrics = metricDOS.stream().map(MetricConverter::convert2Metric).collect(Collectors.toList());
}
return metrics;
}
//保存并获取自增ID
public void saveMetric(Metric metric) {
MetricDO metricDO = MetricConverter.convert2MetricDO(metric);
log.info("[save metric] metricDO:{}", JSONObject.toJSONString(metricDO));
@@ -205,20 +192,12 @@ public class MetricServiceImpl implements MetricService {
}
@Override
public void deleteMetric(Long id) throws Exception {
public void deleteMetric(Long id) {
MetricDO metricDO = metricRepository.getMetricById(id);
if (metricDO == null) {
throw new RuntimeException(String.format("the metric %s not exist", id));
}
metricRepository.deleteMetric(id);
generateYamlFile(metricDO.getDomainId());
}
protected void generateYamlFile(Long domainId) throws Exception {
List<Metric> metrics = getMetricList(domainId);
String fullPath = domainService.getDomainFullPath(domainId);
String domainBizName = domainService.getDomainBizName(domainId);
metricYamlManager.generateYamlFile(metrics, fullPath, domainBizName);
}
@@ -232,21 +211,14 @@ public class MetricServiceImpl implements MetricService {
metricRepository.createMetricBatch(metricDOS);
}
private void saveMetricAndGenerateYaml(Metric metric) throws Exception {
saveMetric(metric);
generateYamlFile(metric.getDomainId());
}
private void preCheckMetric(MetricReq exprMetricReq) {
MetricTypeParams typeParams = exprMetricReq.getTypeParams();
private void preCheckMetric(MetricReq metricReq) {
MetricTypeParams typeParams = metricReq.getTypeParams();
List<Measure> measures = typeParams.getMeasures();
if (CollectionUtils.isEmpty(measures)) {
throw new RuntimeException("measure can not be none");
}
for (Measure measure : measures) {
measure.setExpr(null);
if (StringUtils.isBlank(typeParams.getExpr())) {
throw new RuntimeException("expr can not be blank");
}
}

View File

@@ -24,4 +24,9 @@ public interface DatabaseService {
QueryResultWithSchemaResp queryWithColumns(SqlParserResp sqlParser);
QueryResultWithSchemaResp getDbNames(Long id);
QueryResultWithSchemaResp getTables(Long id, String db);
QueryResultWithSchemaResp getColumns(Long id, String db, String table);
}

View File

@@ -13,6 +13,8 @@ public interface DimensionService {
List<DimensionResp> getDimensions(Long domainId);
List<DimensionResp> getDimensions();
DimensionResp getDimension(String bizName, Long domainId);
void createDimension(DimensionReq dimensionReq, User user) throws Exception;

View File

@@ -13,6 +13,8 @@ public interface MetricService {
List<MetricResp> getMetrics(Long domainId);
List<MetricResp> getMetrics();
List<MetricResp> getMetrics(Long domainId, Long datasourceId);
void creatExprMetric(MetricReq metricReq, User user) throws Exception;

View File

@@ -27,4 +27,22 @@ public class ClickHouseAdaptor extends EngineAdaptor {
return column;
}
@Override
public String getDbMetaQueryTpl() {
return " "
+ " select "
+ " name from system.databases "
+ " where name not in('_temporary_and_external_tables','benchmark','default','system');";
}
@Override
public String getTableMetaQueryTpl() {
return "select name from system.tables where database = '%s';";
}
@Override
public String getColumnMetaQueryTpl() {
return "select name,type as dataType, comment from system.columns where database = '%s' and table='%s'";
}
}

View File

@@ -7,4 +7,9 @@ public abstract class EngineAdaptor {
public abstract String getDateFormat(String dateType, String dateFormat, String column);
public abstract String getColumnMetaQueryTpl();
public abstract String getDbMetaQueryTpl();
public abstract String getTableMetaQueryTpl();
}

View File

@@ -18,7 +18,7 @@ public class MysqlAdaptor extends EngineAdaptor {
} else if (TimeDimensionEnum.WEEK.name().equalsIgnoreCase(dateType)) {
return "to_monday(from_unixtime(unix_timestamp(%s), 'yyyy-MM-dd'))".replace("%s", column);
} else {
return "from_unixtime(unix_timestamp(%s), 'yyyy-MM-dd')".replace("%s", column);
return "date_format(str_to_date(%s, '%Y%m%d'),'%Y-%m-%d')".replace("%s", column);
}
} else if (dateFormat.equalsIgnoreCase(Constants.DAY_FORMAT)) {
if (TimeDimensionEnum.MONTH.name().equalsIgnoreCase(dateType)) {
@@ -33,4 +33,21 @@ public class MysqlAdaptor extends EngineAdaptor {
}
@Override
public String getDbMetaQueryTpl() {
return "select distinct TABLE_SCHEMA from information_schema.tables where TABLE_SCHEMA not in ('information_schema','mysql','performance_schema','sys');";
}
@Override
public String getTableMetaQueryTpl() {
return "select TABLE_NAME from information_schema.tables where TABLE_SCHEMA = '%s';";
}
@Override
public String getColumnMetaQueryTpl() {
return "SELECT COLUMN_NAME as name, DATA_TYPE as dataType, COLUMN_COMMENT as comment " +
"FROM information_schema.columns WHERE table_schema ='%s' AND table_name = '%s'";
}
}

View File

@@ -38,13 +38,6 @@ public class DatabaseDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DatabaseDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DatabaseDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DatabaseDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DatabaseDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DatabaseDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_database null
*/
@@ -812,38 +812,6 @@ public class DatabaseDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -879,5 +847,37 @@ public class DatabaseDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -38,13 +38,6 @@ public class DatasourceDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DatasourceDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DatasourceDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DatasourceDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DatasourceDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DatasourceDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_datasource null
*/
@@ -872,38 +872,6 @@ public class DatasourceDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -939,5 +907,37 @@ public class DatasourceDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -38,13 +38,6 @@ public class DatasourceRelaDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DatasourceRelaDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DatasourceRelaDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DatasourceRelaDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DatasourceRelaDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DatasourceRelaDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_datasource_rela null
*/
@@ -787,38 +787,6 @@ public class DatasourceRelaDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -854,5 +822,37 @@ public class DatasourceRelaDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -38,13 +38,6 @@ public class DictionaryDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DictionaryDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DictionaryDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DictionaryDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DictionaryDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DictionaryDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_dictionary null
*/
@@ -792,38 +792,6 @@ public class DictionaryDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -859,5 +827,37 @@ public class DictionaryDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -37,13 +37,6 @@ public class DictionaryTaskDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -54,8 +47,8 @@ public class DictionaryTaskDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -65,6 +58,13 @@ public class DictionaryTaskDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -116,13 +116,6 @@ public class DictionaryTaskDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -133,8 +126,8 @@ public class DictionaryTaskDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -144,6 +137,13 @@ public class DictionaryTaskDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_dictionary_task null
*/
@@ -461,38 +461,6 @@ public class DictionaryTaskDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -528,5 +496,37 @@ public class DictionaryTaskDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -74,6 +74,16 @@ public class DimensionDO {
*/
private String semanticType;
/**
*
*/
private String alias;
/**
* default values of dimension when query
*/
private String defaultValues;
/**
* 类型参数
*/
@@ -336,6 +346,38 @@ public class DimensionDO {
this.semanticType = semanticType == null ? null : semanticType.trim();
}
/**
* @return alias
*/
public String getAlias() {
return alias;
}
/**
* @param alias
*/
public void setAlias(String alias) {
this.alias = alias == null ? null : alias.trim();
}
/**
* default values of dimension when query
*
* @return default_values default values of dimension when query
*/
public String getDefaultValues() {
return defaultValues;
}
/**
* default values of dimension when query
*
* @param defaultValues default values of dimension when query
*/
public void setDefaultValues(String defaultValues) {
this.defaultValues = defaultValues == null ? null : defaultValues.trim();
}
/**
* 类型参数
*

View File

@@ -38,13 +38,6 @@ public class DimensionDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DimensionDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DimensionDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DimensionDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DimensionDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DimensionDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_dimension null
*/
@@ -665,6 +665,11 @@ public class DimensionDOExample {
return (Criteria) this;
}
public Criteria andSensitiveLevelGreaterThanOrEqualTo(Integer value) {
addCriterion("sensitive_level >=", value, "sensitiveLevel");
return (Criteria) this;
}
public Criteria andSensitiveLevelLessThan(Integer value) {
addCriterion("sensitive_level <", value, "sensitiveLevel");
return (Criteria) this;
@@ -1094,6 +1099,146 @@ public class DimensionDOExample {
addCriterion("semantic_type not between", value1, value2, "semanticType");
return (Criteria) this;
}
public Criteria andAliasIsNull() {
addCriterion("alias is null");
return (Criteria) this;
}
public Criteria andAliasIsNotNull() {
addCriterion("alias is not null");
return (Criteria) this;
}
public Criteria andAliasEqualTo(String value) {
addCriterion("alias =", value, "alias");
return (Criteria) this;
}
public Criteria andAliasNotEqualTo(String value) {
addCriterion("alias <>", value, "alias");
return (Criteria) this;
}
public Criteria andAliasGreaterThan(String value) {
addCriterion("alias >", value, "alias");
return (Criteria) this;
}
public Criteria andAliasGreaterThanOrEqualTo(String value) {
addCriterion("alias >=", value, "alias");
return (Criteria) this;
}
public Criteria andAliasLessThan(String value) {
addCriterion("alias <", value, "alias");
return (Criteria) this;
}
public Criteria andAliasLessThanOrEqualTo(String value) {
addCriterion("alias <=", value, "alias");
return (Criteria) this;
}
public Criteria andAliasLike(String value) {
addCriterion("alias like", value, "alias");
return (Criteria) this;
}
public Criteria andAliasNotLike(String value) {
addCriterion("alias not like", value, "alias");
return (Criteria) this;
}
public Criteria andAliasIn(List<String> values) {
addCriterion("alias in", values, "alias");
return (Criteria) this;
}
public Criteria andAliasNotIn(List<String> values) {
addCriterion("alias not in", values, "alias");
return (Criteria) this;
}
public Criteria andAliasBetween(String value1, String value2) {
addCriterion("alias between", value1, value2, "alias");
return (Criteria) this;
}
public Criteria andAliasNotBetween(String value1, String value2) {
addCriterion("alias not between", value1, value2, "alias");
return (Criteria) this;
}
public Criteria andDefaultValuesIsNull() {
addCriterion("default_values is null");
return (Criteria) this;
}
public Criteria andDefaultValuesIsNotNull() {
addCriterion("default_values is not null");
return (Criteria) this;
}
public Criteria andDefaultValuesEqualTo(String value) {
addCriterion("default_values =", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesNotEqualTo(String value) {
addCriterion("default_values <>", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesGreaterThan(String value) {
addCriterion("default_values >", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesGreaterThanOrEqualTo(String value) {
addCriterion("default_values >=", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesLessThan(String value) {
addCriterion("default_values <", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesLessThanOrEqualTo(String value) {
addCriterion("default_values <=", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesLike(String value) {
addCriterion("default_values like", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesNotLike(String value) {
addCriterion("default_values not like", value, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesIn(List<String> values) {
addCriterion("default_values in", values, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesNotIn(List<String> values) {
addCriterion("default_values not in", values, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesBetween(String value1, String value2) {
addCriterion("default_values between", value1, value2, "defaultValues");
return (Criteria) this;
}
public Criteria andDefaultValuesNotBetween(String value1, String value2) {
addCriterion("default_values not between", value1, value2, "defaultValues");
return (Criteria) this;
}
}
/**
@@ -1127,38 +1272,6 @@ public class DimensionDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -1194,5 +1307,37 @@ public class DimensionDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -38,13 +38,6 @@ public class DomainDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DomainDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DomainDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DomainDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DomainDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DomainDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_domain null
*/
@@ -1142,38 +1142,6 @@ public class DomainDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -1209,5 +1177,37 @@ public class DomainDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -38,13 +38,6 @@ public class DomainExtendDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class DomainExtendDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class DomainExtendDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class DomainExtendDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class DomainExtendDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class DomainExtendDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_domain_extend null
*/
@@ -727,38 +727,6 @@ public class DomainExtendDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -794,5 +762,37 @@ public class DomainExtendDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -74,6 +74,11 @@ public class MetricDO {
*/
private String dataFormat;
/**
*
*/
private String alias;
/**
* 类型参数
*/
@@ -327,6 +332,20 @@ public class MetricDO {
this.dataFormat = dataFormat == null ? null : dataFormat.trim();
}
/**
* @return alias
*/
public String getAlias() {
return alias;
}
/**
* @param alias
*/
public void setAlias(String alias) {
this.alias = alias == null ? null : alias.trim();
}
/**
* 类型参数
*

View File

@@ -38,13 +38,6 @@ public class MetricDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class MetricDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class MetricDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class MetricDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class MetricDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class MetricDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_metric null
*/
@@ -605,6 +605,11 @@ public class MetricDOExample {
return (Criteria) this;
}
public Criteria andSensitiveLevelGreaterThanOrEqualTo(Integer value) {
addCriterion("sensitive_level >=", value, "sensitiveLevel");
return (Criteria) this;
}
public Criteria andSensitiveLevelLessThan(Integer value) {
addCriterion("sensitive_level <", value, "sensitiveLevel");
return (Criteria) this;
@@ -990,6 +995,11 @@ public class MetricDOExample {
return (Criteria) this;
}
public Criteria andDataFormatTypeGreaterThanOrEqualTo(String value) {
addCriterion("data_format_type >=", value, "dataFormatType");
return (Criteria) this;
}
public Criteria andDataFormatTypeLessThan(String value) {
addCriterion("data_format_type <", value, "dataFormatType");
return (Criteria) this;
@@ -1099,6 +1109,76 @@ public class MetricDOExample {
addCriterion("data_format not between", value1, value2, "dataFormat");
return (Criteria) this;
}
public Criteria andAliasIsNull() {
addCriterion("alias is null");
return (Criteria) this;
}
public Criteria andAliasIsNotNull() {
addCriterion("alias is not null");
return (Criteria) this;
}
public Criteria andAliasEqualTo(String value) {
addCriterion("alias =", value, "alias");
return (Criteria) this;
}
public Criteria andAliasNotEqualTo(String value) {
addCriterion("alias <>", value, "alias");
return (Criteria) this;
}
public Criteria andAliasGreaterThan(String value) {
addCriterion("alias >", value, "alias");
return (Criteria) this;
}
public Criteria andAliasGreaterThanOrEqualTo(String value) {
addCriterion("alias >=", value, "alias");
return (Criteria) this;
}
public Criteria andAliasLessThan(String value) {
addCriterion("alias <", value, "alias");
return (Criteria) this;
}
public Criteria andAliasLessThanOrEqualTo(String value) {
addCriterion("alias <=", value, "alias");
return (Criteria) this;
}
public Criteria andAliasLike(String value) {
addCriterion("alias like", value, "alias");
return (Criteria) this;
}
public Criteria andAliasNotLike(String value) {
addCriterion("alias not like", value, "alias");
return (Criteria) this;
}
public Criteria andAliasIn(List<String> values) {
addCriterion("alias in", values, "alias");
return (Criteria) this;
}
public Criteria andAliasNotIn(List<String> values) {
addCriterion("alias not in", values, "alias");
return (Criteria) this;
}
public Criteria andAliasBetween(String value1, String value2) {
addCriterion("alias between", value1, value2, "alias");
return (Criteria) this;
}
public Criteria andAliasNotBetween(String value1, String value2) {
addCriterion("alias not between", value1, value2, "alias");
return (Criteria) this;
}
}
/**
@@ -1132,38 +1212,6 @@ public class MetricDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -1199,5 +1247,37 @@ public class MetricDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -38,13 +38,6 @@ public class ViewInfoDOExample {
oredCriteria = new ArrayList<Criteria>();
}
/**
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* @mbg.generated
*/
@@ -55,8 +48,8 @@ public class ViewInfoDOExample {
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
@@ -66,6 +59,13 @@ public class ViewInfoDOExample {
return distinct;
}
/**
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* @mbg.generated
*/
@@ -117,13 +117,6 @@ public class ViewInfoDOExample {
distinct = false;
}
/**
* @mbg.generated
*/
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
* @mbg.generated
*/
@@ -134,8 +127,8 @@ public class ViewInfoDOExample {
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
public void setLimitStart(Integer limitStart) {
this.limitStart = limitStart;
}
/**
@@ -145,6 +138,13 @@ public class ViewInfoDOExample {
return limitEnd;
}
/**
* @mbg.generated
*/
public void setLimitEnd(Integer limitEnd) {
this.limitEnd = limitEnd;
}
/**
* s2_view_info null
*/
@@ -672,38 +672,6 @@ public class ViewInfoDOExample {
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
@@ -739,5 +707,37 @@ public class ViewInfoDOExample {
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
}
}

View File

@@ -10,66 +10,22 @@ import com.tencent.supersonic.semantic.api.core.pojo.yaml.DimensionYamlTpl;
import com.tencent.supersonic.semantic.api.core.pojo.yaml.IdentifyYamlTpl;
import com.tencent.supersonic.semantic.api.core.pojo.yaml.MeasureYamlTpl;
import com.tencent.supersonic.semantic.api.core.response.DatabaseResp;
import com.tencent.supersonic.semantic.api.core.response.DimensionResp;
import com.tencent.supersonic.common.enums.TypeEnums;
import com.tencent.supersonic.common.util.yaml.YamlUtils;
import com.tencent.supersonic.semantic.core.domain.utils.SysTimeDimensionBuilder;
import com.tencent.supersonic.semantic.core.domain.adaptor.engineadapter.EngineAdaptor;
import com.tencent.supersonic.semantic.core.domain.adaptor.engineadapter.EngineAdaptorFactory;
import com.tencent.supersonic.semantic.core.domain.pojo.Datasource;
import com.tencent.supersonic.semantic.core.domain.pojo.DatasourceQueryEnum;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Service
@Slf4j
public class DatasourceYamlManager {
private YamlManager yamlManager;
public DatasourceYamlManager(YamlManager yamlManager) {
this.yamlManager = yamlManager;
}
public void generateYamlFile(Datasource datasource, DatabaseResp databaseResp, String fullPath,
List<DimensionResp> dimensionDescsExist) throws Exception {
if (!CollectionUtils.isEmpty(dimensionDescsExist)) {
List<String> dimensionBizNames = dimensionDescsExist.stream().map(DimensionResp::getBizName)
.collect(Collectors.toList());
datasource.getDatasourceDetail().getDimensions()
.removeIf(dim -> dimensionBizNames.contains(dim.getBizName()));
}
String yamlStr = convert2YamlStr(datasource, databaseResp);
log.info("generate yaml str :{} from datasource:{} full path:{}", yamlStr, datasource, fullPath);
yamlManager.generateYamlFile(yamlStr, fullPath, getYamlName(datasource.getBizName()));
}
public void deleteYamlFile(String datasourceBizName, String fullPath) throws Exception {
log.info("delete datasource yaml :{} ,fullPath:{}", datasourceBizName, fullPath);
yamlManager.deleteYamlFile(fullPath, getYamlName(datasourceBizName));
}
public String getYamlName(String name) {
return String.format("%s_%s", name, TypeEnums.DATASOURCE.getName());
}
public static String convert2YamlStr(Datasource datasource, DatabaseResp databaseResp) {
DatasourceYamlTpl datasourceYamlTpl = convert2YamlObj(datasource, databaseResp);
Map<String, Object> rootMap = new HashMap<>();
rootMap.put("data_source", datasourceYamlTpl);
return YamlUtils.toYamlWithoutNull(rootMap);
}
public static DatasourceYamlTpl convert2YamlObj(Datasource datasource, DatabaseResp databaseResp) {
DatasourceDetail datasourceDetail = datasource.getDatasourceDetail();
EngineAdaptor engineAdaptor = EngineAdaptorFactory.getEngineAdaptor(databaseResp.getType());

View File

@@ -21,44 +21,6 @@ import org.springframework.util.CollectionUtils;
public class DimensionYamlManager {
private YamlManager yamlManager;
public DimensionYamlManager(YamlManager yamlManager) {
this.yamlManager = yamlManager;
}
public void generateYamlFile(List<Dimension> dimensions, String fullPath, String datasourceBizName)
throws Exception {
String yamlStr = convert2YamlStr(dimensions, datasourceBizName);
log.info("generate yaml str :{} from metric:{} full path:{}", yamlStr, dimensions, fullPath);
yamlManager.generateYamlFile(yamlStr, fullPath, getYamlName(datasourceBizName));
}
public String getYamlName(String name) {
return String.format("%s_%s", name, TypeEnums.DIMENSION.getName());
}
public static String convert2YamlStr(List<Dimension> dimensions, String datasourceBizName) {
if (CollectionUtils.isEmpty(dimensions)) {
return "";
}
List<DimensionYamlTpl> dimensionYamlTpls = dimensions.stream()
.filter(dimension -> !dimension.getType().equalsIgnoreCase("primary"))
.map(DimensionConverter::convert2DimensionYamlTpl).collect(Collectors.toList());
if (CollectionUtils.isEmpty(dimensionYamlTpls)) {
return "";
}
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("source", datasourceBizName);
dataMap.put("dimensions", dimensionYamlTpls);
Map<String, Object> rootMap = new HashMap<>();
rootMap.put("dimension", dataMap);
return YamlUtils.toYamlWithoutNull(rootMap);
}
public static List<DimensionYamlTpl> convert2DimensionYaml(List<Dimension> dimensions) {
if (CollectionUtils.isEmpty(dimensions)) {
return new ArrayList<>();

View File

@@ -1,17 +1,12 @@
package com.tencent.supersonic.semantic.core.domain.manager;
import com.tencent.supersonic.semantic.api.core.pojo.yaml.MetricYamlTpl;
import com.tencent.supersonic.common.enums.TypeEnums;
import com.tencent.supersonic.common.util.yaml.YamlUtils;
import com.tencent.supersonic.semantic.core.domain.pojo.Metric;
import com.tencent.supersonic.semantic.core.domain.utils.MetricConverter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Slf4j
@@ -19,37 +14,6 @@ import org.springframework.util.CollectionUtils;
public class MetricYamlManager {
private YamlManager yamlManager;
public MetricYamlManager(YamlManager yamlManager) {
this.yamlManager = yamlManager;
}
public void generateYamlFile(List<Metric> metrics, String fullPath, String domainBizName) throws Exception {
String yamlStr = convert2YamlStr(metrics);
log.info("generate yaml str :{} from metric:{} full path:{}", yamlStr, metrics, fullPath);
yamlManager.generateYamlFile(yamlStr, fullPath, getYamlName(domainBizName));
}
public String getYamlName(String name) {
return String.format("%s_%s", name, TypeEnums.METRIC.getName());
}
public static String convert2YamlStr(List<Metric> metrics) {
if (CollectionUtils.isEmpty(metrics)) {
return "";
}
StringBuilder yamlBuilder = new StringBuilder();
for (Metric metric : metrics) {
MetricYamlTpl metricYamlTpl = MetricConverter.convert2MetricYamlTpl(metric);
Map<String, Object> rootMap = new HashMap<>();
rootMap.put("metric", metricYamlTpl);
yamlBuilder.append(YamlUtils.toYamlWithoutNull(rootMap)).append("\n");
}
return yamlBuilder.toString();
}
public static List<MetricYamlTpl> convert2YamlObj(List<Metric> metrics) {
List<MetricYamlTpl> metricYamlTpls = new ArrayList<>();

View File

@@ -1,66 +0,0 @@
package com.tencent.supersonic.semantic.core.domain.manager;
import com.tencent.supersonic.common.constant.Constants;
import com.tencent.supersonic.semantic.core.domain.config.YamlConfig;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class YamlManager {
protected final YamlConfig yamlConfig;
// private final ParserService parserService;
public YamlManager(YamlConfig yamlConfig
// , @Lazy ParserService parserService
) {
this.yamlConfig = yamlConfig;
// this.parserService = parserService;
}
public void generateYamlFile(String yamlStr, String path, String name) throws Exception {
String localPath = generateLocalYamlPath(path, name);
File file = createMetaYamlFile(localPath);
FileUtils.writeStringToFile(file, yamlStr, StandardCharsets.UTF_8);
// parserService.reloadModels(path);
}
public void deleteYamlFile(String path, String fileName) {
String localPath = generateLocalYamlPath(path, fileName);
deleteMetaYamlFile(localPath);
}
private File createMetaYamlFile(String fullPath) throws IOException {
File file = new File(fullPath);
if (file.getParentFile().mkdirs() && file.createNewFile()) {
log.info("File :{} created: " + fullPath);
} else {
log.warn("File:{} create failed.", fullPath);
}
return file;
}
private void deleteMetaYamlFile(String fullPath) {
File file = new File(fullPath);
if (file.delete()) {
log.info("File :{} deleted: " + fullPath);
} else {
log.info("File :{} delete failed: " + fullPath);
}
}
private String generateLocalYamlPath(String path, String name) {
return yamlConfig.getmetaYamlFileDir() + path + name + Constants.YAML_FILES_SUFFIX;
}
}

View File

@@ -3,7 +3,7 @@ package com.tencent.supersonic.semantic.core.domain.pojo;
import com.tencent.supersonic.common.pojo.SchemaItem;
import lombok.Data;
import java.util.List;
@Data
public class Dimension extends SchemaItem {
@@ -15,9 +15,12 @@ public class Dimension extends SchemaItem {
private Long domainId;
private Long datasourceId;
private String semanticType;
private String alias;
private List<String> defaultValues;
}

View File

@@ -29,42 +29,9 @@ import org.springframework.stereotype.Component;
@Component
public class JdbcDataSource {
@Bean(name = "wallConfig")
WallConfig wallConfig() {
WallConfig config = new WallConfig();
config.setDeleteAllow(false);
config.setUpdateAllow(false);
config.setInsertAllow(false);
config.setReplaceAllow(false);
config.setMergeAllow(false);
config.setTruncateAllow(false);
config.setCreateTableAllow(false);
config.setAlterTableAllow(false);
config.setDropTableAllow(false);
config.setCommentAllow(true);
config.setUseAllow(false);
config.setDescribeAllow(false);
config.setShowAllow(false);
config.setSelectWhereAlwayTrueCheck(false);
config.setSelectHavingAlwayTrueCheck(false);
config.setSelectUnionCheck(false);
config.setConditionDoubleConstAllow(true);
config.setConditionAndAlwayTrueAllow(true);
config.setConditionAndAlwayFalseAllow(true);
return config;
}
@Bean(name = "wallFilter")
@DependsOn("wallConfig")
WallFilter wallFilter(WallConfig wallConfig) {
WallFilter wfilter = new WallFilter();
wfilter.setConfig(wallConfig);
return wfilter;
}
@Autowired
WallFilter wallFilter;
private static final Object lockLock = new Object();
private static volatile Map<String, DruidDataSource> dataSourceMap = new ConcurrentHashMap<>();
private static volatile Map<String, Lock> dataSourceLockMap = new ConcurrentHashMap<>();
@Value("${source.lock-time:30}")
@Getter
protected Long lockTime;
@@ -136,10 +103,41 @@ public class JdbcDataSource {
@Value("${source.filters:'stat'}")
@Getter
protected String filters;
@Autowired
WallFilter wallFilter;
private static volatile Map<String, DruidDataSource> dataSourceMap = new ConcurrentHashMap<>();
private static volatile Map<String, Lock> dataSourceLockMap = new ConcurrentHashMap<>();
private static final Object lockLock = new Object();
@Bean(name = "wallConfig")
WallConfig wallConfig() {
WallConfig config = new WallConfig();
config.setDeleteAllow(false);
config.setUpdateAllow(false);
config.setInsertAllow(false);
config.setReplaceAllow(false);
config.setMergeAllow(false);
config.setTruncateAllow(false);
config.setCreateTableAllow(false);
config.setAlterTableAllow(false);
config.setDropTableAllow(false);
config.setCommentAllow(true);
config.setUseAllow(false);
config.setDescribeAllow(false);
config.setShowAllow(false);
config.setSelectWhereAlwayTrueCheck(false);
config.setSelectHavingAlwayTrueCheck(false);
config.setSelectUnionCheck(false);
config.setConditionDoubleConstAllow(true);
config.setConditionAndAlwayTrueAllow(true);
config.setConditionAndAlwayFalseAllow(true);
return config;
}
@Bean(name = "wallFilter")
@DependsOn("wallConfig")
WallFilter wallFilter(WallConfig wallConfig) {
WallFilter wfilter = new WallFilter();
wfilter.setConfig(wallConfig);
return wfilter;
}
private Lock getDataSourceLock(String key) {
if (dataSourceLockMap.containsKey(key)) {

View File

@@ -21,4 +21,6 @@ public class Metric extends SchemaItem {
private DataFormat dataFormat;
private String alias;
}

View File

@@ -18,6 +18,8 @@ public interface DimensionRepository {
List<DimensionDO> getDimensionListOfDomain(Long domainId);
List<DimensionDO> getDimensionList();
List<DimensionDO> getDimensionListByIds(List<Long> ids);
DimensionDO getDimensionById(Long id);

View File

@@ -17,6 +17,8 @@ public interface MetricRepository {
List<MetricDO> getMetricList(Long domainId);
List<MetricDO> getMetricList();
List<MetricDO> getMetricListByIds(List<Long> ids);
MetricDO getMetricById(Long id);

View File

@@ -3,6 +3,7 @@ package com.tencent.supersonic.semantic.core.domain.utils;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.semantic.api.core.enums.MetricTypeEnum;
import com.tencent.supersonic.semantic.api.core.pojo.DatasourceDetail;
import com.tencent.supersonic.semantic.api.core.pojo.Dim;
import com.tencent.supersonic.semantic.api.core.pojo.Identify;
@@ -111,16 +112,17 @@ public class DatasourceConverter {
public static MetricReq convert(Measure measure, Datasource datasource) {
measure.setDatasourceId(datasource.getId());
MetricReq exprMetricReq = new MetricReq();
exprMetricReq.setName(measure.getName());
exprMetricReq.setBizName(measure.getBizName().replace(datasource.getBizName() + "_", ""));
exprMetricReq.setDescription(measure.getName());
exprMetricReq.setDomainId(datasource.getDomainId());
MetricReq metricReq = new MetricReq();
metricReq.setName(measure.getName());
metricReq.setBizName(measure.getBizName().replace(datasource.getBizName() + "_", ""));
metricReq.setDescription(measure.getName());
metricReq.setDomainId(datasource.getDomainId());
metricReq.setMetricType(MetricTypeEnum.ATOMIC);
MetricTypeParams exprTypeParams = new MetricTypeParams();
exprTypeParams.setExpr(measure.getBizName());
exprTypeParams.setMeasures(Lists.newArrayList(measure));
exprMetricReq.setTypeParams(exprTypeParams);
return exprMetricReq;
metricReq.setTypeParams(exprTypeParams);
return metricReq;
}
public static DimensionReq convert(Identify identify, Datasource datasource) {

View File

@@ -1,5 +1,6 @@
package com.tencent.supersonic.semantic.core.domain.utils;
import com.alibaba.fastjson.JSONObject;
import com.tencent.supersonic.semantic.api.core.pojo.yaml.DimensionYamlTpl;
import com.tencent.supersonic.semantic.api.core.request.DimensionReq;
import com.tencent.supersonic.semantic.api.core.response.DatasourceResp;
@@ -22,36 +23,34 @@ public class DimensionConverter {
public static DimensionDO convert(DimensionDO dimensionDO, Dimension dimension) {
BeanMapper.mapper(dimension, dimensionDO);
dimensionDO.setDefaultValues(JSONObject.toJSONString(dimension.getDefaultValues()));
return dimensionDO;
}
public static DimensionDO convert2DimensionDO(Dimension dimension) {
DimensionDO dimensionDO = new DimensionDO();
BeanUtils.copyProperties(dimension, dimensionDO);
dimensionDO.setDefaultValues(JSONObject.toJSONString(dimension.getDefaultValues()));
return dimensionDO;
}
public static DimensionResp convert2DimensionDesc(DimensionDO dimensionDO,
public static DimensionResp convert2DimensionResp(DimensionDO dimensionDO,
Map<Long, String> fullPathMap,
Map<Long, DatasourceResp> datasourceDescMap
) {
DimensionResp dimensionDesc = new DimensionResp();
BeanUtils.copyProperties(dimensionDO, dimensionDesc);
dimensionDesc.setFullPath(fullPathMap.get(dimensionDO.getDomainId()) + dimensionDO.getBizName());
dimensionDesc.setDatasourceId(
datasourceDescMap.getOrDefault(dimensionDesc.getDatasourceId(), new DatasourceResp()).getId());
dimensionDesc.setDatasourceName(
datasourceDescMap.getOrDefault(dimensionDesc.getDatasourceId(), new DatasourceResp()).getName());
dimensionDesc.setDatasourceBizName(
datasourceDescMap.getOrDefault(dimensionDesc.getDatasourceId(), new DatasourceResp()).getBizName());
return dimensionDesc;
}
public static Dimension convert2Dimension(DimensionDO dimensionDO) {
Dimension dimension = new Dimension();
BeanUtils.copyProperties(dimensionDO, dimension);
return dimension;
Map<Long, DatasourceResp> datasourceRespMap) {
DimensionResp dimensionResp = new DimensionResp();
BeanUtils.copyProperties(dimensionDO, dimensionResp);
dimensionResp.setFullPath(fullPathMap.get(dimensionDO.getDomainId()) + dimensionDO.getBizName());
dimensionResp.setDatasourceId(
datasourceRespMap.getOrDefault(dimensionResp.getDatasourceId(), new DatasourceResp()).getId());
dimensionResp.setDatasourceName(
datasourceRespMap.getOrDefault(dimensionResp.getDatasourceId(), new DatasourceResp()).getName());
dimensionResp.setDatasourceBizName(
datasourceRespMap.getOrDefault(dimensionResp.getDatasourceId(), new DatasourceResp()).getBizName());
if (dimensionDO.getDefaultValues() != null) {
dimensionResp.setDefaultValues(JSONObject.parseObject(dimensionDO.getDefaultValues(), List.class));
}
return dimensionResp;
}

View File

@@ -4,12 +4,15 @@ package com.tencent.supersonic.semantic.core.domain.utils;
import com.google.common.collect.Lists;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.semantic.api.core.request.DomainReq;
import com.tencent.supersonic.semantic.api.core.response.DimensionResp;
import com.tencent.supersonic.semantic.api.core.response.DomainResp;
import com.tencent.supersonic.common.enums.StatusEnum;
import com.tencent.supersonic.semantic.api.core.response.MetricResp;
import com.tencent.supersonic.semantic.core.domain.dataobject.DomainDO;
import com.tencent.supersonic.semantic.core.domain.pojo.Domain;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -38,18 +41,26 @@ public class DomainConvert {
}
public static DomainResp convert(DomainDO domainDO, Map<Long, String> domainFullPathMap) {
DomainResp domainDesc = new DomainResp();
BeanUtils.copyProperties(domainDO, domainDesc);
domainDesc.setFullPath(domainFullPathMap.get(domainDO.getId()));
domainDesc.setAdmins(StringUtils.isBlank(domainDO.getAdmin())
DomainResp domainResp = new DomainResp();
BeanUtils.copyProperties(domainDO, domainResp);
domainResp.setFullPath(domainFullPathMap.get(domainDO.getId()));
domainResp.setAdmins(StringUtils.isBlank(domainDO.getAdmin())
? Lists.newArrayList() : Arrays.asList(domainDO.getAdmin().split(",")));
domainDesc.setAdminOrgs(StringUtils.isBlank(domainDO.getAdminOrg())
domainResp.setAdminOrgs(StringUtils.isBlank(domainDO.getAdminOrg())
? Lists.newArrayList() : Arrays.asList(domainDO.getAdminOrg().split(",")));
domainDesc.setViewers(StringUtils.isBlank(domainDO.getViewer())
domainResp.setViewers(StringUtils.isBlank(domainDO.getViewer())
? Lists.newArrayList() : Arrays.asList(domainDO.getViewer().split(",")));
domainDesc.setViewOrgs(StringUtils.isBlank(domainDO.getViewOrg())
domainResp.setViewOrgs(StringUtils.isBlank(domainDO.getViewOrg())
? Lists.newArrayList() : Arrays.asList(domainDO.getViewOrg().split(",")));
return domainDesc;
return domainResp;
}
public static DomainResp convert(DomainDO domainDO, Map<Long, String> domainFullPathMap,
Map<Long, List<DimensionResp>> dimensionMap, Map<Long, List<MetricResp>> metricMap) {
DomainResp domainResp = convert(domainDO, domainFullPathMap);
domainResp.setDimensionCnt(dimensionMap.getOrDefault(domainResp.getId(), Lists.newArrayList()).size());
domainResp.setMetricCnt(metricMap.getOrDefault(domainResp.getId(), Lists.newArrayList()).size());
return domainResp;
}

View File

@@ -29,10 +29,9 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class JdbcDataSourceUtils {
private JdbcDataSource jdbcDataSource;
@Getter
private static Set releaseSourceSet = new HashSet();
private JdbcDataSource jdbcDataSource;
public JdbcDataSourceUtils(JdbcDataSource jdbcDataSource) {
this.jdbcDataSource = jdbcDataSource;
@@ -57,54 +56,6 @@ public class JdbcDataSourceUtils {
return false;
}
public DataSource getDataSource(DatabaseResp databaseResp) throws RuntimeException {
return jdbcDataSource.getDataSource(databaseResp);
}
public Connection getConnection(DatabaseResp databaseResp) throws RuntimeException {
Connection conn = getConnectionWithRetry(databaseResp);
if (conn == null) {
try {
releaseDataSource(databaseResp);
DataSource dataSource = getDataSource(databaseResp);
return dataSource.getConnection();
} catch (Exception e) {
log.error("Get connection error, jdbcUrl:{}, e:{}", databaseResp.getUrl(), e);
throw new RuntimeException("Get connection error, jdbcUrl:" + databaseResp.getUrl()
+ " you can try again later or reset datasource");
}
}
return conn;
}
private Connection getConnectionWithRetry(DatabaseResp databaseResp) {
int rc = 1;
for (; ; ) {
if (rc > 3) {
return null;
}
try {
Connection connection = getDataSource(databaseResp).getConnection();
if (connection != null && connection.isValid(5)) {
return connection;
}
} catch (Exception e) {
log.error("e", e);
}
try {
Thread.sleep((long) Math.pow(2, rc) * 1000);
} catch (InterruptedException e) {
log.error("e", e);
}
rc++;
}
}
public static void releaseConnection(Connection connection) {
if (null != connection) {
try {
@@ -177,11 +128,6 @@ public class JdbcDataSourceUtils {
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
}
public void releaseDataSource(DatabaseResp databaseResp) {
jdbcDataSource.removeDatasource(databaseResp);
}
public static String getKey(String name, String jdbcUrl, String username, String password, String version,
boolean isExt) {
@@ -199,4 +145,55 @@ public class JdbcDataSourceUtils {
return MD5Util.getMD5(sb.toString(), true, 64);
}
public DataSource getDataSource(DatabaseResp databaseResp) throws RuntimeException {
return jdbcDataSource.getDataSource(databaseResp);
}
public Connection getConnection(DatabaseResp databaseResp) throws RuntimeException {
Connection conn = getConnectionWithRetry(databaseResp);
if (conn == null) {
try {
releaseDataSource(databaseResp);
DataSource dataSource = getDataSource(databaseResp);
return dataSource.getConnection();
} catch (Exception e) {
log.error("Get connection error, jdbcUrl:{}, e:{}", databaseResp.getUrl(), e);
throw new RuntimeException("Get connection error, jdbcUrl:" + databaseResp.getUrl()
+ " you can try again later or reset datasource");
}
}
return conn;
}
private Connection getConnectionWithRetry(DatabaseResp databaseResp) {
int rc = 1;
for (; ; ) {
if (rc > 3) {
return null;
}
try {
Connection connection = getDataSource(databaseResp).getConnection();
if (connection != null && connection.isValid(5)) {
return connection;
}
} catch (Exception e) {
log.error("e", e);
}
try {
Thread.sleep((long) Math.pow(2, rc) * 1000);
} catch (InterruptedException e) {
log.error("e", e);
}
rc++;
}
}
public void releaseDataSource(DatabaseResp databaseResp) {
jdbcDataSource.removeDatasource(databaseResp);
}
}

View File

@@ -26,7 +26,7 @@ public class MetricConverter {
public static Metric convert(MetricReq metricReq) {
Metric metric = new Metric();
BeanUtils.copyProperties(metricReq, metric);
metric.setType(MetricTypeEnum.EXPR.getName());
metric.setType(metricReq.getMetricType().name());
metric.setTypeParams(metricReq.getTypeParams());
return metric;
}
@@ -75,7 +75,7 @@ public class MetricConverter {
return metric;
}
public static MetricYamlTpl convert2MetricYamlTpl(Metric metric) {
MetricYamlTpl metricYamlTpl = new MetricYamlTpl();
BeanUtils.copyProperties(metric, metricYamlTpl);

View File

@@ -47,6 +47,15 @@ public class SqlUtils {
@Getter
private JdbcDataSourceUtils jdbcDataSourceUtils;
public SqlUtils() {
}
public SqlUtils(DatabaseResp databaseResp) {
this.databaseResp = databaseResp;
this.dataTypeEnum = DataTypeEnum.urlOf(databaseResp.getUrl());
}
public SqlUtils init(DatabaseResp databaseResp) {
//todo Password decryption
return SqlUtilsBuilder
@@ -62,16 +71,6 @@ public class SqlUtils {
.build();
}
public SqlUtils() {
}
public SqlUtils(DatabaseResp databaseResp) {
this.databaseResp = databaseResp;
this.dataTypeEnum = DataTypeEnum.urlOf(databaseResp.getUrl());
}
public List<Map<String, Object>> execute(String sql) throws ServerException {
try {
List<Map<String, Object>> list = jdbcTemplate().queryForList(sql);
@@ -97,7 +96,6 @@ public class SqlUtils {
JdbcDataSourceUtils.releaseConnection(connection);
}
DataSource dataSource = jdbcDataSourceUtils.getDataSource(databaseResp);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setDatabaseProductName(databaseResp.getName());
jdbcTemplate.setFetchSize(500);
@@ -232,4 +230,4 @@ public class SqlUtils {
return sqlUtils;
}
}
}
}

View File

@@ -23,7 +23,7 @@ public class SysTimeDimensionBuilder {
dims.add(generateSysDayDimension(timeDim, engineAdaptor));
dims.add(generateSysWeekDimension(timeDim, engineAdaptor));
dims.add(generateSysMonthDimension(timeDim, engineAdaptor));
log.info("addSysTimeDimension after:{}, engineAdaptor:{}", dims, engineAdaptor);
log.debug("addSysTimeDimension after:{}, engineAdaptor:{}", dims, engineAdaptor);
}

View File

@@ -3,9 +3,9 @@ package com.tencent.supersonic.semantic.core.infrastructure.mapper;
import com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO;
import com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface DimensionDOMapper {
@@ -59,4 +59,4 @@ public interface DimensionDOMapper {
* @mbg.generated
*/
int updateByPrimaryKey(DimensionDO record);
}
}

View File

@@ -48,4 +48,4 @@ public interface DomainDOMapper {
* @mbg.generated
*/
int updateByPrimaryKey(DomainDO record);
}
}

View File

@@ -53,7 +53,7 @@ public class DatasourceRepositoryImpl implements DatasourceRepository {
public DatasourceDO getDatasourceById(Long id) {
return datasourceMapper.selectByPrimaryKey(id);
}
@Override
public void deleteDatasource(Long id) {
datasourceMapper.deleteByPrimaryKey(id);

View File

@@ -56,6 +56,12 @@ public class DimensionRepositoryImpl implements DimensionRepository {
return dimensionDOMapper.selectByExampleWithBLOBs(dimensionDOExample);
}
@Override
public List<DimensionDO> getDimensionList() {
DimensionDOExample dimensionDOExample = new DimensionDOExample();
return dimensionDOMapper.selectByExampleWithBLOBs(dimensionDOExample);
}
@Override
public List<DimensionDO> getDimensionListByIds(List<Long> ids) {
DimensionDOExample dimensionDOExample = new DimensionDOExample();
@@ -86,7 +92,7 @@ public class DimensionRepositoryImpl implements DimensionRepository {
dimensionDOExample.getOredCriteria().get(0).andNameLike("%" + dimensionFilter.getName() + "%");
}
if (dimensionFilter.getBizName() != null) {
dimensionDOExample.getOredCriteria().get(0).andBizNameEqualTo("%" + dimensionFilter.getBizName() + "%");
dimensionDOExample.getOredCriteria().get(0).andBizNameLike("%" + dimensionFilter.getBizName() + "%");
}
if (dimensionFilter.getCreatedBy() != null) {
dimensionDOExample.getOredCriteria().get(0).andCreatedByEqualTo(dimensionFilter.getCreatedBy());
@@ -94,6 +100,9 @@ public class DimensionRepositoryImpl implements DimensionRepository {
if (dimensionFilter.getDomainId() != null) {
dimensionDOExample.getOredCriteria().get(0).andDomainIdEqualTo(dimensionFilter.getDomainId());
}
if (dimensionFilter.getSensitiveLevel() != null) {
dimensionDOExample.getOredCriteria().get(0).andSensitiveLevelEqualTo(dimensionFilter.getSensitiveLevel());
}
return dimensionDOMapper.selectByExampleWithBLOBs(dimensionDOExample);
}

View File

@@ -5,10 +5,13 @@ import com.tencent.supersonic.semantic.core.domain.dataobject.DomainDOExample;
import com.tencent.supersonic.semantic.core.domain.repository.DomainRepository;
import com.tencent.supersonic.semantic.core.infrastructure.mapper.DomainDOMapper;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class DomainRepositoryImpl implements DomainRepository {
private DomainDOMapper domainDOMapper;

View File

@@ -48,6 +48,12 @@ public class MetricRepositoryImpl implements MetricRepository {
return metricDOMapper.selectByExampleWithBLOBs(metricDOExample);
}
@Override
public List<MetricDO> getMetricList() {
MetricDOExample metricDOExample = new MetricDOExample();
return metricDOMapper.selectByExampleWithBLOBs(metricDOExample);
}
@Override
public List<MetricDO> getMetricListByIds(List<Long> ids) {
MetricDOExample metricDOExample = new MetricDOExample();

View File

@@ -59,5 +59,24 @@ public class DatabaseController {
return databaseService.executeSql(sqlExecuteReq.getSql(), sqlExecuteReq.getDomainId());
}
@RequestMapping("/getDbNames/{id}")
public QueryResultWithSchemaResp getDbNames(@PathVariable("id") Long id) {
return databaseService.getDbNames(id);
}
@RequestMapping("/getTables/{id}/{db}")
public QueryResultWithSchemaResp getTables(@PathVariable("id") Long id,
@PathVariable("db") String db) {
return databaseService.getTables(id, db);
}
@RequestMapping("/getColumns/{id}/{db}/{table}")
public QueryResultWithSchemaResp getColumns(@PathVariable("id") Long id,
@PathVariable("db") String db,
@PathVariable("table") String table) {
return databaseService.getColumns(id, db, table);
}
}

View File

@@ -32,7 +32,7 @@ public class ViewInfoController {
@PostMapping("/createOrUpdateViewInfo")
public ViewInfoDO createOrUpdateViewInfo(@RequestBody ViewInfoReq viewInfoReq, HttpServletRequest request,
HttpServletResponse response) {
HttpServletResponse response) {
User user = UserHolder.findUser(request, response);
return viewInfoServiceImpl.createOrUpdateViewInfo(viewInfoReq, user);
}

View File

@@ -1,338 +1,341 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.semantic.core.infrastructure.mapper.DimensionDOMapper">
<resultMap id="BaseResultMap"
type="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="domain_id" jdbcType="BIGINT" property="domainId"/>
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="biz_name" jdbcType="VARCHAR" property="bizName"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="sensitive_level" jdbcType="INTEGER" property="sensitiveLevel"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
<result column="semantic_type" jdbcType="VARCHAR" property="semanticType"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
type="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams"/>
<result column="expr" jdbcType="LONGVARCHAR" property="expr"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and
#{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem"
open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="domain_id" jdbcType="BIGINT" property="domainId" />
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="sensitive_level" jdbcType="INTEGER" property="sensitiveLevel" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="semantic_type" jdbcType="VARCHAR" property="semanticType" />
<result column="alias" jdbcType="VARCHAR" property="alias" />
<result column="default_values" jdbcType="VARCHAR" property="defaultValues" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams" />
<result column="expr" jdbcType="LONGVARCHAR" property="expr" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id
, domain_id, datasource_id, name, biz_name, description, status, sensitive_level,
type, created_at, created_by, updated_at, updated_by, semantic_type
</sql>
<sql id="Blob_Column_List">
type_params
, expr
</sql>
<select id="selectByExampleWithBLOBs"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample"
resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</trim>
</if>
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from s2_dimension
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from s2_dimension
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limitStart != null and limitStart>=0">
limit #{limitStart} , #{limitEnd}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from s2_dimension
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from s2_dimension
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
insert into s2_dimension (id, domain_id, datasource_id,
name, biz_name, description,
status, sensitive_level, type,
created_at, created_by, updated_at,
updated_by, semantic_type, type_params,
expr)
values (#{id,jdbcType=BIGINT}, #{domainId,jdbcType=BIGINT}, #{datasourceId,jdbcType=BIGINT},
#{name,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{sensitiveLevel,jdbcType=INTEGER},
#{type,jdbcType=VARCHAR},
#{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR},
#{updatedAt,jdbcType=TIMESTAMP},
#{updatedBy,jdbcType=VARCHAR}, #{semanticType,jdbcType=VARCHAR},
#{typeParams,jdbcType=LONGVARCHAR},
#{expr,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
insert into s2_dimension
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="domainId != null">
domain_id,
</if>
<if test="datasourceId != null">
datasource_id,
</if>
<if test="name != null">
name,
</if>
<if test="bizName != null">
biz_name,
</if>
<if test="description != null">
description,
</if>
<if test="status != null">
status,
</if>
<if test="sensitiveLevel != null">
sensitive_level,
</if>
<if test="type != null">
type,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="semanticType != null">
semantic_type,
</if>
<if test="typeParams != null">
type_params,
</if>
<if test="expr != null">
expr,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="domainId != null">
#{domainId,jdbcType=BIGINT},
</if>
<if test="datasourceId != null">
#{datasourceId,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
#{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
#{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="semanticType != null">
#{semanticType,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
#{typeParams,jdbcType=LONGVARCHAR},
</if>
<if test="expr != null">
#{expr,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample"
resultType="java.lang.Long">
select count(*) from s2_dimension
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByPrimaryKeySelective"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
update s2_dimension
<set>
<if test="domainId != null">
domain_id = #{domainId,jdbcType=BIGINT},
</if>
<if test="datasourceId != null">
datasource_id = #{datasourceId,jdbcType=BIGINT},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
biz_name = #{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="semanticType != null">
semantic_type = #{semanticType,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
type_params = #{typeParams,jdbcType=LONGVARCHAR},
</if>
<if test="expr != null">
expr = #{expr,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
update s2_dimension
set domain_id = #{domainId,jdbcType=BIGINT},
datasource_id = #{datasourceId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
semantic_type = #{semanticType,jdbcType=VARCHAR},
type_params = #{typeParams,jdbcType=LONGVARCHAR},
expr = #{expr,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
update s2_dimension
set domain_id = #{domainId,jdbcType=BIGINT},
datasource_id = #{datasourceId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
semantic_type = #{semanticType,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, domain_id, datasource_id, name, biz_name, description, status, sensitive_level,
type, created_at, created_by, updated_at, updated_by, semantic_type, alias, default_values
</sql>
<sql id="Blob_Column_List">
type_params, expr
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_dimension
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_dimension
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limitStart != null and limitStart>=0">
limit #{limitStart} , #{limitEnd}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_dimension
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from s2_dimension
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
insert into s2_dimension (id, domain_id, datasource_id,
name, biz_name, description,
status, sensitive_level, type,
created_at, created_by, updated_at,
updated_by, semantic_type, alias,
default_values, type_params, expr
)
values (#{id,jdbcType=BIGINT}, #{domainId,jdbcType=BIGINT}, #{datasourceId,jdbcType=BIGINT},
#{name,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{sensitiveLevel,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR},
#{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP},
#{updatedBy,jdbcType=VARCHAR}, #{semanticType,jdbcType=VARCHAR}, #{alias,jdbcType=VARCHAR},
#{defaultValues,jdbcType=VARCHAR}, #{typeParams,jdbcType=LONGVARCHAR}, #{expr,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
insert into s2_dimension
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="domainId != null">
domain_id,
</if>
<if test="datasourceId != null">
datasource_id,
</if>
<if test="name != null">
name,
</if>
<if test="bizName != null">
biz_name,
</if>
<if test="description != null">
description,
</if>
<if test="status != null">
status,
</if>
<if test="sensitiveLevel != null">
sensitive_level,
</if>
<if test="type != null">
type,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="semanticType != null">
semantic_type,
</if>
<if test="alias != null">
alias,
</if>
<if test="defaultValues != null">
default_values,
</if>
<if test="typeParams != null">
type_params,
</if>
<if test="expr != null">
expr,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="domainId != null">
#{domainId,jdbcType=BIGINT},
</if>
<if test="datasourceId != null">
#{datasourceId,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
#{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
#{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="semanticType != null">
#{semanticType,jdbcType=VARCHAR},
</if>
<if test="alias != null">
#{alias,jdbcType=VARCHAR},
</if>
<if test="defaultValues != null">
#{defaultValues,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
#{typeParams,jdbcType=LONGVARCHAR},
</if>
<if test="expr != null">
#{expr,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDOExample" resultType="java.lang.Long">
select count(*) from s2_dimension
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
update s2_dimension
<set>
<if test="domainId != null">
domain_id = #{domainId,jdbcType=BIGINT},
</if>
<if test="datasourceId != null">
datasource_id = #{datasourceId,jdbcType=BIGINT},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
biz_name = #{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="semanticType != null">
semantic_type = #{semanticType,jdbcType=VARCHAR},
</if>
<if test="alias != null">
alias = #{alias,jdbcType=VARCHAR},
</if>
<if test="defaultValues != null">
default_values = #{defaultValues,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
type_params = #{typeParams,jdbcType=LONGVARCHAR},
</if>
<if test="expr != null">
expr = #{expr,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
update s2_dimension
set domain_id = #{domainId,jdbcType=BIGINT},
datasource_id = #{datasourceId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
semantic_type = #{semanticType,jdbcType=VARCHAR},
alias = #{alias,jdbcType=VARCHAR},
default_values = #{defaultValues,jdbcType=VARCHAR},
type_params = #{typeParams,jdbcType=LONGVARCHAR},
expr = #{expr,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.DimensionDO">
update s2_dimension
set domain_id = #{domainId,jdbcType=BIGINT},
datasource_id = #{datasourceId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
semantic_type = #{semanticType,jdbcType=VARCHAR},
alias = #{alias,jdbcType=VARCHAR},
default_values = #{defaultValues,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -1,324 +1,316 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.semantic.core.infrastructure.mapper.MetricDOMapper">
<resultMap id="BaseResultMap"
type="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="domain_id" jdbcType="BIGINT" property="domainId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="biz_name" jdbcType="VARCHAR" property="bizName"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="sensitive_level" jdbcType="INTEGER" property="sensitiveLevel"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
<result column="data_format_type" jdbcType="VARCHAR" property="dataFormatType"/>
<result column="data_format" jdbcType="VARCHAR" property="dataFormat"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
type="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and
#{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem"
open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="domain_id" jdbcType="BIGINT" property="domainId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="sensitive_level" jdbcType="INTEGER" property="sensitiveLevel" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="data_format_type" jdbcType="VARCHAR" property="dataFormatType" />
<result column="data_format" jdbcType="VARCHAR" property="dataFormat" />
<result column="alias" jdbcType="VARCHAR" property="alias" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id
, domain_id, name, biz_name, description, status, sensitive_level, type, created_at,
created_by, updated_at, updated_by, data_format_type, data_format
</sql>
<sql id="Blob_Column_List">
type_params
</sql>
<select id="selectByExampleWithBLOBs"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDOExample"
resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</trim>
</if>
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from s2_metric
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDOExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from s2_metric
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limitStart != null and limitStart>=0">
limit #{limitStart} , #{limitEnd}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from s2_metric
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from s2_metric
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
insert into s2_metric (id, domain_id, name,
biz_name, description, status,
sensitive_level, type, created_at,
created_by, updated_at, updated_by,
data_format_type, data_format, type_params)
values (#{id,jdbcType=BIGINT}, #{domainId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
#{bizName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER},
#{sensitiveLevel,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR},
#{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP},
#{updatedBy,jdbcType=VARCHAR},
#{dataFormatType,jdbcType=VARCHAR}, #{dataFormat,jdbcType=VARCHAR},
#{typeParams,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
insert into s2_metric
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="domainId != null">
domain_id,
</if>
<if test="name != null">
name,
</if>
<if test="bizName != null">
biz_name,
</if>
<if test="description != null">
description,
</if>
<if test="status != null">
status,
</if>
<if test="sensitiveLevel != null">
sensitive_level,
</if>
<if test="type != null">
type,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="dataFormatType != null">
data_format_type,
</if>
<if test="dataFormat != null">
data_format,
</if>
<if test="typeParams != null">
type_params,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="domainId != null">
#{domainId,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
#{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
#{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="dataFormatType != null">
#{dataFormatType,jdbcType=VARCHAR},
</if>
<if test="dataFormat != null">
#{dataFormat,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
#{typeParams,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDOExample"
resultType="java.lang.Long">
select count(*) from s2_metric
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByPrimaryKeySelective"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
update s2_metric
<set>
<if test="domainId != null">
domain_id = #{domainId,jdbcType=BIGINT},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
biz_name = #{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="dataFormatType != null">
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
</if>
<if test="dataFormat != null">
data_format = #{dataFormat,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
type_params = #{typeParams,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
update s2_metric
set domain_id = #{domainId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
data_format = #{dataFormat,jdbcType=VARCHAR},
type_params = #{typeParams,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey"
parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
update s2_metric
set domain_id = #{domainId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
data_format = #{dataFormat,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, domain_id, name, biz_name, description, status, sensitive_level, type, created_at,
created_by, updated_at, updated_by, data_format_type, data_format, alias
</sql>
<sql id="Blob_Column_List">
type_params
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_metric
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_metric
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limitStart != null and limitStart>=0">
limit #{limitStart} , #{limitEnd}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_metric
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from s2_metric
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
insert into s2_metric (id, domain_id, name,
biz_name, description, status,
sensitive_level, type, created_at,
created_by, updated_at, updated_by,
data_format_type, data_format, alias,
type_params)
values (#{id,jdbcType=BIGINT}, #{domainId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
#{bizName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
#{sensitiveLevel,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR},
#{dataFormatType,jdbcType=VARCHAR}, #{dataFormat,jdbcType=VARCHAR}, #{alias,jdbcType=VARCHAR},
#{typeParams,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
insert into s2_metric
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="domainId != null">
domain_id,
</if>
<if test="name != null">
name,
</if>
<if test="bizName != null">
biz_name,
</if>
<if test="description != null">
description,
</if>
<if test="status != null">
status,
</if>
<if test="sensitiveLevel != null">
sensitive_level,
</if>
<if test="type != null">
type,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="dataFormatType != null">
data_format_type,
</if>
<if test="dataFormat != null">
data_format,
</if>
<if test="alias != null">
alias,
</if>
<if test="typeParams != null">
type_params,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="domainId != null">
#{domainId,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
#{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
#{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="dataFormatType != null">
#{dataFormatType,jdbcType=VARCHAR},
</if>
<if test="dataFormat != null">
#{dataFormat,jdbcType=VARCHAR},
</if>
<if test="alias != null">
#{alias,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
#{typeParams,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDOExample" resultType="java.lang.Long">
select count(*) from s2_metric
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
update s2_metric
<set>
<if test="domainId != null">
domain_id = #{domainId,jdbcType=BIGINT},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="bizName != null">
biz_name = #{bizName,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="sensitiveLevel != null">
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="dataFormatType != null">
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
</if>
<if test="dataFormat != null">
data_format = #{dataFormat,jdbcType=VARCHAR},
</if>
<if test="alias != null">
alias = #{alias,jdbcType=VARCHAR},
</if>
<if test="typeParams != null">
type_params = #{typeParams,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
update s2_metric
set domain_id = #{domainId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
data_format = #{dataFormat,jdbcType=VARCHAR},
alias = #{alias,jdbcType=VARCHAR},
type_params = #{typeParams,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.core.domain.dataobject.MetricDO">
update s2_metric
set domain_id = #{domainId,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sensitive_level = #{sensitiveLevel,jdbcType=INTEGER},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
data_format = #{dataFormat,jdbcType=VARCHAR},
alias = #{alias,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -32,16 +32,23 @@
</insert>
<select id="getDateInfos" resultMap="BaseResultMap">
select *
select e.*
from s2_available_date_info e
inner join
(
select item_id, max(created_at) as created_at
from s2_available_date_info
where `type` = #{type}
<if test="itemIds != null and itemIds.size >0">
and item_id in
<foreach collection="itemIds" index="index" item="item" open="(" close=")"
separator=",">
separator=",">
#{item}
</foreach>
</if>
group by item_id
) t
on e.item_id=t.item_id and e.created_at=t.created_at
</select>
</mapper>