mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-24 16:34:20 +08:00
Compare commits
11 Commits
v0.9.10
...
fb71ed3dc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb71ed3dc1 | ||
|
|
f764236657 | ||
|
|
738093bc88 | ||
|
|
b6d1525daa | ||
|
|
efddf4cacf | ||
|
|
732222ab98 | ||
|
|
5b994c4f8f | ||
|
|
5d2ebdf680 | ||
|
|
f1bc18ef65 | ||
|
|
8f361f9932 | ||
|
|
f532088e38 |
2
.github/workflows/centos-ci.yml
vendored
2
.github/workflows/centos-ci.yml
vendored
@@ -47,7 +47,7 @@ jobs:
|
|||||||
mvn -version
|
mvn -version
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|||||||
2
.github/workflows/mac-ci.yml
vendored
2
.github/workflows/mac-ci.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/Library/Caches/Maven # macOS Maven cache path
|
path: ~/Library/Caches/Maven # macOS Maven cache path
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|||||||
2
.github/workflows/ubuntu-ci.yml
vendored
2
.github/workflows/ubuntu-ci.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|||||||
2
.github/workflows/windows-ci.yml
vendored
2
.github/workflows/windows-ci.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
distribution: 'adopt' # You might need to change this if 'adopt' doesn't support JDK 21
|
distribution: 'adopt' # You might need to change this if 'adopt' doesn't support JDK 21
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~\.m2 # Windows uses a backslash for paths
|
path: ~\.m2 # Windows uses a backslash for paths
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ SuperSonic comes with sample semantic models as well as chat conversations that
|
|||||||
|
|
||||||
## Build and Development
|
## Build and Development
|
||||||
|
|
||||||
Please refer to project [Docs](https://supersonicbi.github.io/docs/%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA/).
|
Please refer to project [Docs](https://supersonicbi.github.io/docs/%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E9%83%A8%E7%BD%B2/).
|
||||||
|
|
||||||
## WeChat Contact
|
## WeChat Contact
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ SuperSonic自带样例的语义模型和问答对话,只需以下三步即可
|
|||||||
|
|
||||||
## 如何构建和部署
|
## 如何构建和部署
|
||||||
|
|
||||||
请参考项目[文档](https://supersonicbi.github.io/docs/%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA/)。
|
请参考项目[文档](https://supersonicbi.github.io/docs/%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E9%83%A8%E7%BD%B2/)。
|
||||||
|
|
||||||
## 微信联系方式
|
## 微信联系方式
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ SuperSonicには、サンプルのセマンティックモデルとチャット
|
|||||||
|
|
||||||
## ビルドと開発
|
## ビルドと開発
|
||||||
|
|
||||||
プロジェクト[ドキュメント](https://supersonicbi.github.io/docs/%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA/)を参照してください。
|
プロジェクト[ドキュメント](https://supersonicbi.github.io/docs/%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E9%83%A8%E7%BD%B2/)を参照してください。
|
||||||
|
|
||||||
## WeChat連絡先
|
## WeChat連絡先
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tencent.supersonic.auth.authentication.interceptor;
|
package com.tencent.supersonic.auth.authentication.interceptor;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
||||||
import com.tencent.supersonic.auth.authentication.service.UserServiceImpl;
|
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||||
import com.tencent.supersonic.auth.authentication.utils.TokenService;
|
import com.tencent.supersonic.auth.authentication.utils.TokenService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -16,7 +16,7 @@ public abstract class AuthenticationInterceptor implements HandlerInterceptor {
|
|||||||
|
|
||||||
protected AuthenticationConfig authenticationConfig;
|
protected AuthenticationConfig authenticationConfig;
|
||||||
|
|
||||||
protected UserServiceImpl userServiceImpl;
|
protected UserService userService;
|
||||||
|
|
||||||
protected TokenService tokenService;
|
protected TokenService tokenService;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.tencent.supersonic.auth.authentication.interceptor;
|
|||||||
import com.tencent.supersonic.auth.api.authentication.annotation.AuthenticationIgnore;
|
import com.tencent.supersonic.auth.api.authentication.annotation.AuthenticationIgnore;
|
||||||
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
import com.tencent.supersonic.auth.api.authentication.config.AuthenticationConfig;
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
import com.tencent.supersonic.auth.api.authentication.pojo.UserWithPassword;
|
||||||
import com.tencent.supersonic.auth.authentication.service.UserServiceImpl;
|
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||||
import com.tencent.supersonic.auth.authentication.utils.TokenService;
|
import com.tencent.supersonic.auth.authentication.utils.TokenService;
|
||||||
import com.tencent.supersonic.common.pojo.exception.AccessException;
|
import com.tencent.supersonic.common.pojo.exception.AccessException;
|
||||||
import com.tencent.supersonic.common.util.ContextUtils;
|
import com.tencent.supersonic.common.util.ContextUtils;
|
||||||
@@ -16,12 +16,7 @@ import org.springframework.web.method.HandlerMethod;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_IS_ADMIN;
|
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.*;
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_USER_DISPLAY_NAME;
|
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_USER_EMAIL;
|
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_USER_ID;
|
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_USER_NAME;
|
|
||||||
import static com.tencent.supersonic.auth.api.authentication.constant.UserConstants.TOKEN_USER_PASSWORD;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor {
|
public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor {
|
||||||
@@ -30,7 +25,7 @@ public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor
|
|||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||||
Object handler) throws AccessException {
|
Object handler) throws AccessException {
|
||||||
authenticationConfig = ContextUtils.getBean(AuthenticationConfig.class);
|
authenticationConfig = ContextUtils.getBean(AuthenticationConfig.class);
|
||||||
userServiceImpl = ContextUtils.getBean(UserServiceImpl.class);
|
userService = ContextUtils.getBean(UserService.class);
|
||||||
tokenService = ContextUtils.getBean(TokenService.class);
|
tokenService = ContextUtils.getBean(TokenService.class);
|
||||||
if (!authenticationConfig.isEnabled()) {
|
if (!authenticationConfig.isEnabled()) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -26,6 +26,16 @@ public class SqlDialectFactory {
|
|||||||
.withLiteralQuoteString("'").withIdentifierQuoteString("\"")
|
.withLiteralQuoteString("'").withIdentifierQuoteString("\"")
|
||||||
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
||||||
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
|
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
|
||||||
|
public static final Context PRESTO_CONTEXT =
|
||||||
|
SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.PRESTO)
|
||||||
|
.withLiteralQuoteString("'").withIdentifierQuoteString("\"")
|
||||||
|
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
||||||
|
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
|
||||||
|
public static final Context KYUUBI_CONTEXT =
|
||||||
|
SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.BIG_QUERY)
|
||||||
|
.withLiteralQuoteString("'").withIdentifierQuoteString("`")
|
||||||
|
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
||||||
|
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(false);
|
||||||
private static Map<EngineType, SemanticSqlDialect> sqlDialectMap;
|
private static Map<EngineType, SemanticSqlDialect> sqlDialectMap;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -35,6 +45,10 @@ public class SqlDialectFactory {
|
|||||||
sqlDialectMap.put(EngineType.H2, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
sqlDialectMap.put(EngineType.H2, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
||||||
sqlDialectMap.put(EngineType.POSTGRESQL, new SemanticSqlDialect(POSTGRESQL_CONTEXT));
|
sqlDialectMap.put(EngineType.POSTGRESQL, new SemanticSqlDialect(POSTGRESQL_CONTEXT));
|
||||||
sqlDialectMap.put(EngineType.HANADB, new SemanticSqlDialect(HANADB_CONTEXT));
|
sqlDialectMap.put(EngineType.HANADB, new SemanticSqlDialect(HANADB_CONTEXT));
|
||||||
|
sqlDialectMap.put(EngineType.STARROCKS, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
||||||
|
sqlDialectMap.put(EngineType.KYUUBI, new SemanticSqlDialect(KYUUBI_CONTEXT));
|
||||||
|
sqlDialectMap.put(EngineType.PRESTO, new SemanticSqlDialect(PRESTO_CONTEXT));
|
||||||
|
sqlDialectMap.put(EngineType.TRINO, new SemanticSqlDialect(PRESTO_CONTEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SemanticSqlDialect getSqlDialect(EngineType engineType) {
|
public static SemanticSqlDialect getSqlDialect(EngineType engineType) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.tencent.supersonic.common.pojo;
|
|||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import static com.tencent.supersonic.common.pojo.Constants.ASC_UPPER;
|
import static com.tencent.supersonic.common.pojo.Constants.ASC_UPPER;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "15432:5432"
|
- "15432:5432"
|
||||||
# volumes:
|
# volumes:
|
||||||
# - postgres_data:/var/lib/postgresql
|
# - postgres_data:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
- supersonic_network
|
- supersonic_network
|
||||||
dns:
|
dns:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tencent.supersonic.headless.core.translator;
|
package com.tencent.supersonic.headless.core.translator;
|
||||||
|
|
||||||
import com.tencent.supersonic.common.calcite.SqlMergeWithUtils;
|
import com.tencent.supersonic.common.calcite.SqlMergeWithUtils;
|
||||||
|
import com.tencent.supersonic.common.jsqlparser.SqlSelectHelper;
|
||||||
import com.tencent.supersonic.common.pojo.enums.EngineType;
|
import com.tencent.supersonic.common.pojo.enums.EngineType;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.QueryState;
|
import com.tencent.supersonic.headless.api.pojo.response.QueryState;
|
||||||
import com.tencent.supersonic.headless.core.pojo.OntologyQuery;
|
import com.tencent.supersonic.headless.core.pojo.OntologyQuery;
|
||||||
@@ -73,7 +74,7 @@ public class DefaultSemanticTranslator implements SemanticTranslator {
|
|||||||
String finalSql = null;
|
String finalSql = null;
|
||||||
if (sqlQuery.isSupportWith()) {
|
if (sqlQuery.isSupportWith()) {
|
||||||
EngineType engineType = queryStatement.getOntology().getDatabaseType();
|
EngineType engineType = queryStatement.getOntology().getDatabaseType();
|
||||||
if (!SqlMergeWithUtils.hasWith(engineType, ontologyOuterSql)) {
|
if (!SqlSelectHelper.hasWith(ontologyOuterSql)) {
|
||||||
finalSql = "with " + tables.stream()
|
finalSql = "with " + tables.stream()
|
||||||
.map(t -> String.format("%s as (%s)", t.getLeft(), t.getRight()))
|
.map(t -> String.format("%s as (%s)", t.getLeft(), t.getRight()))
|
||||||
.collect(Collectors.joining(",")) + "\n" + ontologyOuterSql;
|
.collect(Collectors.joining(",")) + "\n" + ontologyOuterSql;
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ public abstract class SemanticNode {
|
|||||||
scope.getValidator().getCatalogReader().getRootSchema(), engineType);
|
scope.getValidator().getCatalogReader().getRootSchema(), engineType);
|
||||||
if (Configuration.getSqlAdvisor(sqlValidatorWithHints, engineType).getReservedAndKeyWords()
|
if (Configuration.getSqlAdvisor(sqlValidatorWithHints, engineType).getReservedAndKeyWords()
|
||||||
.contains(expression.toUpperCase())) {
|
.contains(expression.toUpperCase())) {
|
||||||
if (engineType == EngineType.HANADB) {
|
if (engineType == EngineType.HANADB || engineType == EngineType.PRESTO
|
||||||
|
|| engineType == EngineType.TRINO) {
|
||||||
expression = String.format("\"%s\"", expression);
|
expression = String.format("\"%s\"", expression);
|
||||||
} else {
|
} else {
|
||||||
expression = String.format("`%s`", expression);
|
expression = String.format("`%s`", expression);
|
||||||
@@ -166,9 +167,9 @@ public abstract class SemanticNode {
|
|||||||
if (sqlNode instanceof SqlBasicCall) {
|
if (sqlNode instanceof SqlBasicCall) {
|
||||||
SqlBasicCall sqlBasicCall = (SqlBasicCall) sqlNode;
|
SqlBasicCall sqlBasicCall = (SqlBasicCall) sqlNode;
|
||||||
if (sqlBasicCall.getOperator().getKind().equals(SqlKind.AS)) {
|
if (sqlBasicCall.getOperator().getKind().equals(SqlKind.AS)) {
|
||||||
if (sqlBasicCall.getOperandList().get(0) instanceof SqlSelect) {
|
SqlNode innerQuery = sqlBasicCall.getOperandList().get(0);
|
||||||
SqlSelect table = (SqlSelect) sqlBasicCall.getOperandList().get(0);
|
if (innerQuery instanceof SqlCall) {
|
||||||
return table;
|
return innerQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,13 @@ public class SqlBuilder {
|
|||||||
SqlNode parserNode = tableView.build();
|
SqlNode parserNode = tableView.build();
|
||||||
DatabaseResp database = queryStatement.getOntology().getDatabase();
|
DatabaseResp database = queryStatement.getOntology().getDatabase();
|
||||||
EngineType engineType = EngineType.fromString(database.getType());
|
EngineType engineType = EngineType.fromString(database.getType());
|
||||||
parserNode = optimizeParseNode(parserNode, engineType);
|
try {
|
||||||
|
parserNode = optimizeParseNode(parserNode, engineType);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// failure in optimization phase doesn't affect the query result,
|
||||||
|
// just ignore it
|
||||||
|
log.error("optimizeParseNode error", e);
|
||||||
|
}
|
||||||
return SemanticNode.getSql(parserNode, engineType);
|
return SemanticNode.getSql(parserNode, engineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.tencent.supersonic.headless.server.rest;
|
|||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||||
import com.tencent.supersonic.common.pojo.User;
|
import com.tencent.supersonic.common.pojo.User;
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||||
import com.tencent.supersonic.headless.api.pojo.MetaFilter;
|
import com.tencent.supersonic.headless.api.pojo.MetaFilter;
|
||||||
import com.tencent.supersonic.headless.api.pojo.request.DataSetReq;
|
import com.tencent.supersonic.headless.api.pojo.request.DataSetReq;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.DataSetResp;
|
import com.tencent.supersonic.headless.api.pojo.response.DataSetResp;
|
||||||
@@ -51,6 +52,7 @@ public class DataSetController {
|
|||||||
public List<DataSetResp> getDataSetList(@RequestParam("domainId") Long domainId) {
|
public List<DataSetResp> getDataSetList(@RequestParam("domainId") Long domainId) {
|
||||||
MetaFilter metaFilter = new MetaFilter();
|
MetaFilter metaFilter = new MetaFilter();
|
||||||
metaFilter.setDomainId(domainId);
|
metaFilter.setDomainId(domainId);
|
||||||
|
metaFilter.setStatus(StatusEnum.ONLINE.getCode());
|
||||||
return dataSetService.getDataSetList(metaFilter);
|
return dataSetService.getDataSetList(metaFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
|
|||||||
public DataSetResp save(DataSetReq dataSetReq, User user) {
|
public DataSetResp save(DataSetReq dataSetReq, User user) {
|
||||||
dataSetReq.createdBy(user.getName());
|
dataSetReq.createdBy(user.getName());
|
||||||
DataSetDO dataSetDO = convert(dataSetReq);
|
DataSetDO dataSetDO = convert(dataSetReq);
|
||||||
dataSetDO.setStatus(StatusEnum.ONLINE.getCode());
|
dataSetDO.setStatus(dataSetReq.getStatus() != null ? dataSetReq.getStatus()
|
||||||
|
: StatusEnum.ONLINE.getCode());
|
||||||
DataSetResp dataSetResp = convert(dataSetDO);
|
DataSetResp dataSetResp = convert(dataSetDO);
|
||||||
// conflictCheck(dataSetResp);
|
|
||||||
save(dataSetDO);
|
save(dataSetDO);
|
||||||
dataSetResp.setId(dataSetDO.getId());
|
dataSetResp.setId(dataSetDO.getId());
|
||||||
return dataSetResp;
|
return dataSetResp;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||||
import com.tencent.supersonic.common.pojo.User;
|
import com.tencent.supersonic.common.pojo.User;
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||||
import com.tencent.supersonic.common.pojo.enums.EngineType;
|
import com.tencent.supersonic.common.pojo.enums.EngineType;
|
||||||
import com.tencent.supersonic.headless.api.pojo.DBColumn;
|
import com.tencent.supersonic.headless.api.pojo.DBColumn;
|
||||||
import com.tencent.supersonic.headless.api.pojo.enums.DataType;
|
import com.tencent.supersonic.headless.api.pojo.enums.DataType;
|
||||||
@@ -79,8 +80,9 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DatabaseResp> getDatabaseList(User user) {
|
public List<DatabaseResp> getDatabaseList(User user) {
|
||||||
List<DatabaseResp> databaseResps =
|
List<DatabaseResp> databaseResps = list().stream().map(DatabaseConverter::convert)
|
||||||
list().stream().map(DatabaseConverter::convert).collect(Collectors.toList());
|
.filter(database -> filterByAuth(database, user, AuthType.VIEWER))
|
||||||
|
.collect(Collectors.toList());
|
||||||
fillPermission(databaseResps, user);
|
fillPermission(databaseResps, user);
|
||||||
return databaseResps;
|
return databaseResps;
|
||||||
}
|
}
|
||||||
@@ -100,6 +102,43 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean filterByAuth(DatabaseResp database, User user, AuthType authType) {
|
||||||
|
if (user.isSuperAdmin() || user.getName().equals(database.getCreatedBy())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
authType = authType == null ? AuthType.VIEWER : authType;
|
||||||
|
switch (authType) {
|
||||||
|
case ADMIN:
|
||||||
|
return checkAdminPermission(user, database);
|
||||||
|
case VIEWER:
|
||||||
|
default:
|
||||||
|
return checkViewPermission(user, database);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkAdminPermission(User user, DatabaseResp database) {
|
||||||
|
List<String> admins = database.getAdmins();
|
||||||
|
if (user.isSuperAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (admins.contains(user.getName()) || database.getCreatedBy().equals(user.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkViewPermission(User user, DatabaseResp database) {
|
||||||
|
if (checkAdminPermission(user, database)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
List<String> viewers = database.getViewers();
|
||||||
|
|
||||||
|
if (viewers.contains(user.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDatabase(Long databaseId) {
|
public void deleteDatabase(Long databaseId) {
|
||||||
ModelFilter modelFilter = new ModelFilter();
|
ModelFilter modelFilter = new ModelFilter();
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -26,7 +26,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>0.9.10</revision>
|
<revision>1.0.0-SNAPSHOT</revision>
|
||||||
<java.source.version>21</java.source.version>
|
<java.source.version>21</java.source.version>
|
||||||
<java.target.version>21</java.target.version>
|
<java.target.version>21</java.target.version>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
|||||||
@@ -48,12 +48,13 @@ const MetricTrend: React.FC<Props> = ({
|
|||||||
const { queryColumns, queryResults, aggregateInfo, entityInfo, chatContext } = data;
|
const { queryColumns, queryResults, aggregateInfo, entityInfo, chatContext } = data;
|
||||||
const [chartType, setChartType] = useState('line');
|
const [chartType, setChartType] = useState('line');
|
||||||
|
|
||||||
const dateField: any = queryColumns?.find(
|
const dateField = queryColumns?.find(
|
||||||
(column: any) => column.showType === 'DATE' || column.type === 'DATE'
|
(column: any) => column.showType === 'DATE' || column.type === 'DATE'
|
||||||
);
|
);
|
||||||
const dateColumnName = dateField?.bizName || '';
|
const dateColumnName = dateField?.bizName || '';
|
||||||
const categoryColumnName =
|
let categoryColumnName =
|
||||||
queryColumns?.find((column: any) => column.showType === 'CATEGORY')?.bizName || '';
|
queryColumns?.find((column: any) => column.showType === 'CATEGORY')?.bizName || '';
|
||||||
|
categoryColumnName = categoryColumnName === dateColumnName ? '' : categoryColumnName;
|
||||||
const metricFields = queryColumns?.filter((column: any) => column.showType === 'NUMBER');
|
const metricFields = queryColumns?.filter((column: any) => column.showType === 'NUMBER');
|
||||||
|
|
||||||
const currentMetricField = queryColumns?.find((column: any) => column.showType === 'NUMBER');
|
const currentMetricField = queryColumns?.find((column: any) => column.showType === 'NUMBER');
|
||||||
@@ -80,11 +81,11 @@ const MetricTrend: React.FC<Props> = ({
|
|||||||
<MetricInfo aggregateInfo={aggregateInfo} currentMetricField={currentMetricField} />
|
<MetricInfo aggregateInfo={aggregateInfo} currentMetricField={currentMetricField} />
|
||||||
)}
|
)}
|
||||||
<div className={`${prefixCls}-select-options`}>
|
<div className={`${prefixCls}-select-options`}>
|
||||||
<DateOptions
|
{/*<DateOptions*/}
|
||||||
chatContext={chatContext}
|
{/* chatContext={chatContext}*/}
|
||||||
currentDateOption={currentDateOption}
|
{/* currentDateOption={currentDateOption}*/}
|
||||||
onSelectDateOption={onSelectDateOption}
|
{/* onSelectDateOption={onSelectDateOption}*/}
|
||||||
/>
|
{/*/>*/}
|
||||||
<div>
|
<div>
|
||||||
<Select
|
<Select
|
||||||
defaultValue="line"
|
defaultValue="line"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { ISemantic } from '../../data';
|
|||||||
import {
|
import {
|
||||||
AGG_OPTIONS,
|
AGG_OPTIONS,
|
||||||
DATE_FORMATTER,
|
DATE_FORMATTER,
|
||||||
DATE_OPTIONS,
|
// DATE_OPTIONS,
|
||||||
DIM_OPTIONS,
|
DIM_OPTIONS,
|
||||||
EnumDataSourceType,
|
EnumDataSourceType,
|
||||||
EnumModelDataType,
|
EnumModelDataType,
|
||||||
@@ -275,7 +275,7 @@ const ModelFieldForm: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ([EnumDataSourceType.TIME, EnumDataSourceType.PARTITION_TIME].includes(type)) {
|
if ([EnumDataSourceType.TIME, EnumDataSourceType.PARTITION_TIME].includes(type)) {
|
||||||
const { dateFormat, timeGranularity } = record;
|
const { dateFormat } = record;
|
||||||
const dateFormatterOptions =
|
const dateFormatterOptions =
|
||||||
type === EnumDataSourceType.PARTITION_TIME ? PARTITION_TIME_FORMATTER : DATE_FORMATTER;
|
type === EnumDataSourceType.PARTITION_TIME ? PARTITION_TIME_FORMATTER : DATE_FORMATTER;
|
||||||
|
|
||||||
@@ -302,25 +302,25 @@ const ModelFieldForm: React.FC<Props> = ({
|
|||||||
<ExclamationCircleOutlined />
|
<ExclamationCircleOutlined />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Space>
|
</Space>
|
||||||
<Space>
|
{/*<Space>*/}
|
||||||
<span>时间粒度:</span>
|
{/* <span>时间粒度:</span>*/}
|
||||||
<Select
|
{/* <Select*/}
|
||||||
placeholder="时间粒度"
|
{/* placeholder="时间粒度"*/}
|
||||||
value={timeGranularity === '' ? undefined : timeGranularity}
|
{/* value={timeGranularity === '' ? undefined : timeGranularity}*/}
|
||||||
onChange={(value) => {
|
{/* onChange={(value) => {*/}
|
||||||
handleFieldChange(record, 'timeGranularity', value);
|
{/* handleFieldChange(record, 'timeGranularity', value);*/}
|
||||||
}}
|
{/* }}*/}
|
||||||
defaultValue={timeGranularity === '' ? undefined : DATE_OPTIONS[0]}
|
{/* defaultValue={timeGranularity === '' ? undefined : DATE_OPTIONS[0]}*/}
|
||||||
style={{ minWidth: 180 }}
|
{/* style={{ minWidth: 180 }}*/}
|
||||||
allowClear
|
{/* allowClear*/}
|
||||||
>
|
{/* >*/}
|
||||||
{DATE_OPTIONS.map((item) => (
|
{/* {DATE_OPTIONS.map((item) => (*/}
|
||||||
<Option key={item} value={item}>
|
{/* <Option key={item} value={item}>*/}
|
||||||
{item}
|
{/* {item}*/}
|
||||||
</Option>
|
{/* </Option>*/}
|
||||||
))}
|
{/* ))}*/}
|
||||||
</Select>
|
{/* </Select>*/}
|
||||||
</Space>
|
{/*</Space>*/}
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user