mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(semantic) support adding tag for metric
This commit is contained in:
@@ -108,6 +108,7 @@ CREATE TABLE IF NOT EXISTS `s2_metric` (
|
||||
`data_format_type` varchar(50) DEFAULT NULL ,
|
||||
`data_format` varchar(500) DEFAULT NULL,
|
||||
`alias` varchar(500) DEFAULT NULL,
|
||||
`tags` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_metric IS 'metric information table';
|
||||
|
||||
@@ -190,6 +190,7 @@ CREATE TABLE IF NOT EXISTS `s2_metric` (
|
||||
`data_format_type` varchar(50) DEFAULT NULL ,
|
||||
`data_format` varchar(500) DEFAULT NULL,
|
||||
`alias` varchar(500) DEFAULT NULL,
|
||||
`tags` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_metric IS 'metric information table';
|
||||
|
||||
@@ -254,6 +254,7 @@ CREATE TABLE `s2_metric` (
|
||||
`data_format_type` varchar(50) DEFAULT NULL COMMENT '数值类型',
|
||||
`data_format` varchar(500) DEFAULT NULL COMMENT '数值类型参数',
|
||||
`alias` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`tags` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='指标表';
|
||||
|
||||
|
||||
@@ -48,5 +48,7 @@ alter table s2_database drop column domain_id;
|
||||
alter table s2_chat add column agent_id int after chat_id;
|
||||
|
||||
--20230907
|
||||
ALTER TABLE s2_model add alias varchar(200) default null after domain_id;
|
||||
|
||||
ALTER TABLE s2_model add alias varchar(200) default null after domain_id;
|
||||
--20230919
|
||||
alter table s2_metric add tags varchar(500) null;
|
||||
@@ -205,6 +205,7 @@ CREATE TABLE IF NOT EXISTS `s2_metric` (
|
||||
`data_format_type` varchar(50) DEFAULT NULL ,
|
||||
`data_format` varchar(500) DEFAULT NULL,
|
||||
`alias` varchar(500) DEFAULT NULL,
|
||||
`tags` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_metric IS 'metric information table';
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.tencent.supersonic.semantic.api.model.request;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@@ -17,4 +18,6 @@ public class MetricBaseReq extends SchemaItem {
|
||||
|
||||
private DataFormat dataFormat;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,4 @@ public class PageMetricReq extends PageSchemaItemReq {
|
||||
|
||||
private String type;
|
||||
|
||||
private String key;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,4 +16,5 @@ public class PageSchemaItemReq extends PageBaseReq {
|
||||
private List<Long> modelIds = Lists.newArrayList();
|
||||
private Integer sensitiveLevel;
|
||||
private Integer status;
|
||||
private String key;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.tencent.supersonic.semantic.api.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@@ -14,6 +18,8 @@ public class MetricResp extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String modelName;
|
||||
|
||||
//ATOMIC DERIVED
|
||||
@@ -27,5 +33,13 @@ public class MetricResp extends SchemaItem {
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
public void setTag(String tag) {
|
||||
if (StringUtils.isBlank(tag)) {
|
||||
tags = Lists.newArrayList();
|
||||
} else {
|
||||
tags = Arrays.asList(tag.split(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.tencent.supersonic.semantic.model.domain.utils.MetricConverter;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Metric;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -250,6 +251,16 @@ public class MetricServiceImpl implements MetricService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMetricTags() {
|
||||
List<MetricResp> metricResps = getMetrics();
|
||||
if (CollectionUtils.isEmpty(metricResps)) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
return metricResps.stream().flatMap(metricResp ->
|
||||
metricResp.getTags().stream()).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
private void saveMetricBatch(List<Metric> metrics, User user) {
|
||||
if (CollectionUtils.isEmpty(metrics)) {
|
||||
@@ -293,7 +304,7 @@ public class MetricServiceImpl implements MetricService {
|
||||
Map<Long, ModelResp> modelMap = modelService.getModelMap();
|
||||
if (!CollectionUtils.isEmpty(metricDOS)) {
|
||||
metricDescs = metricDOS.stream()
|
||||
.map(metricDO -> MetricConverter.convert2MetricDesc(metricDO, modelMap))
|
||||
.map(metricDO -> MetricConverter.convert2MetricResp(metricDO, modelMap))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return metricDescs;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MetricService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public interface MetricService {
|
||||
|
||||
void createMetricBatch(List<MetricReq> metricReqs, User user) throws Exception;
|
||||
|
||||
PageInfo<MetricResp> queryMetric(PageMetricReq pageMetrricReq);
|
||||
PageInfo<MetricResp> queryMetric(PageMetricReq pageMetricReq);
|
||||
|
||||
MetricResp getMetric(Long modelId, String bizName);
|
||||
|
||||
@@ -35,4 +36,6 @@ public interface MetricService {
|
||||
void deleteMetric(Long id) throws Exception;
|
||||
|
||||
List<String> mockAlias(MetricReq metricReq, String mockType, User user);
|
||||
|
||||
Set<String> getMetricTags();
|
||||
}
|
||||
|
||||
@@ -3,116 +3,247 @@ package com.tencent.supersonic.semantic.model.domain.dataobject;
|
||||
import java.util.Date;
|
||||
|
||||
public class MetricDO {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主体域ID
|
||||
*/
|
||||
private Long modelId;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 指标状态,0正常,1下架,2删除
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
*/
|
||||
private Integer sensitiveLevel;
|
||||
|
||||
/**
|
||||
* 指标类型 proxy,expr
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 数值类型
|
||||
*/
|
||||
private String dataFormatType;
|
||||
|
||||
/**
|
||||
* 数值类型参数
|
||||
*/
|
||||
private String dataFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
* 类型参数
|
||||
*/
|
||||
private String typeParams;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主体域ID
|
||||
* @return model_id 主体域ID
|
||||
*/
|
||||
public Long getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主体域ID
|
||||
* @param modelId 主体域ID
|
||||
*/
|
||||
public void setModelId(Long modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
* @return name 指标名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
* @param name 指标名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
* @return biz_name 字段名称
|
||||
*/
|
||||
public String getBizName() {
|
||||
return bizName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
* @param bizName 字段名称
|
||||
*/
|
||||
public void setBizName(String bizName) {
|
||||
this.bizName = bizName == null ? null : bizName.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* @return description 描述
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* @param description 描述
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description == null ? null : description.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标状态,0正常,1下架,2删除
|
||||
* @return status 指标状态,0正常,1下架,2删除
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标状态,0正常,1下架,2删除
|
||||
* @param status 指标状态,0正常,1下架,2删除
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
* @return sensitive_level 敏感级别
|
||||
*/
|
||||
public Integer getSensitiveLevel() {
|
||||
return sensitiveLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
* @param sensitiveLevel 敏感级别
|
||||
*/
|
||||
public void setSensitiveLevel(Integer sensitiveLevel) {
|
||||
this.sensitiveLevel = sensitiveLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标类型 proxy,expr
|
||||
* @return type 指标类型 proxy,expr
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标类型 proxy,expr
|
||||
* @param type 指标类型 proxy,expr
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type == null ? null : type.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* @return created_at 创建时间
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* @param createdAt 创建时间
|
||||
*/
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
* @return created_by 创建人
|
||||
*/
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
* @param createdBy 创建人
|
||||
*/
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy == null ? null : createdBy.trim();
|
||||
}
|
||||
@@ -182,21 +313,37 @@ public class MetricDO {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return alias
|
||||
*
|
||||
* @return alias
|
||||
*/
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param alias
|
||||
*
|
||||
* @param alias
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias == null ? null : alias.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return tags
|
||||
*/
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tags
|
||||
*/
|
||||
public void setTags(String tags) {
|
||||
this.tags = tags == null ? null : tags.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型参数
|
||||
* @return type_params 类型参数
|
||||
@@ -212,4 +359,4 @@ public class MetricDO {
|
||||
public void setTypeParams(String typeParams) {
|
||||
this.typeParams = typeParams == null ? null : typeParams.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public class MetricDOExample {
|
||||
protected Integer limitEnd;
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public MetricDOExample() {
|
||||
@@ -38,6 +39,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
@@ -45,6 +47,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public String getOrderByClause() {
|
||||
@@ -52,6 +55,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setDistinct(boolean distinct) {
|
||||
@@ -59,6 +63,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public boolean isDistinct() {
|
||||
@@ -66,6 +71,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public List<Criteria> getOredCriteria() {
|
||||
@@ -73,6 +79,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void or(Criteria criteria) {
|
||||
@@ -80,6 +87,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Criteria or() {
|
||||
@@ -89,6 +97,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Criteria createCriteria() {
|
||||
@@ -100,6 +109,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
protected Criteria createCriteriaInternal() {
|
||||
@@ -108,6 +118,7 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void clear() {
|
||||
@@ -117,13 +128,15 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setLimitStart(Integer limitStart) {
|
||||
this.limitStart = limitStart;
|
||||
this.limitStart=limitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getLimitStart() {
|
||||
@@ -131,13 +144,15 @@ public class MetricDOExample {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setLimitEnd(Integer limitEnd) {
|
||||
this.limitEnd = limitEnd;
|
||||
this.limitEnd=limitEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getLimitEnd() {
|
||||
@@ -1177,6 +1192,76 @@ public class MetricDOExample {
|
||||
addCriterion("alias not between", value1, value2, "alias");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsIsNull() {
|
||||
addCriterion("tags is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsIsNotNull() {
|
||||
addCriterion("tags is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsEqualTo(String value) {
|
||||
addCriterion("tags =", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsNotEqualTo(String value) {
|
||||
addCriterion("tags <>", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsGreaterThan(String value) {
|
||||
addCriterion("tags >", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("tags >=", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsLessThan(String value) {
|
||||
addCriterion("tags <", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsLessThanOrEqualTo(String value) {
|
||||
addCriterion("tags <=", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsLike(String value) {
|
||||
addCriterion("tags like", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsNotLike(String value) {
|
||||
addCriterion("tags not like", value, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsIn(List<String> values) {
|
||||
addCriterion("tags in", values, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsNotIn(List<String> values) {
|
||||
addCriterion("tags not in", values, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsBetween(String value1, String value2) {
|
||||
addCriterion("tags between", value1, value2, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTagsNotBetween(String value1, String value2) {
|
||||
addCriterion("tags not between", value1, value2, "tags");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1209,6 +1294,38 @@ public class MetricDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -1244,37 +1361,5 @@ public class MetricDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.tencent.supersonic.semantic.model.domain.pojo;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Metric extends SchemaItem {
|
||||
@@ -23,4 +25,13 @@ public class Metric extends SchemaItem {
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
public String getTag() {
|
||||
if (CollectionUtils.isEmpty(tags)) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.join(tags, ",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class MetricConverter {
|
||||
if (metric.getDataFormat() != null) {
|
||||
metricDO.setDataFormat(JSONObject.toJSONString(metric.getDataFormat()));
|
||||
}
|
||||
metricDO.setTags(metric.getTag());
|
||||
return metricDO;
|
||||
}
|
||||
|
||||
@@ -51,27 +52,23 @@ public class MetricConverter {
|
||||
BeanUtils.copyProperties(metric, metricDO);
|
||||
metricDO.setTypeParams(JSONObject.toJSONString(metric.getTypeParams()));
|
||||
metricDO.setDataFormat(JSONObject.toJSONString(metric.getDataFormat()));
|
||||
metricDO.setTags(metric.getTag());
|
||||
return metricDO;
|
||||
}
|
||||
|
||||
|
||||
public static MetricResp convert2MetricDesc(MetricDO metricDO, Map<Long, ModelResp> modelMap) {
|
||||
MetricResp metricDesc = new MetricResp();
|
||||
BeanUtils.copyProperties(metricDO, metricDesc);
|
||||
metricDesc.setTypeParams(JSONObject.parseObject(metricDO.getTypeParams(), MetricTypeParams.class));
|
||||
metricDesc.setDataFormat(JSONObject.parseObject(metricDO.getDataFormat(), DataFormat.class));
|
||||
public static MetricResp convert2MetricResp(MetricDO metricDO, Map<Long, ModelResp> modelMap) {
|
||||
MetricResp metricResp = new MetricResp();
|
||||
BeanUtils.copyProperties(metricDO, metricResp);
|
||||
metricResp.setTypeParams(JSONObject.parseObject(metricDO.getTypeParams(), MetricTypeParams.class));
|
||||
metricResp.setDataFormat(JSONObject.parseObject(metricDO.getDataFormat(), DataFormat.class));
|
||||
ModelResp modelResp = modelMap.get(metricDO.getModelId());
|
||||
if (modelResp != null) {
|
||||
metricDesc.setModelName(modelResp.getName());
|
||||
metricResp.setModelName(modelResp.getName());
|
||||
metricResp.setDomainId(modelResp.getDomainId());
|
||||
}
|
||||
return metricDesc;
|
||||
}
|
||||
|
||||
public static Metric convert2Metric(MetricDO metricDO) {
|
||||
Metric metric = new Metric();
|
||||
BeanUtils.copyProperties(metricDO, metric);
|
||||
metric.setTypeParams(JSONObject.parseObject(metricDO.getTypeParams(), MetricTypeParams.class));
|
||||
return metric;
|
||||
metricResp.setTag(metricDO.getTags());
|
||||
return metricResp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -90,4 +91,9 @@ public class MetricController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getMetricTags")
|
||||
public Set<String> getMetricTags() {
|
||||
return metricService.getMetricTags();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<result column="data_format_type" jdbcType="VARCHAR" property="dataFormatType" />
|
||||
<result column="data_format" jdbcType="VARCHAR" property="dataFormat" />
|
||||
<result column="alias" jdbcType="VARCHAR" property="alias" />
|
||||
<result column="tags" jdbcType="VARCHAR" property="tags" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO">
|
||||
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams" />
|
||||
@@ -52,7 +53,7 @@
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, model_id, name, biz_name, description, status, sensitive_level, type, created_at,
|
||||
created_by, updated_at, updated_by, data_format_type, data_format, alias
|
||||
created_by, updated_at, updated_by, data_format_type, data_format, alias, tags
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
type_params
|
||||
@@ -108,13 +109,13 @@
|
||||
sensitive_level, type, created_at,
|
||||
created_by, updated_at, updated_by,
|
||||
data_format_type, data_format, alias,
|
||||
type_params)
|
||||
tags, type_params)
|
||||
values (#{id,jdbcType=BIGINT}, #{modelId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
|
||||
#{bizName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
|
||||
#{sensitiveLevel,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
|
||||
#{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR},
|
||||
#{dataFormatType,jdbcType=VARCHAR}, #{dataFormat,jdbcType=VARCHAR}, #{alias,jdbcType=VARCHAR},
|
||||
#{typeParams,jdbcType=LONGVARCHAR})
|
||||
#{tags,jdbcType=VARCHAR}, #{typeParams,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO">
|
||||
insert into s2_metric
|
||||
@@ -164,6 +165,9 @@
|
||||
<if test="alias != null">
|
||||
alias,
|
||||
</if>
|
||||
<if test="tags != null">
|
||||
tags,
|
||||
</if>
|
||||
<if test="typeParams != null">
|
||||
type_params,
|
||||
</if>
|
||||
@@ -214,6 +218,9 @@
|
||||
<if test="alias != null">
|
||||
#{alias,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tags != null">
|
||||
#{tags,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="typeParams != null">
|
||||
#{typeParams,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@@ -270,6 +277,9 @@
|
||||
<if test="alias != null">
|
||||
alias = #{alias,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tags != null">
|
||||
tags = #{tags,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="typeParams != null">
|
||||
type_params = #{typeParams,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@@ -292,6 +302,7 @@
|
||||
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
|
||||
data_format = #{dataFormat,jdbcType=VARCHAR},
|
||||
alias = #{alias,jdbcType=VARCHAR},
|
||||
tags = #{tags,jdbcType=VARCHAR},
|
||||
type_params = #{typeParams,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
@@ -310,7 +321,8 @@
|
||||
updated_by = #{updatedBy,jdbcType=VARCHAR},
|
||||
data_format_type = #{dataFormatType,jdbcType=VARCHAR},
|
||||
data_format = #{dataFormat,jdbcType=VARCHAR},
|
||||
alias = #{alias,jdbcType=VARCHAR}
|
||||
alias = #{alias,jdbcType=VARCHAR},
|
||||
tags = #{tags,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -2,22 +2,26 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tencent.supersonic.semantic.model.infrastructure.mapper.MetricDOCustomMapper">
|
||||
<resultMap id="BaseResultMap"
|
||||
type="com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="model_id" jdbcType="BIGINT" property="modelId"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="biz_name" jdbcType="VARCHAR" property="bizName"/>
|
||||
<result column="description" jdbcType="VARCHAR" property="description"/>
|
||||
<result column="type" jdbcType="VARCHAR" property="type"/>
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
|
||||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
|
||||
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
|
||||
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="model_id" jdbcType="BIGINT" property="modelId" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="sensitive_level" jdbcType="INTEGER" property="sensitiveLevel" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
|
||||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
||||
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
|
||||
<result column="data_format_type" jdbcType="VARCHAR" property="dataFormatType" />
|
||||
<result column="data_format" jdbcType="VARCHAR" property="dataFormat" />
|
||||
<result column="alias" jdbcType="VARCHAR" property="alias" />
|
||||
<result column="tags" jdbcType="VARCHAR" property="tags" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
|
||||
type="com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO">
|
||||
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams"/>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO">
|
||||
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@@ -51,12 +55,11 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
, model_id, name, biz_name, description, type, created_at, created_by, updated_at,
|
||||
updated_by
|
||||
id, model_id, name, biz_name, description, status, sensitive_level, type, created_at,
|
||||
created_by, updated_at, updated_by, data_format_type, data_format, alias, tags
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
typeParams
|
||||
type_params
|
||||
</sql>
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
@@ -108,7 +111,8 @@
|
||||
and ( id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||
name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||
biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||
description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
|
||||
description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||
tags like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
|
||||
</if>
|
||||
<if test="id != null">
|
||||
and id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
|
||||
|
||||
Reference in New Issue
Block a user