From 91718592d4be5f35039dcade69672cfe106bf180 Mon Sep 17 00:00:00 2001 From: LXW <1264174498@qq.com> Date: Tue, 21 Nov 2023 11:44:27 +0800 Subject: [PATCH] (improvement)(semantic) Add is_tag label to the dimension and Specify entity alias on datasource primary-key (#411) Co-authored-by: jolunoluo --- .../tencent/supersonic/LoadModelDataDemo.java | 8 +- .../src/main/resources/db/schema-h2.sql | 1 + .../src/main/resources/db/schema-mysql.sql | 1 + .../src/main/resources/db/sql-update.sql | 5 +- .../src/test/resources/db/schema-h2.sql | 1 + .../semantic/api/model/pojo/Dim.java | 12 + .../semantic/api/model/pojo/Identify.java | 10 +- .../api/model/request/DimensionReq.java | 6 +- .../api/model/response/DimensionResp.java | 7 +- .../model/domain/dataobject/DimensionDO.java | 349 +---------------- .../model/domain/dataobject/MetricDO.java | 298 +------------- .../domain/utils/DatasourceConverter.java | 7 +- .../mapper/DimensionDOMapper.java | 64 +-- .../infrastructure/mapper/MetricDOMapper.java | 64 +-- .../repository/DimensionRepositoryImpl.java | 8 +- .../repository/MetricRepositoryImpl.java | 6 +- .../resources/mapper/DimensionDOMapper.xml | 366 ------------------ .../main/resources/mapper/MetricDOMapper.xml | 342 ---------------- .../mapper/custom/DimensionDOCustomMapper.xml | 4 +- 19 files changed, 73 insertions(+), 1486 deletions(-) delete mode 100644 semantic/model/src/main/resources/mapper/DimensionDOMapper.xml delete mode 100644 semantic/model/src/main/resources/mapper/MetricDOMapper.xml diff --git a/launchers/standalone/src/main/java/com/tencent/supersonic/LoadModelDataDemo.java b/launchers/standalone/src/main/java/com/tencent/supersonic/LoadModelDataDemo.java index 0882b1f45..dd524348d 100644 --- a/launchers/standalone/src/main/java/com/tencent/supersonic/LoadModelDataDemo.java +++ b/launchers/standalone/src/main/java/com/tencent/supersonic/LoadModelDataDemo.java @@ -234,7 +234,9 @@ public class LoadModelDataDemo implements CommandLineRunner { datasourceReq.setDatabaseId(1L); List identifiers = new ArrayList<>(); - identifiers.add(new Identify("歌手名", IdentifyTypeEnum.primary.name(), "singer_name")); + Identify identify = new Identify("歌手名", IdentifyTypeEnum.primary.name(), "singer_name"); + identify.setEntityNames(Lists.newArrayList("歌手", "艺人")); + identifiers.add(identify); datasourceReq.setIdentifiers(identifiers); List dimensions = new ArrayList<>(); @@ -242,11 +244,11 @@ public class LoadModelDataDemo implements CommandLineRunner { dimension1.setTypeParams(new DimensionTimeTypeParams()); dimensions.add(dimension1); dimensions.add(new Dim("活跃区域", "act_area", - DimensionTypeEnum.categorical.name(), 1)); + DimensionTypeEnum.categorical.name(), 1, 1)); dimensions.add(new Dim("代表作", "song_name", DimensionTypeEnum.categorical.name(), 1)); dimensions.add(new Dim("风格", "genre", - DimensionTypeEnum.categorical.name(), 1)); + DimensionTypeEnum.categorical.name(), 1, 1)); datasourceReq.setDimensions(dimensions); Measure measure1 = new Measure("播放量", "js_play_cnt", "sum", 1); diff --git a/launchers/standalone/src/main/resources/db/schema-h2.sql b/launchers/standalone/src/main/resources/db/schema-h2.sql index 9c48815bf..f1c1195ad 100644 --- a/launchers/standalone/src/main/resources/db/schema-h2.sql +++ b/launchers/standalone/src/main/resources/db/schema-h2.sql @@ -226,6 +226,7 @@ CREATE TABLE IF NOT EXISTS `s2_dimension` ( `alias` varchar(500) DEFAULT NULL, `default_values` varchar(500) DEFAULT NULL, `dim_value_maps` varchar(500) DEFAULT NULL, + `is_tag` INT DEFAULT NULL, PRIMARY KEY (`id`) ); COMMENT ON TABLE s2_dimension IS 'dimension information table'; diff --git a/launchers/standalone/src/main/resources/db/schema-mysql.sql b/launchers/standalone/src/main/resources/db/schema-mysql.sql index 7bc345d8c..87ed2ecaf 100644 --- a/launchers/standalone/src/main/resources/db/schema-mysql.sql +++ b/launchers/standalone/src/main/resources/db/schema-mysql.sql @@ -219,6 +219,7 @@ CREATE TABLE `s2_dimension` ( `alias` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `default_values` varchar(500) DEFAULT NULL, `dim_value_maps` varchar(5000) DEFAULT NULL, + `is_tag` int(10) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='维度表'; diff --git a/launchers/standalone/src/main/resources/db/sql-update.sql b/launchers/standalone/src/main/resources/db/sql-update.sql index 149ade1b2..51769b52b 100644 --- a/launchers/standalone/src/main/resources/db/sql-update.sql +++ b/launchers/standalone/src/main/resources/db/sql-update.sql @@ -93,4 +93,7 @@ CREATE TABLE s2_sys_parameter alter table s2_chat_config add column `llm_examples` text COMMENT 'llm examples'; --20231116 -alter table s2_datasource add column `filter_sql` varchar(1000) COMMENT 'filter_sql' after depends; \ No newline at end of file +alter table s2_datasource add column `filter_sql` varchar(1000) COMMENT 'filter_sql' after depends; + +--20231120 +alter table s2_dimension add column `is_tag` int(10) DEFAULT NULL; \ No newline at end of file diff --git a/launchers/standalone/src/test/resources/db/schema-h2.sql b/launchers/standalone/src/test/resources/db/schema-h2.sql index d75ced5a8..9ace2760e 100644 --- a/launchers/standalone/src/test/resources/db/schema-h2.sql +++ b/launchers/standalone/src/test/resources/db/schema-h2.sql @@ -241,6 +241,7 @@ CREATE TABLE IF NOT EXISTS `s2_dimension` ( `alias` varchar(500) DEFAULT NULL, `default_values` varchar(500) DEFAULT NULL, `dim_value_maps` varchar(500) DEFAULT NULL, + `is_tag` INT DEFAULT NULL, PRIMARY KEY (`id`) ); COMMENT ON TABLE s2_dimension IS 'dimension information table'; diff --git a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Dim.java b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Dim.java index 33ee6acec..11c21f15c 100644 --- a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Dim.java +++ b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Dim.java @@ -27,6 +27,8 @@ public class Dim { private String description; + private int isTag; + public Dim(String name, String bizName, String type, Integer isCreateDimension) { this.name = name; this.type = type; @@ -34,6 +36,14 @@ public class Dim { 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; @@ -45,6 +55,8 @@ public class Dim { this.bizName = bizName; } + + public static Dim getDefault() { return new Dim("日期", "time", "2023-05-28", Constants.DAY_FORMAT, diff --git a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Identify.java b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Identify.java index e3bddbf0f..30a62f79a 100644 --- a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Identify.java +++ b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/pojo/Identify.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; @Data @AllArgsConstructor @@ -13,10 +14,17 @@ public class Identify { private String name; /** - * like primary, foreign + * primary, foreign */ private String type; private String bizName; + private List entityNames; + + public Identify(String name, String type, String bizName) { + this.name = name; + this.type = type; + this.bizName = bizName; + } } diff --git a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/request/DimensionReq.java b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/request/DimensionReq.java index 3b069b6df..191cd0dde 100644 --- a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/request/DimensionReq.java +++ b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/request/DimensionReq.java @@ -3,11 +3,9 @@ package com.tencent.supersonic.semantic.api.model.request; import com.tencent.supersonic.common.pojo.enums.DataTypeEnums; import com.tencent.supersonic.semantic.api.model.pojo.DimValueMap; import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem; - -import javax.validation.constraints.NotNull; - import lombok.Data; +import javax.validation.constraints.NotNull; import java.util.List; @Data @@ -33,4 +31,6 @@ public class DimensionReq extends SchemaItem { private List dimValueMaps; private DataTypeEnums dataType; + + private int isTag; } diff --git a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/DimensionResp.java b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/DimensionResp.java index 712af0ab0..408195217 100644 --- a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/DimensionResp.java +++ b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/DimensionResp.java @@ -4,12 +4,11 @@ package com.tencent.supersonic.semantic.api.model.response; import com.tencent.supersonic.common.pojo.enums.DataTypeEnums; import com.tencent.supersonic.semantic.api.model.pojo.DimValueMap; import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem; - -import java.util.List; - import lombok.Data; import lombok.ToString; +import java.util.List; + @Data @ToString(callSuper = true) @@ -41,4 +40,6 @@ public class DimensionResp extends SchemaItem { private DataTypeEnums dataType; + private int isTag; + } diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/DimensionDO.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/DimensionDO.java index 870e5e681..cfad208d8 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/DimensionDO.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/DimensionDO.java @@ -1,11 +1,18 @@ package com.tencent.supersonic.semantic.model.domain.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_dimension") public class DimensionDO { /** * 维度ID */ + @TableId(type = IdType.AUTO) private Long id; /** @@ -103,345 +110,5 @@ public class DimensionDO { */ private String dataType; - /** - * 维度ID - * - * @return id 维度ID - */ - public Long getId() { - return id; - } - - /** - * 维度ID - * - * @param id 维度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; - } - - /** - * 所属数据源id - * - * @return datasource_id 所属数据源id - */ - public Long getDatasourceId() { - return datasourceId; - } - - /** - * 所属数据源id - * - * @param datasourceId 所属数据源id - */ - public void setDatasourceId(Long datasourceId) { - this.datasourceId = datasourceId; - } - - /** - * 维度名称 - * - * @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; - } - - /** - * 维度类型 categorical,time - * - * @return type 维度类型 categorical,time - */ - public String getType() { - return type; - } - - /** - * 维度类型 categorical,time - * - * @param type 维度类型 categorical,time - */ - 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(); - } - - /** - * 更新时间 - * - * @return updated_at 更新时间 - */ - public Date getUpdatedAt() { - return updatedAt; - } - - /** - * 更新时间 - * - * @param updatedAt 更新时间 - */ - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - /** - * 更新人 - * - * @return updated_by 更新人 - */ - public String getUpdatedBy() { - return updatedBy; - } - - /** - * 更新人 - * - * @param updatedBy 更新人 - */ - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy == null ? null : updatedBy.trim(); - } - - /** - * 语义类型DATE, ID, CATEGORY - * - * @return semantic_type 语义类型DATE, ID, CATEGORY - */ - public String getSemanticType() { - return semanticType; - } - - /** - * 语义类型DATE, ID, CATEGORY - * - * @param semanticType 语义类型DATE, ID, CATEGORY - */ - public void setSemanticType(String semanticType) { - this.semanticType = semanticType == null ? null : semanticType.trim(); - } - - /** - * @return alias - */ - public String getAlias() { - return alias; - } - - /** - * @param alias - */ - public void setAlias(String alias) { - this.alias = alias == null ? null : alias.trim(); - } - - /** - * default values of dimension when query - * - * @return default_values default values of dimension when query - */ - public String getDefaultValues() { - return defaultValues; - } - - /** - * default values of dimension when query - * - * @param defaultValues default values of dimension when query - */ - public void setDefaultValues(String defaultValues) { - this.defaultValues = defaultValues == null ? null : defaultValues.trim(); - } - - /** - * @return dim_value_maps - */ - public String getDimValueMaps() { - return dimValueMaps; - } - - /** - * @param dimValueMaps - */ - public void setDimValueMaps(String dimValueMaps) { - this.dimValueMaps = dimValueMaps == null ? null : dimValueMaps.trim(); - } - - /** - * 类型参数 - * - * @return type_params 类型参数 - */ - public String getTypeParams() { - return typeParams; - } - - /** - * 类型参数 - * - * @param typeParams 类型参数 - */ - public void setTypeParams(String typeParams) { - this.typeParams = typeParams == null ? null : typeParams.trim(); - } - - /** - * 表达式 - * - * @return expr 表达式 - */ - public String getExpr() { - return expr; - } - - /** - * 表达式 - * - * @param expr 表达式 - */ - public void setExpr(String expr) { - this.expr = expr == null ? null : expr.trim(); - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } + private int isTag; } \ No newline at end of file diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/MetricDO.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/MetricDO.java index 03d211f91..4b5466c16 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/MetricDO.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/dataobject/MetricDO.java @@ -1,11 +1,16 @@ package com.tencent.supersonic.semantic.model.domain.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_metric") public class MetricDO { - /** - * - */ + + @TableId(type = IdType.AUTO) private Long id; /** @@ -93,291 +98,4 @@ public class MetricDO { */ 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(); - } - - /** - * 更新时间 - * @return updated_at 更新时间 - */ - public Date getUpdatedAt() { - return updatedAt; - } - - /** - * 更新时间 - * @param updatedAt 更新时间 - */ - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - /** - * 更新人 - * @return updated_by 更新人 - */ - public String getUpdatedBy() { - return updatedBy; - } - - /** - * 更新人 - * @param updatedBy 更新人 - */ - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy == null ? null : updatedBy.trim(); - } - - /** - * 数值类型 - * @return data_format_type 数值类型 - */ - public String getDataFormatType() { - return dataFormatType; - } - - /** - * 数值类型 - * @param dataFormatType 数值类型 - */ - public void setDataFormatType(String dataFormatType) { - this.dataFormatType = dataFormatType == null ? null : dataFormatType.trim(); - } - - /** - * 数值类型参数 - * @return data_format 数值类型参数 - */ - public String getDataFormat() { - return dataFormat; - } - - /** - * 数值类型参数 - * @param dataFormat 数值类型参数 - */ - public void setDataFormat(String dataFormat) { - this.dataFormat = dataFormat == null ? null : dataFormat.trim(); - } - - /** - * - * @return alias - */ - public String getAlias() { - return 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 relate_dimensions - */ - public String getRelateDimensions() { - return relateDimensions; - } - - /** - * - * @param relateDimensions - */ - public void setRelateDimensions(String relateDimensions) { - this.relateDimensions = relateDimensions == null ? null : relateDimensions.trim(); - } - - /** - * 类型参数 - * @return type_params 类型参数 - */ - public String getTypeParams() { - return typeParams; - } - - /** - * 类型参数 - * @param typeParams 类型参数 - */ - public void setTypeParams(String typeParams) { - this.typeParams = typeParams == null ? null : typeParams.trim(); - } } \ No newline at end of file diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/utils/DatasourceConverter.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/utils/DatasourceConverter.java index 5fd9227e3..4f95ca866 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/utils/DatasourceConverter.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/domain/utils/DatasourceConverter.java @@ -18,13 +18,13 @@ import com.tencent.supersonic.semantic.api.model.response.DatasourceResp; import com.tencent.supersonic.semantic.api.model.response.MeasureResp; import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO; import com.tencent.supersonic.semantic.model.domain.pojo.Datasource; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.util.CollectionUtils; import java.util.Date; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.util.CollectionUtils; public class DatasourceConverter { @@ -79,6 +79,7 @@ public class DatasourceConverter { dimensionReq.setExpr(dim.getBizName()); dimensionReq.setType("categorical"); dimensionReq.setDescription(Objects.isNull(dim.getDescription()) ? "" : dim.getDescription()); + dimensionReq.setIsTag(dim.getIsTag()); return dimensionReq; } diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/DimensionDOMapper.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/DimensionDOMapper.java index 50065e02e..1ec00edba 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/DimensionDOMapper.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/DimensionDOMapper.java @@ -1,70 +1,10 @@ package com.tencent.supersonic.semantic.model.infrastructure.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.tencent.supersonic.semantic.model.domain.dataobject.DimensionDO; -import com.tencent.supersonic.semantic.model.domain.dataobject.DimensionDOExample; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - @Mapper -public interface DimensionDOMapper { - /** - * - * @mbg.generated - */ - long countByExample(DimensionDOExample example); +public interface DimensionDOMapper extends BaseMapper { - /** - * - * @mbg.generated - */ - int deleteByPrimaryKey(Long id); - - /** - * - * @mbg.generated - */ - int insert(DimensionDO record); - - /** - * - * @mbg.generated - */ - int insertSelective(DimensionDO record); - - /** - * - * @mbg.generated - */ - List selectByExampleWithBLOBs(DimensionDOExample example); - - /** - * - * @mbg.generated - */ - List selectByExample(DimensionDOExample example); - - /** - * - * @mbg.generated - */ - DimensionDO selectByPrimaryKey(Long id); - - /** - * - * @mbg.generated - */ - int updateByPrimaryKeySelective(DimensionDO record); - - /** - * - * @mbg.generated - */ - int updateByPrimaryKeyWithBLOBs(DimensionDO record); - - /** - * - * @mbg.generated - */ - int updateByPrimaryKey(DimensionDO record); } \ No newline at end of file diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/MetricDOMapper.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/MetricDOMapper.java index c0c036d42..205a9a77b 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/MetricDOMapper.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/mapper/MetricDOMapper.java @@ -1,70 +1,10 @@ package com.tencent.supersonic.semantic.model.infrastructure.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO; -import com.tencent.supersonic.semantic.model.domain.dataobject.MetricDOExample; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - @Mapper -public interface MetricDOMapper { - /** - * - * @mbg.generated - */ - long countByExample(MetricDOExample example); +public interface MetricDOMapper extends BaseMapper { - /** - * - * @mbg.generated - */ - int deleteByPrimaryKey(Long id); - - /** - * - * @mbg.generated - */ - int insert(MetricDO record); - - /** - * - * @mbg.generated - */ - int insertSelective(MetricDO record); - - /** - * - * @mbg.generated - */ - List selectByExampleWithBLOBs(MetricDOExample example); - - /** - * - * @mbg.generated - */ - List selectByExample(MetricDOExample example); - - /** - * - * @mbg.generated - */ - MetricDO selectByPrimaryKey(Long id); - - /** - * - * @mbg.generated - */ - int updateByPrimaryKeySelective(MetricDO record); - - /** - * - * @mbg.generated - */ - int updateByPrimaryKeyWithBLOBs(MetricDO record); - - /** - * - * @mbg.generated - */ - int updateByPrimaryKey(MetricDO record); } \ No newline at end of file diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/DimensionRepositoryImpl.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/DimensionRepositoryImpl.java index 0511a9de0..da36f1390 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/DimensionRepositoryImpl.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/DimensionRepositoryImpl.java @@ -1,12 +1,12 @@ package com.tencent.supersonic.semantic.model.infrastructure.repository; import com.tencent.supersonic.semantic.model.domain.dataobject.DimensionDO; -import com.tencent.supersonic.semantic.model.domain.repository.DimensionRepository; import com.tencent.supersonic.semantic.model.domain.pojo.DimensionFilter; +import com.tencent.supersonic.semantic.model.domain.repository.DimensionRepository; import com.tencent.supersonic.semantic.model.infrastructure.mapper.DimensionDOCustomMapper; import com.tencent.supersonic.semantic.model.infrastructure.mapper.DimensionDOMapper; -import java.util.List; import org.springframework.stereotype.Service; +import java.util.List; @Service public class DimensionRepositoryImpl implements DimensionRepository { @@ -33,7 +33,7 @@ public class DimensionRepositoryImpl implements DimensionRepository { @Override public void updateDimension(DimensionDO dimensionDO) { - dimensionDOMapper.updateByPrimaryKeySelective(dimensionDO); + dimensionDOMapper.updateById(dimensionDO); } @Override @@ -43,7 +43,7 @@ public class DimensionRepositoryImpl implements DimensionRepository { @Override public DimensionDO getDimensionById(Long id) { - return dimensionDOMapper.selectByPrimaryKey(id); + return dimensionDOMapper.selectById(id); } @Override diff --git a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/MetricRepositoryImpl.java b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/MetricRepositoryImpl.java index 378008b57..c32bfc5c5 100644 --- a/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/MetricRepositoryImpl.java +++ b/semantic/model/src/main/java/com/tencent/supersonic/semantic/model/infrastructure/repository/MetricRepositoryImpl.java @@ -5,8 +5,8 @@ import com.tencent.supersonic.semantic.model.domain.pojo.MetricFilter; import com.tencent.supersonic.semantic.model.domain.repository.MetricRepository; import com.tencent.supersonic.semantic.model.infrastructure.mapper.MetricDOCustomMapper; import com.tencent.supersonic.semantic.model.infrastructure.mapper.MetricDOMapper; -import java.util.List; import org.springframework.stereotype.Component; +import java.util.List; @Component @@ -36,7 +36,7 @@ public class MetricRepositoryImpl implements MetricRepository { @Override public void updateMetric(MetricDO metricDO) { - metricDOMapper.updateByPrimaryKeySelective(metricDO); + metricDOMapper.updateById(metricDO); } @Override @@ -46,7 +46,7 @@ public class MetricRepositoryImpl implements MetricRepository { @Override public MetricDO getMetricById(Long id) { - return metricDOMapper.selectByPrimaryKey(id); + return metricDOMapper.selectById(id); } @Override diff --git a/semantic/model/src/main/resources/mapper/DimensionDOMapper.xml b/semantic/model/src/main/resources/mapper/DimensionDOMapper.xml deleted file mode 100644 index c454a8176..000000000 --- a/semantic/model/src/main/resources/mapper/DimensionDOMapper.xml +++ /dev/null @@ -1,366 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - id, model_id, datasource_id, name, biz_name, description, status, sensitive_level, - type, created_at, created_by, updated_at, updated_by, semantic_type, alias, default_values, - dim_value_maps, data_type - - - type_params, expr - - - - - - delete from s2_dimension - where id = #{id,jdbcType=BIGINT} - - - insert into s2_dimension (id, model_id, datasource_id, - name, biz_name, description, - status, sensitive_level, type, - created_at, created_by, updated_at, - updated_by, semantic_type, alias, - default_values, dim_value_maps, type_params, - expr, data_type) - values (#{id,jdbcType=BIGINT}, #{modelId,jdbcType=BIGINT}, #{datasourceId,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}, #{semanticType,jdbcType=VARCHAR}, #{alias,jdbcType=VARCHAR}, - #{defaultValues,jdbcType=VARCHAR}, #{dimValueMaps,jdbcType=VARCHAR}, #{typeParams,jdbcType=LONGVARCHAR}, - #{expr,jdbcType=LONGVARCHAR}, #{dataType,jdbcType=VARCHAR}) - - - insert into s2_dimension - - - id, - - - model_id, - - - datasource_id, - - - name, - - - biz_name, - - - description, - - - status, - - - sensitive_level, - - - type, - - - created_at, - - - created_by, - - - updated_at, - - - updated_by, - - - semantic_type, - - - alias, - - - default_values, - - - dim_value_maps, - - - type_params, - - - expr, - - - data_type, - - - - - #{id,jdbcType=BIGINT}, - - - #{modelId,jdbcType=BIGINT}, - - - #{datasourceId,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}, - - - #{semanticType,jdbcType=VARCHAR}, - - - #{alias,jdbcType=VARCHAR}, - - - #{defaultValues,jdbcType=VARCHAR}, - - - #{dimValueMaps,jdbcType=VARCHAR}, - - - #{typeParams,jdbcType=LONGVARCHAR}, - - - #{expr,jdbcType=LONGVARCHAR}, - - - #{dataType,jdbcType=VARCHAR}, - - - - - - update s2_dimension - - - model_id = #{modelId,jdbcType=BIGINT}, - - - datasource_id = #{datasourceId,jdbcType=BIGINT}, - - - name = #{name,jdbcType=VARCHAR}, - - - biz_name = #{bizName,jdbcType=VARCHAR}, - - - description = #{description,jdbcType=VARCHAR}, - - - status = #{status,jdbcType=INTEGER}, - - - sensitive_level = #{sensitiveLevel,jdbcType=INTEGER}, - - - type = #{type,jdbcType=VARCHAR}, - - - created_at = #{createdAt,jdbcType=TIMESTAMP}, - - - created_by = #{createdBy,jdbcType=VARCHAR}, - - - updated_at = #{updatedAt,jdbcType=TIMESTAMP}, - - - updated_by = #{updatedBy,jdbcType=VARCHAR}, - - - semantic_type = #{semanticType,jdbcType=VARCHAR}, - - - alias = #{alias,jdbcType=VARCHAR}, - - - default_values = #{defaultValues,jdbcType=VARCHAR}, - - - dim_value_maps = #{dimValueMaps,jdbcType=VARCHAR}, - - - type_params = #{typeParams,jdbcType=LONGVARCHAR}, - - - expr = #{expr,jdbcType=LONGVARCHAR}, - - - data_type = #{dataType,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=BIGINT} - - - update s2_dimension - set model_id = #{modelId,jdbcType=BIGINT}, - datasource_id = #{datasourceId,jdbcType=BIGINT}, - name = #{name,jdbcType=VARCHAR}, - biz_name = #{bizName,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR}, - status = #{status,jdbcType=INTEGER}, - sensitive_level = #{sensitiveLevel,jdbcType=INTEGER}, - type = #{type,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=TIMESTAMP}, - created_by = #{createdBy,jdbcType=VARCHAR}, - updated_at = #{updatedAt,jdbcType=TIMESTAMP}, - updated_by = #{updatedBy,jdbcType=VARCHAR}, - semantic_type = #{semanticType,jdbcType=VARCHAR}, - alias = #{alias,jdbcType=VARCHAR}, - default_values = #{defaultValues,jdbcType=VARCHAR}, - dim_value_maps = #{dimValueMaps,jdbcType=VARCHAR}, - type_params = #{typeParams,jdbcType=LONGVARCHAR}, - expr = #{expr,jdbcType=LONGVARCHAR}, - data_type = #{dataType,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - - - update s2_dimension - set model_id = #{modelId,jdbcType=BIGINT}, - datasource_id = #{datasourceId,jdbcType=BIGINT}, - name = #{name,jdbcType=VARCHAR}, - biz_name = #{bizName,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR}, - status = #{status,jdbcType=INTEGER}, - sensitive_level = #{sensitiveLevel,jdbcType=INTEGER}, - type = #{type,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=TIMESTAMP}, - created_by = #{createdBy,jdbcType=VARCHAR}, - updated_at = #{updatedAt,jdbcType=TIMESTAMP}, - updated_by = #{updatedBy,jdbcType=VARCHAR}, - semantic_type = #{semanticType,jdbcType=VARCHAR}, - alias = #{alias,jdbcType=VARCHAR}, - default_values = #{defaultValues,jdbcType=VARCHAR}, - dim_value_maps = #{dimValueMaps,jdbcType=VARCHAR}, - data_type = #{dataType,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - - \ No newline at end of file diff --git a/semantic/model/src/main/resources/mapper/MetricDOMapper.xml b/semantic/model/src/main/resources/mapper/MetricDOMapper.xml deleted file mode 100644 index 0bce5189d..000000000 --- a/semantic/model/src/main/resources/mapper/MetricDOMapper.xml +++ /dev/null @@ -1,342 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - 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, relate_dimensions - - - type_params - - - - - - delete from s2_metric - where id = #{id,jdbcType=BIGINT} - - - insert into s2_metric (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, relate_dimensions, 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}, - #{tags,jdbcType=VARCHAR}, #{relateDimensions,jdbcType=VARCHAR}, #{typeParams,jdbcType=LONGVARCHAR} - ) - - - insert into s2_metric - - - 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, - - - relate_dimensions, - - - type_params, - - - - - #{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}, - - - #{tags,jdbcType=VARCHAR}, - - - #{relateDimensions,jdbcType=VARCHAR}, - - - #{typeParams,jdbcType=LONGVARCHAR}, - - - - - - update s2_metric - - - model_id = #{modelId,jdbcType=BIGINT}, - - - name = #{name,jdbcType=VARCHAR}, - - - biz_name = #{bizName,jdbcType=VARCHAR}, - - - description = #{description,jdbcType=VARCHAR}, - - - status = #{status,jdbcType=INTEGER}, - - - sensitive_level = #{sensitiveLevel,jdbcType=INTEGER}, - - - type = #{type,jdbcType=VARCHAR}, - - - created_at = #{createdAt,jdbcType=TIMESTAMP}, - - - created_by = #{createdBy,jdbcType=VARCHAR}, - - - updated_at = #{updatedAt,jdbcType=TIMESTAMP}, - - - updated_by = #{updatedBy,jdbcType=VARCHAR}, - - - data_format_type = #{dataFormatType,jdbcType=VARCHAR}, - - - data_format = #{dataFormat,jdbcType=VARCHAR}, - - - alias = #{alias,jdbcType=VARCHAR}, - - - tags = #{tags,jdbcType=VARCHAR}, - - - relate_dimensions = #{relateDimensions,jdbcType=VARCHAR}, - - - type_params = #{typeParams,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=BIGINT} - - - update s2_metric - set model_id = #{modelId,jdbcType=BIGINT}, - name = #{name,jdbcType=VARCHAR}, - biz_name = #{bizName,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR}, - status = #{status,jdbcType=INTEGER}, - sensitive_level = #{sensitiveLevel,jdbcType=INTEGER}, - type = #{type,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=TIMESTAMP}, - created_by = #{createdBy,jdbcType=VARCHAR}, - updated_at = #{updatedAt,jdbcType=TIMESTAMP}, - updated_by = #{updatedBy,jdbcType=VARCHAR}, - data_format_type = #{dataFormatType,jdbcType=VARCHAR}, - data_format = #{dataFormat,jdbcType=VARCHAR}, - alias = #{alias,jdbcType=VARCHAR}, - tags = #{tags,jdbcType=VARCHAR}, - relate_dimensions = #{relateDimensions,jdbcType=VARCHAR}, - type_params = #{typeParams,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=BIGINT} - - - update s2_metric - set model_id = #{modelId,jdbcType=BIGINT}, - name = #{name,jdbcType=VARCHAR}, - biz_name = #{bizName,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR}, - status = #{status,jdbcType=INTEGER}, - sensitive_level = #{sensitiveLevel,jdbcType=INTEGER}, - type = #{type,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=TIMESTAMP}, - created_by = #{createdBy,jdbcType=VARCHAR}, - updated_at = #{updatedAt,jdbcType=TIMESTAMP}, - updated_by = #{updatedBy,jdbcType=VARCHAR}, - data_format_type = #{dataFormatType,jdbcType=VARCHAR}, - data_format = #{dataFormat,jdbcType=VARCHAR}, - alias = #{alias,jdbcType=VARCHAR}, - tags = #{tags,jdbcType=VARCHAR}, - relate_dimensions = #{relateDimensions,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - - \ No newline at end of file diff --git a/semantic/model/src/main/resources/mapper/custom/DimensionDOCustomMapper.xml b/semantic/model/src/main/resources/mapper/custom/DimensionDOCustomMapper.xml index 6b4338fab..db1786a2d 100644 --- a/semantic/model/src/main/resources/mapper/custom/DimensionDOCustomMapper.xml +++ b/semantic/model/src/main/resources/mapper/custom/DimensionDOCustomMapper.xml @@ -69,7 +69,7 @@ description, status, model_id, type, type_params, expr, datasource_id, created_at, created_by, - updated_by, updated_at, semantic_type,sensitive_level) + updated_by, updated_at, semantic_type,sensitive_level, is_tag) values (#{dimension.name,jdbcType=VARCHAR}, #{dimension.bizName,jdbcType=VARCHAR}, @@ -81,7 +81,7 @@ #{dimension.createdBy,jdbcType=VARCHAR}, #{dimension.updatedBy,jdbcType=VARCHAR}, #{dimension.updatedAt,jdbcType=TIMESTAMP}, #{dimension.semanticType,jdbcType=VARCHAR}, - #{dimension.sensitiveLevel,jdbcType=INTEGER}) + #{dimension.sensitiveLevel,jdbcType=INTEGER}, #{dimension.isTag, jdbcType=INTEGER})