mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
(improvement)(headless) Add API interface to provide data services to other applications (#561)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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 ApiItemType type;
|
||||
|
||||
private List<Item> relateItems = Lists.newArrayList();
|
||||
|
||||
public String getValue() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppDetailResp extends AppResp {
|
||||
|
||||
private String appSecret;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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,6 +1,5 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
@@ -44,10 +43,6 @@ public class ModelResp extends SchemaItem {
|
||||
|
||||
private String fullPath;
|
||||
|
||||
private Integer dimensionCnt;
|
||||
|
||||
private Integer metricCnt;
|
||||
|
||||
public boolean openToAll() {
|
||||
return isOpen != null && isOpen == 1;
|
||||
}
|
||||
@@ -74,24 +69,4 @@ public class ModelResp extends SchemaItem {
|
||||
return modelDetail.getTimeDims();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
ModelResp that = (ModelResp) o;
|
||||
return Objects.equal(getId(), that.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Item;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryApiPreviewReq {
|
||||
|
||||
private Item item;
|
||||
|
||||
private DateConf dateConf = new DateConf();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.ApiItemType;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QueryApiReq {
|
||||
|
||||
@NotEmpty(message = "ids不可为空")
|
||||
private List<Long> ids;
|
||||
|
||||
private ApiItemType type = ApiItemType.METRIC;
|
||||
|
||||
private DateConf dateConf = new DateConf();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.tencent.supersonic.headless.api.query.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.query.pojo.ApiQuerySingleResult;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class ApiQueryResultResp {
|
||||
|
||||
private List<ApiQuerySingleResult> results;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user