(improvement)(chat) Adding the Metric API to Headless. (#738)

This commit is contained in:
lexluo09
2024-02-22 20:42:07 +08:00
committed by GitHub
parent 417a43dee8
commit 16643e8d75
31 changed files with 587 additions and 172 deletions

View File

@@ -167,4 +167,40 @@
</select>
<select id="queryDimensions" resultMap="ResultMapWithBLOBs">
select *
from s2_dimension
where status != 3
<if test="modelIds != null and modelIds.size >0">
and model_id in
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
separator=",">
#{model}
</foreach>
</if>
<if test="dimensionIds != null and dimensionIds.size >0">
and id in
<foreach collection="dimensionIds" index="index" item="dimensionId" open="(" close=")"
separator=",">
#{dimensionId}
</foreach>
</if>
<if test="dimensionNames != null and dimensionNames.size > 0">
AND (
(name IN
<foreach collection="dimensionNames" index="index" item="dimensionName" open="(" close=")"
separator=",">
#{dimensionName}
</foreach>)
OR
(biz_name IN
<foreach collection="dimensionNames" index="index" item="dimensionName" open="(" close=")"
separator=",">
#{dimensionName}
</foreach>)
)
</if>
</select>
</mapper>

View File

@@ -2,27 +2,29 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.headless.server.persistence.mapper.MetricDOCustomMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.headless.server.persistence.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" />
<result column="define_type" jdbcType="VARCHAR" property="defineType" />
<resultMap id="BaseResultMap"
type="com.tencent.supersonic.headless.server.persistence.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"/>
<result column="define_type" jdbcType="VARCHAR" property="defineType"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.headless.server.persistence.dataobject.MetricDO">
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams" />
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
type="com.tencent.supersonic.headless.server.persistence.dataobject.MetricDO">
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
@@ -56,14 +58,16 @@
</where>
</sql>
<sql id="Base_Column_List">
id, model_id, name, biz_name, description, status, sensitive_level, type, created_at,
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, define_type
</sql>
<sql id="Blob_Column_List">
type_params
</sql>
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true"
keyProperty="id">
insert into s2_metric (model_id, name,
biz_name, description, type,status,sensitive_level,
created_at, created_by, updated_at,
@@ -94,9 +98,9 @@
</update>
<select id="query" resultMap="ResultMapWithBLOBs">
select *
from s2_metric
where status != 3
select *
from s2_metric
where status != 3
<if test="type != null and type != ''">
and type = #{type}
</if>
@@ -126,14 +130,14 @@
<if test="modelIds != null and modelIds.size >0">
and model_id in
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
separator=",">
separator=",">
#{model}
</foreach>
</if>
<if test="ids != null and ids.size >0">
and id in
<foreach collection="ids" index="index" item="id" open="(" close=")"
separator=",">
separator=",">
#{id}
</foreach>
</if>
@@ -142,4 +146,40 @@
</if>
</select>
<select id="queryMetrics" resultMap="ResultMapWithBLOBs">
select *
from s2_metric
where status != 3
<if test="modelIds != null and modelIds.size >0">
and model_id in
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
separator=",">
#{model}
</foreach>
</if>
<if test="metricIds != null and metricIds.size >0">
and id in
<foreach collection="metricIds" index="index" item="metricId" open="(" close=")"
separator=",">
#{metricId}
</foreach>
</if>
<if test="metricNames != null and metricNames.size > 0">
AND (
(name IN
<foreach collection="metricNames" index="index" item="metricName" open="(" close=")"
separator=",">
#{metricName}
</foreach>)
OR
(biz_name IN
<foreach collection="metricNames" index="index" item="metricName" open="(" close=")"
separator=",">
#{metricName}
</foreach>)
)
</if>
</select>
</mapper>