mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
(feature)(headless) Add a new headless-api module and Change old headless-api module to headless-common (#582)
* (improvement)(headless) Add headless-api module * (improvement)(headless) Change old headless-api module to headless-common --------- Co-authored-by: jolunoluo <jolunoluo@tencent.com>
This commit is contained in:
@@ -1,69 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>headless</artifactId>
|
||||
<version>${revision}</version>
|
||||
<version>0.8.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>headless-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>ru.yandex.clickhouse</groupId>-->
|
||||
<!-- <artifactId>clickhouse-jdbc</artifactId>-->
|
||||
<!-- <version>${clickhouse.jdbc.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.clickhouse</groupId>
|
||||
<artifactId>clickhouse-jdbc</artifactId>
|
||||
<version>${clickhouse.jdbc.version}</version>
|
||||
<!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
|
||||
<classifier>all</classifier>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>auth-api</artifactId>
|
||||
<artifactId>headless-query</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.api.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApiHeaderCheck {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.tencent.supersonic.headless.api.aspect;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Pair;
|
||||
import com.tencent.supersonic.common.pojo.exception.InvalidArgumentException;
|
||||
import com.tencent.supersonic.common.util.SignatureUtils;
|
||||
import com.tencent.supersonic.headless.api.service.AppService;
|
||||
import com.tencent.supersonic.headless.common.model.enums.AppStatusEnum;
|
||||
import com.tencent.supersonic.headless.common.model.response.AppDetailResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Component
|
||||
@Aspect
|
||||
@Order(1)
|
||||
@Slf4j
|
||||
public class ApiHeaderCheckAspect {
|
||||
|
||||
public static final String APPID = "appId";
|
||||
|
||||
private static final String TIMESTAMP = "timestamp";
|
||||
|
||||
private static final String SIGNATURE = "signature";
|
||||
|
||||
@Autowired
|
||||
private AppService appService;
|
||||
|
||||
@Pointcut("@annotation(com.tencent.supersonic.headless.api.annotation.ApiHeaderCheck)")
|
||||
private void apiPermissionCheck() {
|
||||
}
|
||||
|
||||
@Around("apiPermissionCheck()")
|
||||
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
Object[] objects = joinPoint.getArgs();
|
||||
HttpServletRequest request = (HttpServletRequest) objects[1];
|
||||
checkHeader(request);
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
private void checkHeader(HttpServletRequest request) {
|
||||
String timestampStr = request.getHeader(TIMESTAMP);
|
||||
String signature = request.getHeader(SIGNATURE);
|
||||
String appId = request.getHeader(APPID);
|
||||
if (StringUtils.isBlank(timestampStr)) {
|
||||
throw new InvalidArgumentException("header中timestamp不可为空");
|
||||
}
|
||||
if (StringUtils.isBlank(signature)) {
|
||||
throw new InvalidArgumentException("header中signature不可为空");
|
||||
}
|
||||
if (StringUtils.isBlank(appId)) {
|
||||
throw new InvalidArgumentException("header中appId不可为空");
|
||||
}
|
||||
AppDetailResp appDetailResp = appService.getApp(Integer.parseInt(appId));
|
||||
if (appDetailResp == null) {
|
||||
throw new InvalidArgumentException("该appId对应的应用不存在");
|
||||
}
|
||||
if (!AppStatusEnum.ONLINE.equals(appDetailResp.getAppStatus())) {
|
||||
throw new InvalidArgumentException("该应用暂时为非在线状态");
|
||||
}
|
||||
Pair<Boolean, String> checkResult = SignatureUtils.isValidSignature(appId, appDetailResp.getAppSecret(),
|
||||
Long.parseLong(timestampStr), signature);
|
||||
if (!checkResult.first) {
|
||||
throw new InvalidArgumentException(checkResult.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.enums;
|
||||
|
||||
public enum ElementFrequencyEnum {
|
||||
|
||||
UNKNOWN,
|
||||
HIGH,
|
||||
LOW
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.enums;
|
||||
|
||||
public enum ElementTypeEnum {
|
||||
|
||||
VARCHAR,
|
||||
DOUBLE,
|
||||
BIGINT,
|
||||
INT,
|
||||
DATE,
|
||||
ARRAY
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.enums;
|
||||
|
||||
|
||||
public enum UpdateCycleEnum {
|
||||
DAY,
|
||||
WEEK,
|
||||
MONTH
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class MaterializationConfFilter extends MaterializationFilter {
|
||||
|
||||
private Long id;
|
||||
private Boolean containElements = false;
|
||||
|
||||
private TypeEnums type;
|
||||
private Long materializationId;
|
||||
private Long elementId;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class MaterializationDateFilter {
|
||||
|
||||
private Long modelId;
|
||||
private List<String> dimensions;
|
||||
private List<String> metrics;
|
||||
private Date createdAt;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MaterializationFilter {
|
||||
|
||||
private Long materializationId;
|
||||
private String name;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private Long modelId;
|
||||
private Long databaseId;
|
||||
private Integer level;
|
||||
private String createdBy;
|
||||
private String destinationTable;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class MaterializationRecordFilter {
|
||||
|
||||
private Long id;
|
||||
private Long materializationId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private List<TaskStatusEnum> taskStatus;
|
||||
private String taskId;
|
||||
private String createdBy;
|
||||
private Date createdAt;
|
||||
private String startDataTime;
|
||||
private String endDataTime;
|
||||
private List<Long> materializationIds;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementTypeEnum;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class MaterializationElementReq extends RecordInfo {
|
||||
private Long id;
|
||||
private TypeEnums type;
|
||||
private Long materializationId;
|
||||
private String depends;
|
||||
private ElementTypeEnum elementType;
|
||||
private String defaultValue;
|
||||
private String outlier;
|
||||
private ElementFrequencyEnum frequency;
|
||||
private String description;
|
||||
private StatusEnum status;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationRecordReq extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
private Long materializationId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private String dataTime;
|
||||
private TaskStatusEnum taskStatus;
|
||||
private String taskId;
|
||||
private Long retryCount;
|
||||
private Long sourceCount;
|
||||
private Long sinkCount;
|
||||
private String message;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterializationReq extends RecordInfo {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private Long modelId;
|
||||
private Long databaseId;
|
||||
private Integer level;
|
||||
private String destinationTable;
|
||||
private String dateInfo;
|
||||
private String entities;
|
||||
private List<String> principals;
|
||||
private String description;
|
||||
private StatusEnum status;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationSourceReq {
|
||||
|
||||
private Long materializationId = 0L;
|
||||
private Long dataSourceId = 0L;
|
||||
private String dataTime;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterializationDateResp {
|
||||
|
||||
private Long modelId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private String dateFormat;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private List<String> unavailableDateList = new ArrayList<>();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class MaterializationElementModelResp {
|
||||
private Long id;
|
||||
private TypeEnums type;
|
||||
private String bizName;
|
||||
private String expr;
|
||||
private List<Measure> measures = Lists.newArrayList();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationElementResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
private TypeEnums type;
|
||||
private Long materializationId;
|
||||
private String depends;
|
||||
private ElementTypeEnum elementType;
|
||||
private String defaultValue;
|
||||
private String outlier;
|
||||
private ElementFrequencyEnum frequency;
|
||||
private String description;
|
||||
private String bizName;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationRecordResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
private Long materializationId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private String dataTime;
|
||||
private TaskStatusEnum taskStatus;
|
||||
private String taskId;
|
||||
private Integer retryCount;
|
||||
private Long sourceCount;
|
||||
private Long sinkCount;
|
||||
private String message;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterializationResp extends RecordInfo {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private Long modelId;
|
||||
private Long databaseId;
|
||||
private Integer level;
|
||||
private String destinationTable;
|
||||
private String dateInfo;
|
||||
private String entities;
|
||||
private List<String> principals;
|
||||
private String description;
|
||||
private List<MaterializationElementResp> materializationElementRespList;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.model.response.DatabaseResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class MaterializationSourceResp {
|
||||
|
||||
private Long materializationId;
|
||||
private Long dataSourceId;
|
||||
private Long modelId;
|
||||
private String sql;
|
||||
private List<String> fields;
|
||||
private String sourceDb;
|
||||
private String sourceTable;
|
||||
|
||||
private String dateInfo;
|
||||
private String entities;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private DatabaseResp databaseResp;
|
||||
private String depends;
|
||||
private Map<Long, String> dimensions;
|
||||
private Map<Long, String> metrics;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum AppStatusEnum {
|
||||
|
||||
INIT(0),
|
||||
ONLINE(1),
|
||||
OFFLINE(2),
|
||||
DELETED(3),
|
||||
UNKNOWN(4);
|
||||
|
||||
private Integer code;
|
||||
|
||||
AppStatusEnum(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static AppStatusEnum fromCode(Integer code) {
|
||||
for (AppStatusEnum appStatusEnum : AppStatusEnum.values()) {
|
||||
if (appStatusEnum.getCode().equals(code)) {
|
||||
return appStatusEnum;
|
||||
}
|
||||
}
|
||||
return AppStatusEnum.UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public enum DataTypeEnum {
|
||||
|
||||
MYSQL("mysql", "mysql", "com.mysql.cj.jdbc.Driver", "`", "`", "'", "'"),
|
||||
|
||||
HIVE2("hive2", "hive", "org.apache.hive.jdbc.HiveDriver", "`", "`", "`", "`"),
|
||||
|
||||
ORACLE("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
SQLSERVER("sqlserver", "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
H2("h2", "h2", "org.h2.Driver", "`", "`", "\"", "\""),
|
||||
|
||||
PHOENIX("phoenix", "hbase phoenix", "org.apache.phoenix.jdbc.PhoenixDriver", "", "", "\"", "\""),
|
||||
|
||||
MONGODB("mongo", "mongodb", "mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),
|
||||
|
||||
ELASTICSEARCH("elasticsearch", "elasticsearch", "com.amazon.opendistroforelasticsearch.jdbc.Driver", "", "", "'",
|
||||
"'"),
|
||||
|
||||
PRESTO("presto", "presto", "com.facebook.presto.jdbc.PrestoDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
MOONBOX("moonbox", "moonbox", "moonbox.jdbc.MbDriver", "`", "`", "`", "`"),
|
||||
|
||||
CASSANDRA("cassandra", "cassandra", "com.github.adejanovski.cassandra.jdbc.CassandraDriver", "", "", "'", "'"),
|
||||
|
||||
CLICKHOUSE("clickhouse", "clickhouse", "ru.yandex.clickhouse.ClickHouseDriver", "", "", "\"", "\""),
|
||||
|
||||
KYLIN("kylin", "kylin", "org.apache.kylin.jdbc.Driver", "\"", "\"", "\"", "\""),
|
||||
|
||||
VERTICA("vertica", "vertica", "com.vertica.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
HANA("sap", "sap hana", "com.sap.db.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
IMPALA("impala", "impala", "com.cloudera.impala.jdbc41.Driver", "", "", "'", "'"),
|
||||
|
||||
TDENGINE("TAOS", "TAOS", "com.taosdata.jdbc.TSDBDriver", "'", "'", "\"", "\"");
|
||||
|
||||
private String feature;
|
||||
private String desc;
|
||||
private String driver;
|
||||
private String keywordPrefix;
|
||||
private String keywordSuffix;
|
||||
private String aliasPrefix;
|
||||
private String aliasSuffix;
|
||||
|
||||
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix,
|
||||
String aliasPrefix, String aliasSuffix) {
|
||||
this.feature = feature;
|
||||
this.desc = desc;
|
||||
this.driver = driver;
|
||||
this.keywordPrefix = keywordPrefix;
|
||||
this.keywordSuffix = keywordSuffix;
|
||||
this.aliasPrefix = aliasPrefix;
|
||||
this.aliasSuffix = aliasSuffix;
|
||||
}
|
||||
|
||||
public static DataTypeEnum urlOf(String jdbcUrl) throws RuntimeException {
|
||||
String url = jdbcUrl.toLowerCase().trim();
|
||||
for (DataTypeEnum dataTypeEnum : values()) {
|
||||
if (url.startsWith(String.format(Constants.JDBC_PREFIX_FORMATTER, dataTypeEnum.feature))) {
|
||||
return dataTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<String> getAllSupportedDatasourceNameSet() {
|
||||
Set<String> datasourceSet = new HashSet<>();
|
||||
for (DataTypeEnum datasource : values()) {
|
||||
datasourceSet.add(datasource.getFeature());
|
||||
}
|
||||
return datasourceSet;
|
||||
}
|
||||
|
||||
public String getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public String getKeywordPrefix() {
|
||||
return keywordPrefix;
|
||||
}
|
||||
|
||||
public String getKeywordSuffix() {
|
||||
return keywordSuffix;
|
||||
}
|
||||
|
||||
public String getAliasPrefix() {
|
||||
return aliasPrefix;
|
||||
}
|
||||
|
||||
public String getAliasSuffix() {
|
||||
return aliasSuffix;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum DimensionTypeEnum {
|
||||
|
||||
categorical,
|
||||
time
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum IdentifyTypeEnum {
|
||||
|
||||
primary,
|
||||
|
||||
foreign,
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum MetricTypeEnum {
|
||||
|
||||
ATOMIC,
|
||||
DERIVED
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public enum ModelSourceTypeEnum {
|
||||
FULL,
|
||||
PARTITION,
|
||||
ZIPPER;
|
||||
|
||||
public static ModelSourceTypeEnum of(String src) {
|
||||
for (ModelSourceTypeEnum modelSourceTypeEnum : ModelSourceTypeEnum.values()) {
|
||||
if (Objects.nonNull(src) && src.equalsIgnoreCase(modelSourceTypeEnum.name())) {
|
||||
return modelSourceTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isZipper(ModelSourceTypeEnum modelSourceTypeEnum) {
|
||||
return Objects.nonNull(modelSourceTypeEnum) && ZIPPER.equals(modelSourceTypeEnum);
|
||||
}
|
||||
|
||||
public static boolean isZipper(String str) {
|
||||
ModelSourceTypeEnum modelSourceTypeEnum = of(str);
|
||||
return Objects.nonNull(modelSourceTypeEnum) && isZipper(modelSourceTypeEnum);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum OperatorEnum {
|
||||
|
||||
MAX("MAX"),
|
||||
|
||||
MIN("MIN"),
|
||||
|
||||
AVG("AVG"),
|
||||
|
||||
SUM("SUM"),
|
||||
|
||||
DISTINCT("DISTINCT"),
|
||||
|
||||
TOPN("TOPN"),
|
||||
|
||||
PERCENTILE("PERCENTILE"),
|
||||
|
||||
UNKNOWN("UNKNOWN");
|
||||
|
||||
|
||||
private String operator;
|
||||
|
||||
OperatorEnum(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum QueryOptMode {
|
||||
|
||||
NONE,
|
||||
|
||||
MATERIALIZATION
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum QueryTypeBackEnum {
|
||||
NORMAL("NORMAL", 0),
|
||||
|
||||
PRE_FLUSH("PRE_FLUSH", 1);
|
||||
|
||||
private String value;
|
||||
private Integer state;
|
||||
|
||||
QueryTypeBackEnum(String value, Integer state) {
|
||||
this.value = value;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static QueryTypeBackEnum of(String src) {
|
||||
for (QueryTypeBackEnum operatorEnum : QueryTypeBackEnum.values()) {
|
||||
if (src.toUpperCase().contains(operatorEnum.value)) {
|
||||
return operatorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum QueryTypeEnum {
|
||||
SQL("SQL"),
|
||||
|
||||
STRUCT("STRUCT");
|
||||
|
||||
private String value;
|
||||
|
||||
QueryTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static QueryTypeEnum of(String src) {
|
||||
for (QueryTypeEnum operatorEnum : QueryTypeEnum.values()) {
|
||||
if (src.toUpperCase().contains(operatorEnum.value)) {
|
||||
return operatorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum SemanticTypeEnum {
|
||||
|
||||
CATEGORY,
|
||||
ID,
|
||||
DATE,
|
||||
NUMBER
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppConfig {
|
||||
|
||||
private List<Item> items = Lists.newArrayList();
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DatasourceType {
|
||||
|
||||
private String name;
|
||||
private String prefix;
|
||||
private List<String> versions;
|
||||
|
||||
public DatasourceType(String name, List<String> versions) {
|
||||
this.name = name;
|
||||
this.prefix = String.format(Constants.JDBC_PREFIX_FORMATTER, name);
|
||||
this.versions = versions;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Dim {
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String dateFormat = Constants.DAY_FORMAT;
|
||||
|
||||
private DimensionTimeTypeParams typeParams;
|
||||
|
||||
private Integer isCreateDimension = 0;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private String description;
|
||||
|
||||
private int isTag;
|
||||
|
||||
public Dim(String name, String bizName, String type, Integer isCreateDimension) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
public Dim(String name, String bizName, String type, Integer isCreateDimension, int isTag) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
this.isTag = isTag;
|
||||
}
|
||||
|
||||
public Dim(String name, String type, String expr, String dateFormat, DimensionTimeTypeParams typeParams,
|
||||
Integer isCreateDimension, String bizName) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.expr = expr;
|
||||
this.dateFormat = dateFormat;
|
||||
this.typeParams = typeParams;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
public static Dim getDefault() {
|
||||
return new Dim("日期", "time", "2023-05-28",
|
||||
Constants.DAY_FORMAT,
|
||||
new DimensionTimeTypeParams("true", "day"),
|
||||
0, "imp_date"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DimValueMap {
|
||||
|
||||
/**
|
||||
* dimension value in db
|
||||
*/
|
||||
private String techName;
|
||||
|
||||
/**
|
||||
* dimension value for result show
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
/**
|
||||
* dimension value for user query
|
||||
*/
|
||||
private List<String> alias = new ArrayList<>();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DimensionTimeTypeParams {
|
||||
|
||||
private String isPrimary = "true";
|
||||
|
||||
private String timeGranularity = "day";
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DrillDownDimension {
|
||||
|
||||
private Long dimensionId;
|
||||
|
||||
private boolean necessary;
|
||||
|
||||
public DrillDownDimension(Long dimensionId) {
|
||||
this.dimensionId = dimensionId;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Entity {
|
||||
|
||||
|
||||
/**
|
||||
* uniquely identifies an entity
|
||||
*/
|
||||
private Long entityId;
|
||||
|
||||
/**
|
||||
* entity name list
|
||||
*/
|
||||
private List<String> names;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Identify {
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* primary, foreign
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private List<String> entityNames;
|
||||
|
||||
public Identify(String name, String type, String bizName) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.ApiItemType;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Item {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
private ApiItemType type;
|
||||
|
||||
private List<Item> relateItems = Lists.newArrayList();
|
||||
|
||||
public String getValue() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class ItemDateFilter {
|
||||
|
||||
private List<Long> itemIds;
|
||||
@NonNull
|
||||
private String type;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Measure {
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
private String agg;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String constraint;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String createMetric;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private Integer isCreateMetric = 0;
|
||||
|
||||
public Measure(String name, String bizName, String agg, Integer isCreateMetric) {
|
||||
this.name = name;
|
||||
this.agg = agg;
|
||||
this.isCreateMetric = isCreateMetric;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricQueryDefaultConfig extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long metricId;
|
||||
|
||||
private String userName;
|
||||
|
||||
//string of queryStruct
|
||||
private String defaultConfig;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricTypeParams {
|
||||
|
||||
private List<Measure> measures = Lists.newArrayList();
|
||||
|
||||
private String expr;
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.enums.DimensionTypeEnum;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Data
|
||||
public class ModelDetail {
|
||||
|
||||
private String queryType;
|
||||
|
||||
private String sqlQuery;
|
||||
|
||||
private String tableQuery;
|
||||
|
||||
private List<Identify> identifiers;
|
||||
|
||||
private List<Dim> dimensions;
|
||||
|
||||
private List<Measure> measures;
|
||||
|
||||
public String getSqlQuery() {
|
||||
if (StringUtils.isNotBlank(sqlQuery) && sqlQuery.endsWith(";")) {
|
||||
sqlQuery = sqlQuery.substring(0, sqlQuery.length() - 1);
|
||||
}
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
public List<Dim> getTimeDims() {
|
||||
if (CollectionUtils.isEmpty(dimensions)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return dimensions.stream()
|
||||
.filter(dim -> DimensionTypeEnum.time.name().equalsIgnoreCase(dim.getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryResult<T> implements Serializable {
|
||||
|
||||
private int pageNo = -1;
|
||||
private int pageSize = -1;
|
||||
private long totalCount = -1;
|
||||
private List<T> resultList = new ArrayList<T>();
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryStat {
|
||||
|
||||
private Long id;
|
||||
private String traceId;
|
||||
private Long modelId;
|
||||
private String user;
|
||||
private String createdAt;
|
||||
/**
|
||||
* corresponding type, such as sql, struct, etc
|
||||
*/
|
||||
private String queryType;
|
||||
/**
|
||||
* NORMAL, PRE_FLUSH
|
||||
*/
|
||||
private Integer queryTypeBack;
|
||||
private String querySqlCmd;
|
||||
private String querySqlCmdMd5;
|
||||
private String queryStructCmd;
|
||||
private String queryStructCmdMd5;
|
||||
private String sql;
|
||||
private String sqlMd5;
|
||||
private String queryEngine;
|
||||
private Long startTime;
|
||||
private Long elapsedMs;
|
||||
private String queryState;
|
||||
private Boolean nativeQuery;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String dimensions;
|
||||
private String metrics;
|
||||
private String selectCols;
|
||||
private String aggCols;
|
||||
private String filterCols;
|
||||
private String groupByCols;
|
||||
private String orderByCols;
|
||||
private Boolean useResultCache;
|
||||
private Boolean useSqlCache;
|
||||
private String sqlCacheKey;
|
||||
private String resultCacheKey;
|
||||
private String queryOptMode;
|
||||
|
||||
public QueryStat setQueryOptMode(String queryOptMode) {
|
||||
this.queryOptMode = queryOptMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQuerySqlCmdMd5(String querySqlCmdMd5) {
|
||||
this.querySqlCmdMd5 = querySqlCmdMd5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryStructCmdMd5(String queryStructCmdMd5) {
|
||||
this.queryStructCmdMd5 = queryStructCmdMd5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryTypeBack(Integer queryTypeBack) {
|
||||
this.queryTypeBack = queryTypeBack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setNativeQuery(Boolean nativeQuery) {
|
||||
this.nativeQuery = nativeQuery;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setTraceId(String traceId) {
|
||||
this.traceId = traceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setModelId(Long modelId) {
|
||||
this.modelId = modelId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setUser(String user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryType(String queryType) {
|
||||
this.queryType = queryType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQuerySqlCmd(String querySqlCmd) {
|
||||
this.querySqlCmd = querySqlCmd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryStructCmd(String queryStructCmd) {
|
||||
this.queryStructCmd = queryStructCmd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSql(String sql) {
|
||||
this.sql = sql;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSqlMd5(String sqlMd5) {
|
||||
this.sqlMd5 = sqlMd5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryEngine(String queryEngine) {
|
||||
this.queryEngine = queryEngine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setElapsedMs(Long elapsedMs) {
|
||||
this.elapsedMs = elapsedMs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryState(String queryState) {
|
||||
this.queryState = queryState;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setDimensions(String dimensions) {
|
||||
this.dimensions = dimensions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setMetrics(String metrics) {
|
||||
this.metrics = metrics;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSelectCols(String selectCols) {
|
||||
this.selectCols = selectCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setAggCols(String aggCols) {
|
||||
this.aggCols = aggCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setFilterCols(String filterCols) {
|
||||
this.filterCols = filterCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setGroupByCols(String groupByCols) {
|
||||
this.groupByCols = groupByCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setOrderByCols(String orderByCols) {
|
||||
this.orderByCols = orderByCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setUseResultCache(Boolean useResultCache) {
|
||||
this.useResultCache = useResultCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setUseSqlCache(Boolean useSqlCache) {
|
||||
this.useSqlCache = useSqlCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSqlCacheKey(String sqlCacheKey) {
|
||||
this.sqlCacheKey = sqlCacheKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setResultCacheKey(String resultCacheKey) {
|
||||
this.resultCacheKey = resultCacheKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setCreatedAt(String createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getMetricListBizName() {
|
||||
if (Objects.isNull(metrics)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return JSONObject.parseArray(metrics, String.class);
|
||||
}
|
||||
|
||||
public List<String> getDimensionListBizName() {
|
||||
return JSONObject.parseArray(dimensions, String.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class RelateDimension {
|
||||
|
||||
List<DrillDownDimension> drillDownDimensions = Lists.newArrayList();
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.SensitiveLevelEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class SchemaItem extends RecordInfo {
|
||||
|
||||
private static String aliasSplit = ",";
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private TypeEnums typeEnum;
|
||||
|
||||
private Integer sensitiveLevel = SensitiveLevelEnum.LOW.getCode();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
SchemaItem that = (SchemaItem) o;
|
||||
return Objects.equal(id, that.id) && Objects.equal(name, that.name)
|
||||
&& Objects.equal(bizName, that.bizName) && Objects.equal(
|
||||
description, that.description) && Objects.equal(status, that.status)
|
||||
&& typeEnum == that.typeEnum && Objects.equal(sensitiveLevel, that.sensitiveLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), id, name, bizName, description, status, typeEnum, sensitiveLevel);
|
||||
}
|
||||
|
||||
public static List<String> getAliasList(String alias) {
|
||||
if (StringUtils.isEmpty(alias)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return Arrays.asList(alias.split(aliasSplit));
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.PageBaseReq;
|
||||
import com.tencent.supersonic.headless.api.model.enums.AppStatusEnum;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class AppQueryReq extends PageBaseReq {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<AppStatusEnum> appStatus;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
public List<Integer> getStatus() {
|
||||
if (CollectionUtils.isEmpty(appStatus)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return appStatus.stream().map(AppStatusEnum::getCode).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.AppConfig;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppReq extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private AppConfig config;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
private Integer qps;
|
||||
|
||||
private List<String> owners;
|
||||
|
||||
public String getOwner() {
|
||||
if (CollectionUtils.isEmpty(owners)) {
|
||||
return "";
|
||||
}
|
||||
return String.join(",", owners);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.enums.DataTypeEnum;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class DatabaseReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String host;
|
||||
|
||||
private String port;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String database;
|
||||
|
||||
private String version;
|
||||
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
|
||||
private List<String> admins = Lists.newArrayList();
|
||||
|
||||
private List<String> viewers = Lists.newArrayList();
|
||||
|
||||
public String getConnectUrl() {
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
return url;
|
||||
}
|
||||
String databaseUrl = database;
|
||||
if (StringUtils.isBlank(databaseUrl)) {
|
||||
databaseUrl = "";
|
||||
} else {
|
||||
databaseUrl = "/" + database;
|
||||
}
|
||||
if (type.equalsIgnoreCase(DataTypeEnum.MYSQL.getFeature())) {
|
||||
return String.format("jdbc:%s://%s:%s%s?sessionVariables=sql_mode='IGNORE_SPACE'&allowMultiQueries=true",
|
||||
type, host, port, databaseUrl);
|
||||
}
|
||||
return String.format("jdbc:%s://%s:%s%s", type, host, port, databaseUrl);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DateInfoReq {
|
||||
|
||||
private String type;
|
||||
private Long itemId;
|
||||
private String dateFormat;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String datePeriod;
|
||||
private List<String> unavailableDateList = new ArrayList<>();
|
||||
|
||||
public DateInfoReq(String type, Long itemId, String dateFormat, String startDate, String endDate) {
|
||||
this.type = type;
|
||||
this.itemId = itemId;
|
||||
this.dateFormat = dateFormat;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public DateInfoReq(String type, Long itemId, String dateFormat, String startDate, String endDate,
|
||||
List<String> unavailableDateList) {
|
||||
this.type = type;
|
||||
this.itemId = itemId;
|
||||
this.dateFormat = dateFormat;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.unavailableDateList = unavailableDateList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DimensionReq extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private String type;
|
||||
|
||||
@NotNull(message = "expr can not be null")
|
||||
private String expr;
|
||||
|
||||
//DATE ID CATEGORY
|
||||
private String semanticType = "CATEGORY";
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> defaultValues;
|
||||
|
||||
private List<DimValueMap> dimValueMaps;
|
||||
|
||||
private DataTypeEnums dataType;
|
||||
|
||||
private int isTag;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class DomainReq extends SchemaItem {
|
||||
|
||||
private Long parentId = 0L;
|
||||
|
||||
private Integer isOpen = 0;
|
||||
|
||||
private List<String> viewers = new ArrayList<>();
|
||||
|
||||
private List<String> viewOrgs = new ArrayList<>();
|
||||
|
||||
private List<String> admins = new ArrayList<>();
|
||||
|
||||
private List<String> adminOrgs = new ArrayList<>();
|
||||
|
||||
public String getViewer() {
|
||||
return String.join(",", viewers);
|
||||
}
|
||||
|
||||
public String getViewOrg() {
|
||||
return String.join(",", viewOrgs);
|
||||
}
|
||||
|
||||
public String getAdmin() {
|
||||
return String.join(",", admins);
|
||||
}
|
||||
|
||||
public String getAdminOrg() {
|
||||
return String.join(",", adminOrgs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DomainUpdateReq extends DomainReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MetaBatchReq {
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Data
|
||||
public class MetricBaseReq extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String dataFormatType;
|
||||
|
||||
private DataFormat dataFormat;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
private RelateDimension relateDimension;
|
||||
|
||||
private Map<String, Object> ext = new HashMap<>();
|
||||
|
||||
public String getTag() {
|
||||
if (CollectionUtils.isEmpty(tags)) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.join(tags, ",");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.MetricTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.MetricTypeParams;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MetricReq extends MetricBaseReq {
|
||||
|
||||
private MetricTypeEnum metricType;
|
||||
|
||||
private MetricTypeParams typeParams;
|
||||
|
||||
public MetricTypeEnum getMetricType() {
|
||||
if (metricType != null) {
|
||||
return metricType;
|
||||
}
|
||||
List<Measure> measureList = typeParams.getMeasures();
|
||||
if (measureList.size() == 1 && typeParams.getExpr().trim().equalsIgnoreCase(measureList.get(0).getBizName())) {
|
||||
return MetricTypeEnum.ATOMIC;
|
||||
} else if (measureList.size() >= 1) {
|
||||
return MetricTypeEnum.DERIVED;
|
||||
}
|
||||
throw new RuntimeException("measure can not be none");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class ModelReq extends SchemaItem {
|
||||
|
||||
private Long databaseId;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String filterSql;
|
||||
|
||||
private Integer isOpen;
|
||||
|
||||
private List<DrillDownDimension> drillDownDimensions;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private ModelDetail modelDetail;
|
||||
|
||||
private List<String> viewers;
|
||||
|
||||
private List<String> viewOrgs;
|
||||
|
||||
private List<String> admins;
|
||||
|
||||
private List<String> adminOrgs;
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return modelDetail.getTimeDims();
|
||||
}
|
||||
|
||||
public String getViewer() {
|
||||
if (viewers == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", viewers);
|
||||
}
|
||||
|
||||
public String getViewOrg() {
|
||||
if (viewOrgs == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", viewOrgs);
|
||||
}
|
||||
|
||||
public String getAdmin() {
|
||||
if (admins == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", admins);
|
||||
}
|
||||
|
||||
public String getAdminOrg() {
|
||||
if (adminOrgs == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", adminOrgs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelSchemaFilterReq {
|
||||
|
||||
/**
|
||||
* if domainIds is empty, get all domain info
|
||||
*/
|
||||
private List<Long> modelIds;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageDimensionReq extends PageSchemaItemReq {
|
||||
|
||||
private Integer isTag;
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageMetricReq extends PageSchemaItemReq {
|
||||
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.PageBaseReq;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PageSchemaItemReq extends PageBaseReq {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String bizName;
|
||||
private String createdBy;
|
||||
private List<Long> domainIds = Lists.newArrayList();
|
||||
private List<Long> modelIds = Lists.newArrayList();
|
||||
private Integer sensitiveLevel;
|
||||
private Integer status;
|
||||
private String key;
|
||||
private List<Long> ids;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
public class SqlExecuteReq {
|
||||
public static final String LIMIT_WRAPPER = " select * from ( %s ) a limit 1000 ";
|
||||
|
||||
@NotNull(message = "modelId can not be null")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "sql can not be blank")
|
||||
private String sql;
|
||||
|
||||
public String getSql() {
|
||||
if (StringUtils.isNotBlank(sql) && sql.endsWith(";")) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
return String.format(LIMIT_WRAPPER, sql);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ViewInfoReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String type;
|
||||
|
||||
private Date createdAt;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
private String updatedBy;
|
||||
|
||||
private String config;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppDetailResp extends AppResp {
|
||||
|
||||
private String appSecret;
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.api.model.enums.AppStatusEnum;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.AppConfig;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private AppStatusEnum appStatus;
|
||||
|
||||
private AppConfig config;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
private Integer qps;
|
||||
|
||||
private List<String> owners;
|
||||
|
||||
private boolean hasAdminRes;
|
||||
|
||||
public void setOwner(String owner) {
|
||||
if (StringUtils.isBlank(owner)) {
|
||||
owners = Lists.newArrayList();
|
||||
return;
|
||||
}
|
||||
owners = Arrays.asList(owner.split(","));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class DatabaseResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<String> admins = Lists.newArrayList();
|
||||
|
||||
private List<String> viewers = Lists.newArrayList();
|
||||
|
||||
private String type;
|
||||
|
||||
private String url;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String database;
|
||||
|
||||
private String version;
|
||||
|
||||
private boolean hasPermission = false;
|
||||
|
||||
private boolean hasUsePermission = false;
|
||||
|
||||
private boolean hasEditPermission = false;
|
||||
|
||||
public String getHost() {
|
||||
Pattern p = Pattern.compile("jdbc:(?<db>\\w+):.*((//)|@)(?<host>.+):(?<port>\\d+).*");
|
||||
Matcher m = p.matcher(url);
|
||||
if (m.find()) {
|
||||
return m.group("host");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
Pattern p = Pattern.compile("jdbc:(?<db>\\w+):.*((//)|@)(?<host>.+):(?<port>\\d+).*");
|
||||
Matcher m = p.matcher(url);
|
||||
if (m.find()) {
|
||||
return m.group("port");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DimSchemaResp extends DimensionResp {
|
||||
|
||||
private Long useCnt = 0L;
|
||||
|
||||
private List<String> entityAlias;
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DimensionResp extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private String type;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String fullPath;
|
||||
|
||||
private String modelName;
|
||||
|
||||
private String modelBizName;
|
||||
|
||||
private String modelFilterSql;
|
||||
//DATE ID CATEGORY
|
||||
private String semanticType;
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> defaultValues;
|
||||
|
||||
private List<DimValueMap> dimValueMaps;
|
||||
|
||||
private DataTypeEnums dataType;
|
||||
|
||||
private int isTag;
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Entity;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class DomainResp extends SchemaItem {
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String fullPath;
|
||||
|
||||
private List<String> viewers;
|
||||
|
||||
private List<String> viewOrgs;
|
||||
|
||||
private List<String> admins;
|
||||
|
||||
private List<String> adminOrgs;
|
||||
|
||||
private Integer isOpen = 0;
|
||||
|
||||
private Integer dimensionCnt;
|
||||
|
||||
private Integer metricCnt;
|
||||
|
||||
private Entity entity;
|
||||
|
||||
private boolean hasEditPermission = false;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DomainResp that = (DomainResp) o;
|
||||
if (getId() == null || that.getId() == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(getId().intValue(), that.getId().intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (getId() == null) {
|
||||
return 0;
|
||||
}
|
||||
return getId().hashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExplainResp implements Serializable {
|
||||
|
||||
private String sql;
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class MeasureResp {
|
||||
|
||||
private String name;
|
||||
|
||||
//sum max min avg count distinct
|
||||
private String agg;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String constraint;
|
||||
|
||||
private String alias;
|
||||
|
||||
private Long datasourceId;
|
||||
|
||||
private String datasourceName;
|
||||
|
||||
private String datasourceBizName;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private Long modelId;
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class MetricResp extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String modelName;
|
||||
|
||||
//ATOMIC DERIVED
|
||||
private String type;
|
||||
|
||||
private MetricTypeParams typeParams;
|
||||
|
||||
private String dataFormatType;
|
||||
|
||||
private DataFormat dataFormat;
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
private RelateDimension relateDimension;
|
||||
|
||||
private boolean hasAdminRes = false;
|
||||
|
||||
private Boolean isCollect;
|
||||
|
||||
private Map<String, Object> ext = new HashMap<>();
|
||||
|
||||
public void setTag(String tag) {
|
||||
if (StringUtils.isBlank(tag)) {
|
||||
tags = Lists.newArrayList();
|
||||
} else {
|
||||
tags = Arrays.asList(tag.split(","));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Long> getNecessaryDimensionIds() {
|
||||
if (relateDimension == null || CollectionUtils.isEmpty(relateDimension.getDrillDownDimensions())) {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
return relateDimension.getDrillDownDimensions().stream().filter(DrillDownDimension::isNecessary)
|
||||
.map(DrillDownDimension::getDimensionId).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public String getRelaDimensionIdKey() {
|
||||
if (relateDimension == null || CollectionUtils.isEmpty(relateDimension.getDrillDownDimensions())) {
|
||||
return "";
|
||||
}
|
||||
return relateDimension.getDrillDownDimensions().stream()
|
||||
.map(DrillDownDimension::getDimensionId)
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public List<Measure> getMeasures() {
|
||||
if (typeParams == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return typeParams.getMeasures();
|
||||
}
|
||||
|
||||
public String getDefaultAgg() {
|
||||
return typeParams.getMeasures().get(0).getAgg();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class MetricSchemaResp extends MetricResp {
|
||||
|
||||
private Long useCnt = 0L;
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Identify;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelResp extends SchemaItem {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private Long databaseId;
|
||||
|
||||
private ModelDetail modelDetail;
|
||||
|
||||
private String depends;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String filterSql;
|
||||
|
||||
private List<String> viewers = new ArrayList<>();
|
||||
|
||||
private List<String> viewOrgs = new ArrayList<>();
|
||||
|
||||
private List<String> admins = new ArrayList<>();
|
||||
|
||||
private List<String> adminOrgs = new ArrayList<>();
|
||||
|
||||
private Integer isOpen;
|
||||
|
||||
private List<DrillDownDimension> drillDownDimensions;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String fullPath;
|
||||
|
||||
public boolean openToAll() {
|
||||
return isOpen != null && isOpen == 1;
|
||||
}
|
||||
|
||||
public Identify getPrimaryIdentify() {
|
||||
if (modelDetail == null) {
|
||||
return null;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(modelDetail.getIdentifiers())) {
|
||||
return null;
|
||||
}
|
||||
for (Identify identify : modelDetail.getIdentifiers()) {
|
||||
if (!CollectionUtils.isEmpty(identify.getEntityNames())) {
|
||||
return identify;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return modelDetail.getTimeDims();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelSchemaRelaResp {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private ModelResp model;
|
||||
|
||||
private List<MetricResp> metrics;
|
||||
|
||||
private List<DimensionResp> dimensions;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.ModelRela;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Identify;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModelSchemaResp extends ModelResp {
|
||||
|
||||
private List<MetricSchemaResp> metrics;
|
||||
private List<DimSchemaResp> dimensions;
|
||||
private List<ModelRela> modelRelas;
|
||||
|
||||
public DimSchemaResp getPrimaryKey() {
|
||||
Identify identify = getPrimaryIdentify();
|
||||
if (identify == null) {
|
||||
return null;
|
||||
}
|
||||
for (DimSchemaResp dimension : dimensions) {
|
||||
if (identify.getBizName().equals(dimension.getBizName())) {
|
||||
dimension.setEntityAlias(identify.getEntityNames());
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.QueryAuthorization;
|
||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||
import com.tencent.supersonic.headless.api.model.enums.SemanticTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.QueryResult;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryResultWithSchemaResp extends QueryResult<Map<String, Object>> {
|
||||
|
||||
List<QueryColumn> columns = Lists.newArrayList();
|
||||
String sql;
|
||||
QueryAuthorization queryAuthorization;
|
||||
|
||||
public List<QueryColumn> getMetricColumns() {
|
||||
return columns.stream()
|
||||
.filter(queryColumn -> SemanticTypeEnum.NUMBER.name().equals(queryColumn.getShowType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<QueryColumn> getDimensionColumns() {
|
||||
return columns.stream()
|
||||
.filter(queryColumn -> !SemanticTypeEnum.NUMBER.name().equals(queryColumn.getShowType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SqlParserResp {
|
||||
|
||||
private String sql = "";
|
||||
private String sourceId = "";
|
||||
private String errMsg = "";
|
||||
private Boolean ok;
|
||||
|
||||
public boolean isOk() {
|
||||
this.ok = "".equals(errMsg) && !"".equals(sql);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public SqlParserResp error(String msg) {
|
||||
this.setErrMsg(msg);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DataModelYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private Long sourceId;
|
||||
|
||||
private String sqlQuery;
|
||||
|
||||
private String tableQuery;
|
||||
|
||||
private List<IdentifyYamlTpl> identifiers;
|
||||
|
||||
private List<DimensionYamlTpl> dimensions;
|
||||
|
||||
private List<MeasureYamlTpl> measures;
|
||||
|
||||
private ModelSourceTypeEnum modelSourceTypeEnum;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DimensionTimeTypeParamsTpl {
|
||||
|
||||
private String isPrimary;
|
||||
|
||||
private String timeGranularity;
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DimensionYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private String owners;
|
||||
|
||||
private String type;
|
||||
|
||||
private String expr;
|
||||
|
||||
private DimensionTimeTypeParamsTpl typeParams;
|
||||
|
||||
private DataTypeEnums dataType;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class IdentifyYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 主键 primary 外键 foreign
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MeasureYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private String agg;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String constraint;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String createMetric;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricTypeParamsYamlTpl {
|
||||
|
||||
private List<MeasureYamlTpl> measures;
|
||||
|
||||
private String expr;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class MetricYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> owners;
|
||||
|
||||
private String type;
|
||||
|
||||
private MetricTypeParamsYamlTpl typeParams;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.tencent.supersonic.headless.api.persistence.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("s2_app")
|
||||
public class AppDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private String config;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
private Integer qps;
|
||||
|
||||
private String owner;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String appSecret;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
private String updatedBy;
|
||||
|
||||
private Date createdAt;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.supersonic.headless.api.persistence.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tencent.supersonic.headless.api.persistence.dataobject.AppDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AppMapper extends BaseMapper<AppDO> {
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.enums;
|
||||
|
||||
public enum AggOption {
|
||||
NATIVE,
|
||||
AGGREGATION,
|
||||
DEFAULT;
|
||||
|
||||
public static AggOption getAggregation(boolean isNativeQuery) {
|
||||
return isNativeQuery ? NATIVE : AGGREGATION;
|
||||
}
|
||||
|
||||
public static boolean isAgg(AggOption aggOption) {
|
||||
return NATIVE.equals(aggOption) ? false : true;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Item;
|
||||
import com.tencent.supersonic.headless.api.model.response.QueryResultWithSchemaResp;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiQuerySingleResult {
|
||||
|
||||
private Item item;
|
||||
|
||||
private QueryResultWithSchemaResp result;
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Cache {
|
||||
|
||||
private Boolean cache = true;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"cache\":")
|
||||
.append(cache);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class DataDownload {
|
||||
|
||||
List<List<String>> headers;
|
||||
|
||||
List<List<String>> data;
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Materialization {
|
||||
|
||||
private String name;
|
||||
private String destination;
|
||||
private String destinationType;
|
||||
private List<String> depends;
|
||||
private List<String> metrics;
|
||||
private List<String> dimensions;
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import com.tencent.supersonic.headless.api.query.enums.AggOption;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricTable {
|
||||
|
||||
private String alias;
|
||||
private List<String> metrics;
|
||||
private List<String> dimensions;
|
||||
private String where;
|
||||
private AggOption aggOption = AggOption.DEFAULT;
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Param {
|
||||
|
||||
@NotBlank(message = "Invald parameter name")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "Invalid parameter value")
|
||||
private String value;
|
||||
|
||||
public Param() {
|
||||
}
|
||||
|
||||
public Param(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"name\":\"")
|
||||
.append(name).append('\"');
|
||||
sb.append(",\"value\":\"")
|
||||
.append(value).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BatchDownloadReq {
|
||||
|
||||
private List<Long> metricIds;
|
||||
|
||||
private DateConf dateInfo;
|
||||
|
||||
private boolean isTransform = true;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DownloadStructReq extends QueryStructReq {
|
||||
|
||||
private boolean isTransform;
|
||||
|
||||
public void setIsTransform(boolean isTransform) {
|
||||
this.isTransform = isTransform;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.QueryTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExplainSqlReq<T> {
|
||||
|
||||
private QueryTypeEnum queryTypeEnum;
|
||||
|
||||
private T queryReq;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user