mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-30 04:54:25 +08:00
Compare commits
6 Commits
bda4bdda77
...
07825b50b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07825b50b5 | ||
|
|
b70b7ed01a | ||
|
|
335e1f9ada | ||
|
|
33268bf3d9 | ||
|
|
86b9d2013a | ||
|
|
aced1dfd3e |
@@ -9,7 +9,8 @@ public enum EngineType {
|
|||||||
POSTGRESQL(6, "POSTGRESQL"),
|
POSTGRESQL(6, "POSTGRESQL"),
|
||||||
OTHER(7, "OTHER"),
|
OTHER(7, "OTHER"),
|
||||||
DUCKDB(8, "DUCKDB"),
|
DUCKDB(8, "DUCKDB"),
|
||||||
HANADB(9, "HANADB");
|
HANADB(9, "HANADB"),
|
||||||
|
STARROCKS(10, "STARROCKS"),;
|
||||||
|
|
||||||
private Integer code;
|
private Integer code;
|
||||||
|
|
||||||
|
|||||||
@@ -106,8 +106,6 @@ public class PromptHelper {
|
|||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(metric.getDefaultAgg())) {
|
if (StringUtils.isNotEmpty(metric.getDefaultAgg())) {
|
||||||
metricStr.append(" AGGREGATE '" + metric.getDefaultAgg().toUpperCase() + "'");
|
metricStr.append(" AGGREGATE '" + metric.getDefaultAgg().toUpperCase() + "'");
|
||||||
} else {
|
|
||||||
metricStr.append(" AGGREGATE 'NONE'");
|
|
||||||
}
|
}
|
||||||
metricStr.append(">");
|
metricStr.append(">");
|
||||||
metrics.add(metricStr.toString());
|
metrics.add(metricStr.toString());
|
||||||
|
|||||||
@@ -17,7 +17,20 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BaseDbAdaptor implements DbAdaptor {
|
public abstract class BaseDbAdaptor implements DbAdaptor {
|
||||||
|
|
||||||
public List<String> getDBs(ConnectInfo connectionInfo) throws SQLException {
|
@Override
|
||||||
|
public List<String> getCatalogs(ConnectInfo connectInfo) throws SQLException {
|
||||||
|
// Apart from supporting multiple catalog types of data sources, other types will return an
|
||||||
|
// empty set by default.
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDBs(ConnectInfo connectionInfo, String catalog) throws SQLException {
|
||||||
|
// Except for special types implemented separately, the generic logic catalog does not take
|
||||||
|
// effect.
|
||||||
|
return getDBs(connectionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<String> getDBs(ConnectInfo connectionInfo) throws SQLException {
|
||||||
List<String> dbs = Lists.newArrayList();
|
List<String> dbs = Lists.newArrayList();
|
||||||
DatabaseMetaData metaData = getDatabaseMetaData(connectionInfo);
|
DatabaseMetaData metaData = getDatabaseMetaData(connectionInfo);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ public interface DbAdaptor {
|
|||||||
|
|
||||||
String rewriteSql(String sql);
|
String rewriteSql(String sql);
|
||||||
|
|
||||||
List<String> getDBs(ConnectInfo connectInfo) throws SQLException;
|
List<String> getCatalogs(ConnectInfo connectInfo) throws SQLException;
|
||||||
|
|
||||||
|
List<String> getDBs(ConnectInfo connectInfo, String catalog) throws SQLException;
|
||||||
|
|
||||||
List<String> getTables(ConnectInfo connectInfo, String schemaName) throws SQLException;
|
List<String> getTables(ConnectInfo connectInfo, String schemaName) throws SQLException;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class DbAdaptorFactory {
|
|||||||
dbAdaptorMap.put(EngineType.OTHER.getName(), new DefaultDbAdaptor());
|
dbAdaptorMap.put(EngineType.OTHER.getName(), new DefaultDbAdaptor());
|
||||||
dbAdaptorMap.put(EngineType.DUCKDB.getName(), new DuckdbAdaptor());
|
dbAdaptorMap.put(EngineType.DUCKDB.getName(), new DuckdbAdaptor());
|
||||||
dbAdaptorMap.put(EngineType.HANADB.getName(), new HanadbAdaptor());
|
dbAdaptorMap.put(EngineType.HANADB.getName(), new HanadbAdaptor());
|
||||||
|
dbAdaptorMap.put(EngineType.STARROCKS.getName(), new StarrocksAdaptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DbAdaptor getEngineAdaptor(String engineType) {
|
public static DbAdaptor getEngineAdaptor(String engineType) {
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.tencent.supersonic.headless.core.adaptor.db;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.tencent.supersonic.headless.core.pojo.ConnectInfo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class StarrocksAdaptor extends MysqlAdaptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getCatalogs(ConnectInfo connectInfo) throws SQLException {
|
||||||
|
List<String> catalogs = Lists.newArrayList();
|
||||||
|
try (Connection con = DriverManager.getConnection(connectInfo.getUrl(),
|
||||||
|
connectInfo.getUserName(), connectInfo.getPassword());
|
||||||
|
Statement st = con.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("SHOW CATALOGS")) {
|
||||||
|
while (rs.next()) {
|
||||||
|
catalogs.add(rs.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return catalogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getDBs(ConnectInfo connectionInfo, String catalog) throws SQLException {
|
||||||
|
Assert.hasText(catalog, "StarRocks type catalog can not be null or empty");
|
||||||
|
List<String> dbs = Lists.newArrayList();
|
||||||
|
try (Connection con = DriverManager.getConnection(connectionInfo.getUrl(),
|
||||||
|
connectionInfo.getUserName(), connectionInfo.getPassword());
|
||||||
|
Statement st = con.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("SHOW DATABASES IN " + catalog)) {
|
||||||
|
while (rs.next()) {
|
||||||
|
dbs.add(rs.getString(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dbs;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ public class DbParameterFactory {
|
|||||||
parametersBuilder.put(EngineType.MYSQL.getName(), new MysqlParametersBuilder());
|
parametersBuilder.put(EngineType.MYSQL.getName(), new MysqlParametersBuilder());
|
||||||
parametersBuilder.put(EngineType.POSTGRESQL.getName(), new PostgresqlParametersBuilder());
|
parametersBuilder.put(EngineType.POSTGRESQL.getName(), new PostgresqlParametersBuilder());
|
||||||
parametersBuilder.put(EngineType.HANADB.getName(), new HanadbParametersBuilder());
|
parametersBuilder.put(EngineType.HANADB.getName(), new HanadbParametersBuilder());
|
||||||
|
parametersBuilder.put(EngineType.STARROCKS.getName(), new StarrocksParametersBuilder());
|
||||||
parametersBuilder.put(EngineType.OTHER.getName(), new OtherParametersBuilder());
|
parametersBuilder.put(EngineType.OTHER.getName(), new OtherParametersBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.headless.server.pojo;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class StarrocksParametersBuilder extends DefaultParametersBuilder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DatabaseParameter> build() {
|
||||||
|
return super.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,9 +76,15 @@ public class DatabaseController {
|
|||||||
return databaseService.executeSql(sqlExecuteReq, user);
|
return databaseService.executeSql(sqlExecuteReq, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getCatalogs")
|
||||||
|
public List<String> getCatalogs(@RequestParam("id") Long databaseId) throws SQLException {
|
||||||
|
return databaseService.getCatalogs(databaseId);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/getDbNames")
|
@RequestMapping("/getDbNames")
|
||||||
public List<String> getDbNames(@RequestParam("id") Long databaseId) throws SQLException {
|
public List<String> getDbNames(@RequestParam("id") Long databaseId,
|
||||||
return databaseService.getDbNames(databaseId);
|
@RequestParam(value = "catalog", required = false) String catalog) throws SQLException {
|
||||||
|
return databaseService.getDbNames(databaseId, catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/getTables")
|
@RequestMapping("/getTables")
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ public interface DatabaseService {
|
|||||||
|
|
||||||
void deleteDatabase(Long databaseId);
|
void deleteDatabase(Long databaseId);
|
||||||
|
|
||||||
List<String> getDbNames(Long id) throws SQLException;
|
List<String> getCatalogs(Long id) throws SQLException;
|
||||||
|
|
||||||
|
List<String> getDbNames(Long id, String catalog) throws SQLException;
|
||||||
|
|
||||||
List<String> getTables(Long id, String db) throws SQLException;
|
List<String> getTables(Long id, String db) throws SQLException;
|
||||||
|
|
||||||
|
|||||||
@@ -200,10 +200,17 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDbNames(Long id) throws SQLException {
|
public List<String> getCatalogs(Long id) throws SQLException {
|
||||||
DatabaseResp databaseResp = getDatabase(id);
|
DatabaseResp databaseResp = getDatabase(id);
|
||||||
DbAdaptor dbAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
|
DbAdaptor dbAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
|
||||||
return dbAdaptor.getDBs(DatabaseConverter.getConnectInfo(databaseResp));
|
return dbAdaptor.getCatalogs(DatabaseConverter.getConnectInfo(databaseResp));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getDbNames(Long id, String catalog) throws SQLException {
|
||||||
|
DatabaseResp databaseResp = getDatabase(id);
|
||||||
|
DbAdaptor dbAdaptor = DbAdaptorFactory.getEngineAdaptor(databaseResp.getType());
|
||||||
|
return dbAdaptor.getDBs(DatabaseConverter.getConnectInfo(databaseResp), catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -104,11 +104,11 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
|
|||||||
} else {
|
} else {
|
||||||
MetricResp metricRespByBizName = bizNameMap.get(metric.getBizName());
|
MetricResp metricRespByBizName = bizNameMap.get(metric.getBizName());
|
||||||
MetricResp metricRespByName = nameMap.get(metric.getName());
|
MetricResp metricRespByName = nameMap.get(metric.getName());
|
||||||
if (null != metricRespByBizName && isChange(metric, metricRespByBizName)) {
|
if (null != metricRespByBizName) {
|
||||||
metric.setId(metricRespByBizName.getId());
|
metric.setId(metricRespByBizName.getId());
|
||||||
this.updateMetric(metric, user);
|
this.updateMetric(metric, user);
|
||||||
} else {
|
} else {
|
||||||
if (null != metricRespByName && isChange(metric, metricRespByName)) {
|
if (null != metricRespByName) {
|
||||||
metric.setId(metricRespByName.getId());
|
metric.setId(metricRespByName.getId());
|
||||||
this.updateMetric(metric, user);
|
this.updateMetric(metric, user);
|
||||||
}
|
}
|
||||||
@@ -819,7 +819,7 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
|
|||||||
return modelResps.stream().map(ModelResp::getId).collect(Collectors.toSet());
|
return modelResps.stream().map(ModelResp::getId).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isChange(MetricReq metricReq, MetricResp metricResp) {
|
private boolean isNameChange(MetricReq metricReq, MetricResp metricResp) {
|
||||||
boolean isNameChange = !metricReq.getName().equals(metricResp.getName());
|
boolean isNameChange = !metricReq.getName().equals(metricResp.getName());
|
||||||
return isNameChange;
|
return isNameChange;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,8 +142,12 @@ public class ModelServiceImpl implements ModelService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ModelResp updateModel(ModelReq modelReq, User user) throws Exception {
|
public ModelResp updateModel(ModelReq modelReq, User user) throws Exception {
|
||||||
// checkParams(modelReq);
|
// Comment out below checks for now, they seem unnecessary and
|
||||||
|
// lead to unexpected exception in updating model
|
||||||
|
/*
|
||||||
|
checkParams(modelReq);
|
||||||
checkRelations(modelReq);
|
checkRelations(modelReq);
|
||||||
|
*/
|
||||||
ModelDO modelDO = modelRepository.getModelById(modelReq.getId());
|
ModelDO modelDO = modelRepository.getModelById(modelReq.getId());
|
||||||
ModelConverter.convert(modelDO, modelReq, user);
|
ModelConverter.convert(modelDO, modelReq, user);
|
||||||
modelRepository.updateModel(modelDO);
|
modelRepository.updateModel(modelDO);
|
||||||
|
|||||||
@@ -17,6 +17,25 @@
|
|||||||
<start-class>com.tencent.supersonic.StandaloneLauncher</start-class>
|
<start-class>com.tencent.supersonic.StandaloneLauncher</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-expression</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-beans</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tencent.supersonic</groupId>
|
<groupId>com.tencent.supersonic</groupId>
|
||||||
<artifactId>launchers-common</artifactId>
|
<artifactId>launchers-common</artifactId>
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ DELETE FROM s2_canvas;
|
|||||||
|
|
||||||
-- sample user
|
-- sample user
|
||||||
-- The default value for the password is 123456
|
-- The default value for the password is 123456
|
||||||
insert into s2_user (id, `name`, password, salt, display_name, email, is_admin) values (1, 'admin','c3VwZXJzb25pY0BiaWNvbdktJJYWw6A3rEmBUPzbn/6DNeYnD+y3mAwDKEMS3KVT','jGl25bVBBBW96Qi9Te4V3w==','admin','admin@xx.com', 1);
|
INSERT INTO s2_user (`name`, password, salt, display_name, email, is_admin) values ('admin','c3VwZXJzb25pY0BiaWNvbdktJJYWw6A3rEmBUPzbn/6DNeYnD+y3mAwDKEMS3KVT','jGl25bVBBBW96Qi9Te4V3w==','admin','admin@xx.com', 1);
|
||||||
insert into s2_user (id, `name`, password, salt, display_name, email) values (2, 'jack','c3VwZXJzb25pY0BiaWNvbWxGalmwa0h/trkh/3CWOYMDiku0Op1VmOfESIKmN0HG','MWERWefm/3hD6kYndF6JIg==','jack','jack@xx.com');
|
INSERT INTO s2_user (`name`, password, salt, display_name, email) values ('jack','c3VwZXJzb25pY0BiaWNvbWxGalmwa0h/trkh/3CWOYMDiku0Op1VmOfESIKmN0HG','MWERWefm/3hD6kYndF6JIg==','jack','jack@xx.com');
|
||||||
insert into s2_user (id, `name`, password, salt, display_name, email) values (3, 'tom','c3VwZXJzb25pY0BiaWNvbVWv0CZ6HzeX8GRUpw0C8NSaQ+0hE/dAcmzRpCFwAqxK','4WCPdcXXgT89QDHLML+3hg==','tom','tom@xx.com');
|
INSERT INTO s2_user (`name`, password, salt, display_name, email) values ('tom','c3VwZXJzb25pY0BiaWNvbVWv0CZ6HzeX8GRUpw0C8NSaQ+0hE/dAcmzRpCFwAqxK','4WCPdcXXgT89QDHLML+3hg==','tom','tom@xx.com');
|
||||||
insert into s2_user (id, `name`, password, salt, display_name, email, is_admin) values (4, 'lucy','c3VwZXJzb25pY0BiaWNvbc7Ychfu99lPL7rLmCkf/vgF4RASa4Z++Mxo1qlDCpci','3Jnpqob6uDoGLP9eCAg5Fw==','lucy','lucy@xx.com', 1);
|
INSERT INTO s2_user (`name`, password, salt, display_name, email, is_admin) values ('lucy','c3VwZXJzb25pY0BiaWNvbc7Ychfu99lPL7rLmCkf/vgF4RASa4Z++Mxo1qlDCpci','3Jnpqob6uDoGLP9eCAg5Fw==','lucy','lucy@xx.com', 1);
|
||||||
insert into s2_user (id, `name`, password, salt, display_name, email) values (5, 'alice','c3VwZXJzb25pY0BiaWNvbe9Z4F2/DVIfAJoN1HwUTuH1KgVuiusvfh7KkWYQSNHk','K9gGyX8OAK8aH8Myj6djqQ==','alice','alice@xx.com');
|
INSERT INTO s2_user (`name`, password, salt, display_name, email) values ('alice','c3VwZXJzb25pY0BiaWNvbe9Z4F2/DVIfAJoN1HwUTuH1KgVuiusvfh7KkWYQSNHk','K9gGyX8OAK8aH8Myj6djqQ==','alice','alice@xx.com');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO s2_available_date_info (`item_id`, `type`, `date_format`, `start_date`, `end_date`, `unavailable_date`, `created_at`, `created_by`, `updated_at`, `updated_by`)
|
INSERT INTO s2_available_date_info (`item_id`, `type`, `date_format`, `start_date`, `end_date`, `unavailable_date`, `created_at`, `created_by`, `updated_at`, `updated_by`)
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ DELETE FROM s2_canvas;
|
|||||||
|
|
||||||
-- sample user
|
-- sample user
|
||||||
-- The default value for the password is 123456
|
-- The default value for the password is 123456
|
||||||
insert into s2_user (id, "name", password, salt, display_name, email, is_admin) values (1, 'admin','c3VwZXJzb25pY0BiaWNvbdktJJYWw6A3rEmBUPzbn/6DNeYnD+y3mAwDKEMS3KVT','jGl25bVBBBW96Qi9Te4V3w==','admin','admin@xx.com', 1);
|
insert into s2_user ("name", password, salt, display_name, email, is_admin) values ('admin','c3VwZXJzb25pY0BiaWNvbdktJJYWw6A3rEmBUPzbn/6DNeYnD+y3mAwDKEMS3KVT','jGl25bVBBBW96Qi9Te4V3w==','admin','admin@xx.com', 1);
|
||||||
insert into s2_user (id, "name", password, salt, display_name, email) values (2, 'jack','c3VwZXJzb25pY0BiaWNvbWxGalmwa0h/trkh/3CWOYMDiku0Op1VmOfESIKmN0HG','MWERWefm/3hD6kYndF6JIg==','jack','jack@xx.com');
|
insert into s2_user ("name", password, salt, display_name, email) values ('jack','c3VwZXJzb25pY0BiaWNvbWxGalmwa0h/trkh/3CWOYMDiku0Op1VmOfESIKmN0HG','MWERWefm/3hD6kYndF6JIg==','jack','jack@xx.com');
|
||||||
insert into s2_user (id, "name", password, salt, display_name, email) values (3, 'tom','c3VwZXJzb25pY0BiaWNvbVWv0CZ6HzeX8GRUpw0C8NSaQ+0hE/dAcmzRpCFwAqxK','4WCPdcXXgT89QDHLML+3hg==','tom','tom@xx.com');
|
insert into s2_user ("name", password, salt, display_name, email) values ('tom','c3VwZXJzb25pY0BiaWNvbVWv0CZ6HzeX8GRUpw0C8NSaQ+0hE/dAcmzRpCFwAqxK','4WCPdcXXgT89QDHLML+3hg==','tom','tom@xx.com');
|
||||||
insert into s2_user (id, "name", password, salt, display_name, email, is_admin) values (4, 'lucy','c3VwZXJzb25pY0BiaWNvbc7Ychfu99lPL7rLmCkf/vgF4RASa4Z++Mxo1qlDCpci','3Jnpqob6uDoGLP9eCAg5Fw==','lucy','lucy@xx.com', 1);
|
insert into s2_user ("name", password, salt, display_name, email, is_admin) values ('lucy','c3VwZXJzb25pY0BiaWNvbc7Ychfu99lPL7rLmCkf/vgF4RASa4Z++Mxo1qlDCpci','3Jnpqob6uDoGLP9eCAg5Fw==','lucy','lucy@xx.com', 1);
|
||||||
insert into s2_user (id, "name", password, salt, display_name, email) values (5, 'alice','c3VwZXJzb25pY0BiaWNvbe9Z4F2/DVIfAJoN1HwUTuH1KgVuiusvfh7KkWYQSNHk','K9gGyX8OAK8aH8Myj6djqQ==','alice','alice@xx.com');
|
insert into s2_user ("name", password, salt, display_name, email) values ('alice','c3VwZXJzb25pY0BiaWNvbe9Z4F2/DVIfAJoN1HwUTuH1KgVuiusvfh7KkWYQSNHk','K9gGyX8OAK8aH8Myj6djqQ==','alice','alice@xx.com');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO s2_available_date_info (item_id, type, date_format, start_date, end_date, unavailable_date, created_at, created_by, updated_at, updated_by)
|
INSERT INTO s2_available_date_info (item_id, type, date_format, start_date, end_date, unavailable_date, created_at, created_by, updated_at, updated_by)
|
||||||
|
|||||||
5
pom.xml
5
pom.xml
@@ -214,11 +214,6 @@
|
|||||||
<artifactId>mockito-inline</artifactId>
|
<artifactId>mockito-inline</artifactId>
|
||||||
<version>${mockito-inline.version}</version>
|
<version>${mockito-inline.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
|
||||||
<version>2.1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aws-java-sdk</artifactId>
|
<artifactId>aws-java-sdk</artifactId>
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ const BarChart: React.FC<Props> = ({
|
|||||||
} else {
|
} else {
|
||||||
instanceObj = instanceRef.current;
|
instanceObj = instanceRef.current;
|
||||||
}
|
}
|
||||||
const data = (queryResults || []).sort(
|
const data = (queryResults || []);
|
||||||
(a: any, b: any) => b[metricColumnName] - a[metricColumnName]
|
|
||||||
);
|
|
||||||
const xData = data.map(item =>
|
const xData = data.map(item =>
|
||||||
item[categoryColumnName] !== undefined ? item[categoryColumnName] : '未知'
|
item[categoryColumnName] !== undefined ? item[categoryColumnName] : '未知'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Form, Input, Spin, Select, message } from 'antd';
|
import { Form, Input, Spin, Select, message } from 'antd';
|
||||||
import type { FormInstance } from 'antd/lib/form';
|
import type { FormInstance } from 'antd/lib/form';
|
||||||
import { getDbNames, getTables, getDimensionList } from '../../service';
|
import {getDbNames, getTables, getDimensionList, getCatalogs} from '../../service';
|
||||||
import { ISemantic } from '../../data';
|
import { ISemantic } from '../../data';
|
||||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||||
|
|
||||||
@@ -20,13 +20,16 @@ const ModelBasicForm: React.FC<Props> = ({
|
|||||||
isEdit,
|
isEdit,
|
||||||
modelItem,
|
modelItem,
|
||||||
databaseConfigList,
|
databaseConfigList,
|
||||||
|
form,
|
||||||
mode = 'normal',
|
mode = 'normal',
|
||||||
}) => {
|
}) => {
|
||||||
const [currentDbLinkConfigId, setCurrentDbLinkConfigId] = useState<number>();
|
const [currentDbLinkConfigId, setCurrentDbLinkConfigId] = useState<number>();
|
||||||
|
const [catalogList, setCatalogList] = useState<string[]>([]);
|
||||||
const [dbNameList, setDbNameList] = useState<string[]>([]);
|
const [dbNameList, setDbNameList] = useState<string[]>([]);
|
||||||
const [tableNameList, setTableNameList] = useState<any[]>([]);
|
const [tableNameList, setTableNameList] = useState<any[]>([]);
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
const [dimensionOptions, setDimensionOptions] = useState<{ label: string; value: number }[]>([]);
|
const [dimensionOptions, setDimensionOptions] = useState<{ label: string; value: number }[]>([]);
|
||||||
|
const [catalogSelectOpen, setCatalogSelectOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (modelItem?.id) {
|
if (modelItem?.id) {
|
||||||
@@ -50,9 +53,49 @@ const ModelBasicForm: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryDbNameList = async (databaseId: number) => {
|
const onDatabaseSelect = (databaseId: number, type: string) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { code, data, msg } = await getDbNames(databaseId);
|
if (type === 'STARROCKS') {
|
||||||
|
queryCatalogList(databaseId)
|
||||||
|
setCatalogSelectOpen(true);
|
||||||
|
setDbNameList([]);
|
||||||
|
} else {
|
||||||
|
queryDbNameList(databaseId, "");
|
||||||
|
setCatalogSelectOpen(false);
|
||||||
|
setCatalogList([]);
|
||||||
|
}
|
||||||
|
form.setFieldsValue({
|
||||||
|
catalog: undefined,
|
||||||
|
dbName: undefined,
|
||||||
|
tableName: undefined,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
const queryCatalogList = async (databaseId: number) => {
|
||||||
|
setLoading(true);
|
||||||
|
const { code, data, msg } = await getCatalogs(databaseId);
|
||||||
|
setLoading(false)
|
||||||
|
if (code === 200) {
|
||||||
|
const list = data || [];
|
||||||
|
setCatalogList(list);
|
||||||
|
} else {
|
||||||
|
message.error(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onCatalogSelect = (catalog: string) => {
|
||||||
|
if (currentDbLinkConfigId) {
|
||||||
|
queryDbNameList(currentDbLinkConfigId, catalog);
|
||||||
|
}
|
||||||
|
form.setFieldsValue({
|
||||||
|
dbName: undefined,
|
||||||
|
tableName: undefined,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryDbNameList = async (databaseId: number, catalog: string) => {
|
||||||
|
setLoading(true);
|
||||||
|
const { code, data, msg } = await getDbNames(databaseId, catalog);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
const list = data || [];
|
const list = data || [];
|
||||||
@@ -61,6 +104,7 @@ const ModelBasicForm: React.FC<Props> = ({
|
|||||||
message.error(msg);
|
message.error(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryTableNameList = async (databaseName: string) => {
|
const queryTableNameList = async (databaseName: string) => {
|
||||||
if (!currentDbLinkConfigId) {
|
if (!currentDbLinkConfigId) {
|
||||||
return;
|
return;
|
||||||
@@ -89,18 +133,37 @@ const ModelBasicForm: React.FC<Props> = ({
|
|||||||
showSearch
|
showSearch
|
||||||
placeholder="请选择数据库连接"
|
placeholder="请选择数据库连接"
|
||||||
disabled={isEdit}
|
disabled={isEdit}
|
||||||
onChange={(dbLinkConfigId: number) => {
|
onSelect={(dbLinkConfigId: number, option) => {
|
||||||
queryDbNameList(dbLinkConfigId);
|
onDatabaseSelect(dbLinkConfigId, option.type);
|
||||||
setCurrentDbLinkConfigId(dbLinkConfigId);
|
setCurrentDbLinkConfigId(dbLinkConfigId);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{databaseConfigList.map((item) => (
|
{databaseConfigList.map((item) => (
|
||||||
<Select.Option key={item.id} value={item.id} disabled={!item.hasUsePermission}>
|
<Select.Option key={item.id} value={item.id} disabled={!item.hasUsePermission} type={item.type}>
|
||||||
{item.name}
|
{item.name}
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem
|
||||||
|
name="catalog"
|
||||||
|
label="Catalog"
|
||||||
|
rules={[{ required: true, message: '请选择Catalog' }]}
|
||||||
|
hidden={!catalogSelectOpen}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
placeholder="请选择Catalog"
|
||||||
|
disabled={isEdit}
|
||||||
|
onSelect={onCatalogSelect}
|
||||||
|
>
|
||||||
|
{catalogList.map((item) => (
|
||||||
|
<Select.Option key={item} value={item}>
|
||||||
|
{item}
|
||||||
|
</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormItem>
|
||||||
<FormItem
|
<FormItem
|
||||||
name="dbName"
|
name="dbName"
|
||||||
label="数据库名"
|
label="数据库名"
|
||||||
@@ -110,8 +173,11 @@ const ModelBasicForm: React.FC<Props> = ({
|
|||||||
showSearch
|
showSearch
|
||||||
placeholder="请先选择一个数据库连接"
|
placeholder="请先选择一个数据库连接"
|
||||||
disabled={isEdit}
|
disabled={isEdit}
|
||||||
onChange={(dbName: string) => {
|
onSelect={(dbName: string) => {
|
||||||
queryTableNameList(dbName);
|
queryTableNameList(dbName);
|
||||||
|
form.setFieldsValue({
|
||||||
|
tableName: undefined,
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{dbNameList.map((item) => (
|
{dbNameList.map((item) => (
|
||||||
|
|||||||
@@ -379,11 +379,21 @@ export async function listColumnsBySql(data: { databaseId: number; sql: string }
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDbNames(dbId: number): Promise<any> {
|
export function getCatalogs(dbId: number): Promise<any> {
|
||||||
|
return request(`${process.env.API_BASE_URL}database/getCatalogs`, {
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
id: dbId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDbNames(dbId: number, catalog: string): Promise<any> {
|
||||||
return request(`${process.env.API_BASE_URL}database/getDbNames`, {
|
return request(`${process.env.API_BASE_URL}database/getDbNames`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: {
|
params: {
|
||||||
id: dbId,
|
id: dbId,
|
||||||
|
catalog: catalog,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user