mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-19 00:37:08 +00:00
(improvement)(headless) add tag logic (#831)
This commit is contained in:
@@ -2,129 +2,132 @@
|
||||
<!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.TagCustomMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tencent.supersonic.headless.server.persistence.dataobject.TagDO">
|
||||
<resultMap id="BaseTagDO" type="com.tencent.supersonic.headless.server.persistence.dataobject.TagDO">
|
||||
<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="item_id" jdbcType="BIGINT" property="itemId" />
|
||||
<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="define_type" jdbcType="VARCHAR" property="defineType" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.headless.server.persistence.dataobject.TagDO">
|
||||
<result column="type_params" jdbcType="LONGVARCHAR" property="typeParams" />
|
||||
|
||||
<resultMap id="TagResp" type="com.tencent.supersonic.headless.api.pojo.response.TagResp">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="domain_id" jdbcType="BIGINT" property="domainId" />
|
||||
<result column="domain_name" jdbcType="VARCHAR" property="domainName" />
|
||||
<result column="model_id" jdbcType="BIGINT" property="modelId" />
|
||||
<result column="model_name" jdbcType="VARCHAR" property="modelName" />
|
||||
<result column="tag_object_id" jdbcType="BIGINT" property="tagObjectId" />
|
||||
<result column="tag_object_name" jdbcType="VARCHAR" property="tagObjectName" />
|
||||
<result column="tag_define_type" jdbcType="VARCHAR" property="tagDefineType" />
|
||||
<result column="item_id" jdbcType="VARCHAR" property="itemId" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
|
||||
<select id="getTagDOList" resultMap="BaseTagDO">
|
||||
select * from s2_tag
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and
|
||||
#{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem"
|
||||
open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
<if test="itemIds != null and itemIds.size >0">
|
||||
and item_id in
|
||||
<foreach collection="itemIds" index="index" item="itemId" open="(" close=")"
|
||||
separator=",">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="ids != null and ids.size >0">
|
||||
and id in
|
||||
<foreach collection="ids" index="index" item="tagId" open="(" close=")"
|
||||
separator=",">
|
||||
#{tagId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="tagDefineType != null">
|
||||
and tag_define_type = #{tagDefineType}
|
||||
</if>
|
||||
</where>
|
||||
</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, define_type
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
type_params
|
||||
</sql>
|
||||
</select>
|
||||
|
||||
<select id="queryTagRespList" resultMap="TagResp">
|
||||
select * from (
|
||||
select s2_tag.id as id, s2_dimension.model_id as model_id, "DIMENSION" as tag_define_type, s2_dimension.id as item_id,
|
||||
s2_dimension.name as name, s2_dimension.biz_name as biz_name, s2_dimension.description as description, s2_tag.updated_at as updated_at
|
||||
from s2_tag join s2_dimension
|
||||
on s2_tag.item_id = s2_dimension.id
|
||||
where s2_dimension.status=1
|
||||
union
|
||||
select s2_tag.id as id, s2_metric.model_id as model_id, "METRIC" as tag_define_type, s2_metric.id as item_id,
|
||||
s2_metric.name as name, s2_metric.biz_name as biz_name, s2_metric.description as description, s2_tag.updated_at as updated_at
|
||||
from s2_tag join s2_metric
|
||||
on s2_tag.item_id = s2_metric.id
|
||||
where s2_metric.status=1
|
||||
)t
|
||||
<where>
|
||||
<if test="tagDefineType != null">
|
||||
and tag_define_type = #{tagDefineType}
|
||||
</if>
|
||||
<if test="itemIds != null and itemIds.size >0">
|
||||
and item_id in
|
||||
<foreach collection="itemIds" index="index" item="itemId" open="(" close=")"
|
||||
separator=",">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="ids != null and ids.size >0">
|
||||
and id in
|
||||
<foreach collection="ids" index="index" item="tagId" open="(" close=")"
|
||||
separator=",">
|
||||
#{tagId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name}
|
||||
</if>
|
||||
<if test="bizName != null and bizName != ''">
|
||||
and biz_Name = #{bizName}
|
||||
</if>
|
||||
<if test="modelIds != null and modelIds.size >0">
|
||||
and model_id in
|
||||
<foreach collection="modelIds" index="index" item="modelId" open="(" close=")"
|
||||
separator=",">
|
||||
#{modelId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="key != null and key != ''">
|
||||
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},'%'))
|
||||
</if>
|
||||
</where>
|
||||
order by updated_at desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="query" resultMap="ResultMapWithBLOBs">
|
||||
select *
|
||||
from s2_tag
|
||||
where status != 3
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="tagDefineType != null">
|
||||
and define_type = #{tagDefineType}
|
||||
</if>
|
||||
<if test="key != null and key != ''">
|
||||
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},'%'))
|
||||
</if>
|
||||
<if test="id != null">
|
||||
and id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<if test="name != null and name != '' ">
|
||||
and name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<if test="bizName != null and bizName != ''">
|
||||
and biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<if test="sensitiveLevel != null">
|
||||
and sensitive_level = #{sensitiveLevel}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="modelIds != null and modelIds.size >0">
|
||||
and model_id in
|
||||
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
|
||||
<delete id="deleteById">
|
||||
delete from s2_tag where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBatch">
|
||||
delete from s2_tag
|
||||
where type = #{type}
|
||||
<if test="itemIds != null and itemIds.size >0">
|
||||
and item_id in
|
||||
<foreach collection="itemIds" index="index" item="itemId" open="(" close=")"
|
||||
separator=",">
|
||||
#{model}
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="ids != null and ids.size >0">
|
||||
and id in
|
||||
<foreach collection="ids" index="index" item="id" open="(" close=")"
|
||||
<foreach collection="ids" index="index" item="tagId" open="(" close=")"
|
||||
separator=",">
|
||||
#{id}
|
||||
#{tagId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="bizNames != null and bizNames.size >0">
|
||||
and biz_name in
|
||||
<foreach collection="bizNames" index="index" item="bizName" open="(" close=")"
|
||||
separator=",">
|
||||
#{bizName}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateStatus" parameterType="java.util.List">
|
||||
<foreach collection="list" item="tag" separator=";">
|
||||
update s2_tag
|
||||
set status = #{tag.status,jdbcType=INTEGER},
|
||||
updated_at = #{tag.updatedAt,jdbcType=TIMESTAMP},
|
||||
updated_by = #{tag.updatedBy,jdbcType=VARCHAR}
|
||||
where id = #{tag.id,jdbcType=BIGINT}
|
||||
</foreach>
|
||||
</update>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user