mappers.StreamSinkEntityMapper.xml Maven / Gradle / Ivy
The newest version!
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.apache.inlong.manager.dao.mapper.StreamSinkEntityMapper"> <resultMap id="BaseResultMap" type="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/> <result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId"/> <result column="sink_type" jdbcType="VARCHAR" property="sinkType"/> <result column="sink_name" jdbcType="VARCHAR" property="sinkName"/> <result column="description" jdbcType="VARCHAR" property="description"/> <result column="enable_create_resource" jdbcType="TINYINT" property="enableCreateResource"/> <result column="inlong_cluster_name" jdbcType="VARCHAR" property="inlongClusterName"/> <result column="data_node_name" jdbcType="VARCHAR" property="dataNodeName"/> <result column="sort_task_name" jdbcType="VARCHAR" property="sortTaskName"/> <result column="sort_consumer_group" jdbcType="VARCHAR" property="sortConsumerGroup"/> <result column="ext_params" jdbcType="VARCHAR" property="extParams"/> <result column="operate_log" jdbcType="VARCHAR" property="operateLog"/> <result column="status" jdbcType="INTEGER" property="status"/> <result column="previous_status" jdbcType="INTEGER" property="previousStatus"/> <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/> <result column="creator" jdbcType="VARCHAR" property="creator"/> <result column="modifier" jdbcType="VARCHAR" property="modifier"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/> <result column="version" jdbcType="INTEGER" property="version"/> </resultMap> <sql id="Base_Column_List"> id, inlong_group_id, inlong_stream_id, sink_type, sink_name, description, enable_create_resource, inlong_cluster_name, data_node_name, sort_task_name, sort_consumer_group, ext_params, operate_log, status, previous_status, is_deleted, creator, modifier, create_time, modify_time, version </sql> <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> insert into stream_sink (id, inlong_group_id, inlong_stream_id, sink_type, sink_name, description, enable_create_resource, inlong_cluster_name, data_node_name, sort_task_name, sort_consumer_group, ext_params, operate_log, status, previous_status, creator, modifier) values (#{id, jdbcType=INTEGER}, #{inlongGroupId, jdbcType=VARCHAR}, #{inlongStreamId, jdbcType=VARCHAR}, #{sinkType, jdbcType=VARCHAR}, #{sinkName, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{enableCreateResource, jdbcType=TINYINT}, #{inlongClusterName, jdbcType=VARCHAR}, #{dataNodeName, jdbcType=VARCHAR}, #{sortTaskName, jdbcType=VARCHAR}, #{sortConsumerGroup, jdbcType=VARCHAR}, #{extParams, jdbcType=VARCHAR}, #{operateLog, jdbcType=VARCHAR}, #{status, jdbcType=INTEGER}, #{previousStatus, jdbcType=INTEGER}, #{creator, jdbcType=VARCHAR}, #{modifier, jdbcType=VARCHAR}) </insert> <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> insert into stream_sink <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="inlongGroupId != null"> inlong_group_id, </if> <if test="inlongStreamId != null"> inlong_stream_id, </if> <if test="sinkType != null"> sink_type, </if> <if test="sinkName != null"> sink_name, </if> <if test="description != null"> description, </if> <if test="enableCreateResource != null"> enable_create_resource, </if> <if test="inlongClusterName != null"> inlong_cluster_name, </if> <if test="dataNodeName != null"> data_node_name, </if> <if test="sortTaskName != null"> sort_task_name, </if> <if test="sortConsumerGroup != null"> sort_consumer_group, </if> <if test="extParams != null"> ext_params, </if> <if test="operateLog != null"> operate_log, </if> <if test="status != null"> status, </if> <if test="previousStatus != null"> previous_status, </if> <if test="creator != null"> creator, </if> <if test="modifier != null"> modifier, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id, jdbcType=INTEGER}, </if> <if test="inlongGroupId != null"> #{inlongGroupId, jdbcType=VARCHAR}, </if> <if test="inlongStreamId != null"> #{inlongStreamId, jdbcType=VARCHAR}, </if> <if test="sinkType != null"> #{sinkType, jdbcType=VARCHAR}, </if> <if test="sinkName != null"> #{sinkName, jdbcType=VARCHAR}, </if> <if test="description != null"> #{description, jdbcType=VARCHAR}, </if> <if test="enableCreateResource != null"> #{enableCreateResource, jdbcType=TINYINT}, </if> <if test="inlongClusterName != null"> #{inlongClusterName, jdbcType=VARCHAR}, </if> <if test="dataNodeName != null"> #{dataNodeName, jdbcType=VARCHAR}, </if> <if test="sortTaskName != null"> #{sortTaskName, jdbcType=VARCHAR}, </if> <if test="sortConsumerGroup != null"> #{sortConsumerGroup, jdbcType=VARCHAR}, </if> <if test="extParams != null"> #{extParams, jdbcType=VARCHAR}, </if> <if test="operateLog != null"> #{operateLog, jdbcType=VARCHAR}, </if> <if test="status != null"> #{status, jdbcType=INTEGER}, </if> <if test="previousStatus != null"> #{previousStatus, jdbcType=INTEGER}, </if> <if test="creator != null"> #{creator, jdbcType=VARCHAR}, </if> <if test="modifier != null"> #{modifier, jdbcType=VARCHAR}, </if> </trim> </insert> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from stream_sink where id = #{id,jdbcType=INTEGER} and is_deleted = 0 </select> <select id="selectCount" resultType="java.lang.Integer"> select count(1) from stream_sink <where> is_deleted = 0 <if test="groupId != null and groupId != ''"> and inlong_group_id = #{groupId, jdbcType=VARCHAR} </if> <if test="streamId != null and streamId != ''"> and inlong_stream_id = #{streamId, jdbcType=VARCHAR} </if> </where> </select> <select id="selectByCondition" parameterType="org.apache.inlong.manager.pojo.sink.SinkPageRequest" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from stream_sink <where> is_deleted = 0 <if test="request.sinkType != null and request.sinkType != ''"> and sink_type = #{request.sinkType, jdbcType=VARCHAR} </if> and inlong_group_id = #{request.inlongGroupId, jdbcType=VARCHAR} <if test="request.inlongStreamId != null and request.inlongStreamId != ''"> and inlong_stream_id = #{request.inlongStreamId, jdbcType=VARCHAR} </if> <if test="request.keyword != null and request.keyword != ''"> and ( inlong_group_id like CONCAT('%', #{request.keyword}, '%') or inlong_stream_id like CONCAT('%', #{request.keyword}, '%') or sink_name like CONCAT('%', #{request.keyword}, '%') ) </if> <if test="request.status != null and request.status != ''"> and status = #{request.status, jdbcType=INTEGER} </if> <if test="request.statusList != null and request.statusList.size() > 0"> and status in <foreach collection="request.statusList" item="status" index="index" open="(" close=")" separator=","> #{status} </foreach> </if> <if test="request.inlongClusterName != null and request.inlongClusterName != ''"> and inlong_cluster_name = #{request.inlongClusterName, jdbcType=VARCHAR} </if> <if test="request.dataNodeName != null and request.dataNodeName != ''"> and data_node_name = #{request.dataNodeName, jdbcType=VARCHAR} </if> <if test="request.sortTaskName != null and request.sortTaskName != ''"> and sort_task_name = #{request.sortTaskName, jdbcType=VARCHAR} </if> <if test="request.sortConsumerGroup != null and request.sortConsumerGroup != ''"> and sort_consumer_group = #{request.sortConsumerGroup, jdbcType=VARCHAR} </if> </where> <choose> <when test="request.orderField != null and request.orderField != '' and request.orderType != null and request.orderType != ''"> order by ${request.orderField} ${request.orderType} </when> <otherwise> order by create_time desc </otherwise> </choose> </select> <select id="selectSummary" resultType="org.apache.inlong.manager.pojo.sink.SinkBriefInfo"> select s.id, s.inlong_group_id, s.inlong_stream_id, s.sink_type, s.sink_name from stream_sink s where s.is_deleted = 0 and s.inlong_group_id = #{groupId, jdbcType=VARCHAR} and s.inlong_stream_id = #{streamId, jdbcType=VARCHAR} </select> <select id="selectByRelatedId" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> select <include refid="Base_Column_List"/> from stream_sink <where> is_deleted = 0 and inlong_group_id = #{groupId, jdbcType=VARCHAR} <if test="streamId != null and streamId != ''"> and inlong_stream_id = #{streamId, jdbcType=VARCHAR} </if> </where> </select> <select id="selectByUniqueKey" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> select <include refid="Base_Column_List"/> from stream_sink where is_deleted = 0 and inlong_group_id = #{groupId, jdbcType=VARCHAR} and inlong_stream_id = #{streamId, jdbcType=VARCHAR} and sink_name = #{sinkName, jdbcType=VARCHAR} </select> <select id="selectByIdAndType" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> select <include refid="Base_Column_List"/> from stream_sink <where> is_deleted = 0 and inlong_group_id = #{groupId, jdbcType=VARCHAR} <if test="streamId != null and streamId != ''"> and inlong_stream_id = #{streamId, jdbcType=VARCHAR} </if> <if test="sinkType != null and sinkType != ''"> and sink_type = #{sinkType, jdbcType=VARCHAR} </if> </where> </select> <select id="selectExistsStreamId" resultType="java.lang.String"> select inlong_stream_id from stream_sink <where> inlong_group_id = #{groupId, jdbcType=VARCHAR} and sink_type = #{sinkType, jdbcType=VARCHAR} and is_deleted = 0 and inlong_stream_id in <foreach collection="streamIdList" open="(" close=")" separator="," index="index" item="item"> #{item} </foreach> </where> </select> <select id="selectSinkType" resultType="java.lang.String"> select distinct (sink_type) from stream_sink <where> is_deleted = 0 <if test="groupId != null and groupId != ''"> and inlong_group_id = #{groupId, jdbcType=VARCHAR} </if> <if test="streamId != null and streamId != ''"> and inlong_stream_id = #{streamId, jdbcType=VARCHAR} </if> </where> </select> <select id="selectAllConfig" resultType="org.apache.inlong.manager.pojo.sink.SinkInfo"> select sink.id, sink.inlong_group_id, sink.inlong_stream_id, sink.sink_type, sink.inlong_cluster_name, sink.description, sink.enable_create_resource, sink.ext_params, sink.status, sink.creator, sink.sink_name, sink.data_node_name, sink.sort_task_name, sink.sort_consumer_group, stream.mq_resource, stream.data_type, stream.data_separator as sourceSeparator, stream.data_escape_char from inlong_stream stream, stream_sink sink <where> stream.is_deleted = 0 and sink.is_deleted = 0 and stream.inlong_group_id = sink.inlong_group_id and stream.inlong_stream_id = sink.inlong_stream_id and stream.inlong_group_id = #{groupId, jdbcType=VARCHAR} <if test="idList != null and idList.size() > 0"> and stream.inlong_stream_id in <foreach collection="idList" open="(" close=")" separator="," index="index" item="item"> #{item} </foreach> </if> </where> </select> <select id="selectAllTasks" resultType="org.apache.inlong.manager.pojo.sort.standalone.SortTaskInfo"> select inlong_cluster_name as sortClusterName, sort_task_name, sort_consumer_group, sink_type, data_node_name from stream_sink where is_deleted = 0 group by inlong_cluster_name, sort_task_name, sort_consumer_group, sink_type, data_node_name </select> <select id="selectAllIdParams" resultType="org.apache.inlong.manager.pojo.sort.standalone.SortIdInfo"> select sort_task_name, inlong_group_id, inlong_stream_id, ext_params from stream_sink where is_deleted = 0 </select> <select id="selectAllStreams" resultType="org.apache.inlong.manager.pojo.sort.standalone.SortSourceStreamSinkInfo"> select inlong_cluster_name as sortClusterName, sort_task_name, inlong_group_id as groupId, inlong_stream_id as streamId, ext_params from stream_sink where is_deleted = 0 </select> <select id="selectAllStreamSinks" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> select <include refid="Base_Column_List"/> from stream_sink where is_deleted = 0 </select> <select id="selectAssignedCluster" resultType="java.lang.String"> select inlong_cluster_name from stream_sink s left join inlong_cluster c on s.inlong_cluster_name = c.name <where> s.data_node_name = #{dataNodeName, jdbcType=VARCHAR} <if test="clusterTag != null and clusterTag != ''"> and find_in_set(#{clusterTag, jdbcType=VARCHAR}, c.cluster_tags) </if> and s.is_deleted = 0 and c.is_deleted = 0 </where> group by inlong_cluster_name order by count(*) asc limit 1 </select> <update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> update stream_sink <set> <if test="inlongGroupId != null"> inlong_group_id = #{inlongGroupId,jdbcType=VARCHAR}, </if> <if test="inlongStreamId != null"> inlong_stream_id = #{inlongStreamId,jdbcType=VARCHAR}, </if> <if test="description != null"> description = #{description,jdbcType=VARCHAR}, </if> <if test="sinkType != null"> sink_type = #{sinkType,jdbcType=VARCHAR}, </if> <if test="sinkName != null"> sink_name = #{sinkName,jdbcType=VARCHAR}, </if> <if test="enableCreateResource != null"> enable_create_resource = #{enableCreateResource,jdbcType=TINYINT}, </if> <if test="inlongClusterName != null"> inlong_cluster_name = #{inlongClusterName,jdbcType=VARCHAR}, </if> <if test="dataNodeName != null"> data_node_name = #{dataNodeName,jdbcType=VARCHAR}, </if> <if test="sortTaskName != null"> sort_task_name = #{sortTaskName,jdbcType=VARCHAR}, </if> <if test="sortConsumerGroup != null"> sort_consumer_group = #{sortConsumerGroup,jdbcType=VARCHAR}, </if> <if test="extParams != null"> ext_params = #{extParams,jdbcType=VARCHAR}, </if> <if test="operateLog != null"> operate_log = #{operateLog,jdbcType=VARCHAR}, </if> <if test="status != null"> previous_status = status, status = #{status,jdbcType=INTEGER}, </if> <if test="isDeleted != null"> is_deleted = #{isDeleted,jdbcType=INTEGER}, </if> <if test="modifier != null"> modifier = #{modifier,jdbcType=VARCHAR}, </if> version = #{version,jdbcType=INTEGER} + 1 </set> where id = #{id,jdbcType=INTEGER} and version = #{version,jdbcType=INTEGER} </update> <update id="updateStatus" parameterType="org.apache.inlong.manager.dao.entity.StreamSinkEntity"> update stream_sink set status = #{status,jdbcType=INTEGER}, previous_status = status, operate_log = #{operateLog,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> <delete id="deleteById" parameterType="java.lang.Integer"> delete from stream_sink where id = #{id,jdbcType=INTEGER} </delete> <delete id="deleteByInlongGroupIds"> delete from stream_sink where inlong_group_id in <foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=","> #{item} </foreach> </delete> </mapper>