mappers.InlongConsumeEntityMapper.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.InlongConsumeEntityMapper"> <resultMap id="BaseResultMap" type="org.apache.inlong.manager.dao.entity.InlongConsumeEntity"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="consumer_group" jdbcType="VARCHAR" property="consumerGroup"/> <result column="description" jdbcType="VARCHAR" property="description"/> <result column="mq_type" jdbcType="VARCHAR" property="mqType"/> <result column="topic" jdbcType="VARCHAR" property="topic"/> <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/> <result column="filter_enabled" jdbcType="INTEGER" property="filterEnabled"/> <result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId"/> <result column="ext_params" jdbcType="LONGVARCHAR" property="extParams"/> <result column="tenant" jdbcType="VARCHAR" property="tenant"/> <result column="in_charges" jdbcType="VARCHAR" property="inCharges"/> <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, consumer_group, description, mq_type, topic, inlong_group_id, filter_enabled, inlong_stream_id, ext_params, tenant, in_charges, 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.InlongConsumeEntity"> insert into inlong_consume (id, consumer_group, description, mq_type, topic, inlong_group_id, filter_enabled, inlong_stream_id, ext_params, tenant, in_charges, status, previous_status, creator, modifier) values (#{id, jdbcType=INTEGER}, #{consumerGroup, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{mqType, jdbcType=VARCHAR}, #{topic, jdbcType=VARCHAR}, #{inlongGroupId, jdbcType=VARCHAR}, #{filterEnabled, jdbcType=INTEGER}, #{inlongStreamId, jdbcType=VARCHAR}, #{extParams, jdbcType=LONGVARCHAR}, #{tenant, jdbcType=VARCHAR}, #{inCharges, jdbcType=VARCHAR}, #{status, jdbcType=INTEGER}, #{previousStatus, jdbcType=INTEGER}, #{creator, jdbcType=VARCHAR}, #{modifier, jdbcType=VARCHAR}) </insert> <select id="selectById" resultMap="BaseResultMap"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select <include refid="Base_Column_List"/> from inlong_consume <where> id = #{id, jdbcType=INTEGER} <if test="_isInlongService == false"> and tenant = #{tenant,jdbcType=VARCHAR} </if> </where> </select> <select id="countByUser" resultType="org.apache.inlong.manager.pojo.common.CountInfo"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select status as `key`, count(1) as `value` from inlong_consume <where> <if test="_isInlongService == false"> tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 and (creator = #{username, jdbcType=VARCHAR} or FIND_IN_SET(#{username, jdbcType=VARCHAR}, in_charges)) </where> group by status </select> <select id="selectExists" resultType="org.apache.inlong.manager.dao.entity.InlongConsumeEntity"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select <include refid="Base_Column_List"/> from inlong_consume <where> <if test="_isInlongService == false"> tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 and consumer_group = #{consumerGroup, jdbcType=VARCHAR} and topic = #{topic, jdbcType=VARCHAR} and inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR} </where> limit 1 </select> <select id="selectByCondition" resultMap="BaseResultMap" parameterType="org.apache.inlong.manager.pojo.consume.InlongConsumePageRequest"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select <include refid="Base_Column_List"/> from inlong_consume <where> <if test="_isInlongService == false"> tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 <if test="keyword != null and keyword !=''"> and (consumer_group like CONCAT('%', #{keyword}, '%') or topic like CONCAT('%', #{keyword}, '%')) </if> <if test="consumerGroup != null and consumerGroup != ''"> and consumer_group = #{consumerGroup, jdbcType=VARCHAR} </if> <if test="mqType != null and mqType != ''"> and mq_type = #{mqType, jdbcType=VARCHAR} </if> <if test="topic != null and topic != ''"> and topic = #{topic} </if> <if test="inlongGroupId != null and inlongGroupId != ''"> and inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR} </if> <if test="status != null"> and status = #{status, jdbcType=INTEGER} </if> <if test="statusList != null and statusList.size() > 0"> and status in <foreach collection="statusList" item="status" index="index" open="(" close=")" separator=","> #{status} </foreach> </if> </where> <choose> <when test="orderField != null and orderField != '' and orderType != null and orderType != ''"> order by ${orderField} ${orderType} </when> <otherwise> order by create_time desc </otherwise> </choose> </select> <select id="selectBriefList" parameterType="org.apache.inlong.manager.pojo.consume.InlongConsumePageRequest" resultType="org.apache.inlong.manager.pojo.consume.InlongConsumeBriefInfo"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select id, consumer_group, mq_type, topic, inlong_group_id, in_charges, status, creator, modifier, create_time, modify_time from inlong_consume <where> <if test="_isInlongService == false"> tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 <if test="keyword != null and keyword !=''"> and (consumer_group like CONCAT('%', #{keyword}, '%') or topic like CONCAT('%', #{keyword}, '%')) </if> <if test="consumerGroup != null and consumerGroup != ''"> and consumer_group = #{consumerGroup, jdbcType=VARCHAR} </if> <if test="mqType != null and mqType != ''"> and mq_type = #{mqType, jdbcType=VARCHAR} </if> <if test="topic != null and topic != ''"> and topic = #{topic} </if> <if test="inlongGroupId != null and inlongGroupId != ''"> and inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR} </if> <if test="status != null"> and status = #{status, jdbcType=INTEGER} </if> <if test="statusList != null and statusList.size() > 0"> and status in <foreach collection="statusList" item="status" index="index" open="(" close=")" separator=","> #{status} </foreach> </if> </where> <choose> <when test="orderField != null and orderField != '' and orderType != null and orderType != ''"> order by ${orderField} ${orderType} </when> <otherwise> order by create_time desc </otherwise> </choose> </select> <update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.InlongConsumeEntity"> <bind name="_isInlongService" value="LoginUser.InlongService"/> update inlong_consume set consumer_group = #{consumerGroup, jdbcType=VARCHAR}, description = #{description, jdbcType=VARCHAR}, mq_type = #{mqType, jdbcType=VARCHAR}, topic = #{topic, jdbcType=VARCHAR}, inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}, filter_enabled = #{filterEnabled, jdbcType=INTEGER}, inlong_stream_id = #{inlongStreamId, jdbcType=VARCHAR}, ext_params = #{extParams, jdbcType = LONGVARCHAR}, in_charges = #{inCharges, jdbcType=VARCHAR}, previous_status = status, status = #{status, jdbcType=INTEGER}, modifier = #{modifier, jdbcType=VARCHAR}, is_deleted = #{isDeleted, jdbcType=INTEGER}, version = #{version, jdbcType=INTEGER} + 1 <where> id = #{id, jdbcType=INTEGER} <if test="_isInlongService == false"> and tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 and version = #{version, jdbcType=INTEGER} </where> </update> <update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.InlongConsumeEntity"> <bind name="_isInlongService" value="LoginUser.InlongService"/> update inlong_consume <set> <if test="consumerGroup != null"> consumer_group = #{consumerGroup, jdbcType=VARCHAR}, </if> <if test="description != null"> description = #{description,jdbcType=VARCHAR}, </if> <if test="mqType != null"> mq_type = #{mqType, jdbcType=VARCHAR}, </if> <if test="topic != null"> topic = #{topic, jdbcType=VARCHAR}, </if> <if test="inlongGroupId != null"> inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}, </if> <if test="filterEnabled != null"> filter_enabled = #{filterEnabled, jdbcType=INTEGER}, </if> <if test="inlongStreamId != null"> inlong_stream_id = #{inlongStreamId, jdbcType=VARCHAR}, </if> <if test="extParams != null"> ext_params = #{extParams, jdbcType=LONGVARCHAR}, </if> <if test="inCharges != null"> in_charges = #{inCharges, jdbcType=VARCHAR}, </if> <if test="status != null"> previous_status = status, </if> <if test="status != null"> 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} <if test="_isInlongService == false"> and tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 and version = #{version, jdbcType=INTEGER} </where> </update> <update id="updateStatus"> <bind name="_isInlongService" value="LoginUser.InlongService"/> update inlong_consume set previous_status = status, status = #{status, jdbcType=INTEGER}, modifier = #{modifier, jdbcType=VARCHAR} <where> id = #{id,jdbcType=INTEGER} <if test="_isInlongService == false"> and tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 </where> </update> <delete id="deleteById"> <bind name="_isInlongService" value="LoginUser.InlongService"/> delete from inlong_consume <where> id = #{id,jdbcType=INTEGER} <if test="_isInlongService == false"> and tenant = #{tenant,jdbcType=VARCHAR} </if> </where> </delete> <insert id="migrate"> update inlong_consume set tenant = #{targetTenant, jdbcType=VARCHAR} <where> inlong_group_id = #{groupId, jdbcType=VARCHAR} and is_deleted = 0 and tenant = #{sourceTenant, jdbcType=VARCHAR} </where> </insert> <select id="selectByGroupId" resultMap="BaseResultMap"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select <include refid="Base_Column_List"/> from inlong_consume <where> <if test="_isInlongService == false"> tenant = #{tenant,jdbcType=VARCHAR} </if> and is_deleted = 0 and inlong_group_id = #{groupId, jdbcType=VARCHAR} </where> </select> </mapper>