All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mappers.ConsumptionEntityMapper.xml Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show 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.ConsumptionEntityMapper">
    <resultMap id="BaseResultMap" type="org.apache.inlong.manager.dao.entity.ConsumptionEntity">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="consumer_group" jdbcType="VARCHAR" property="consumerGroup"/>
        <result column="in_charges" jdbcType="VARCHAR" property="inCharges"/>
        <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/>
        <result column="mq_type" jdbcType="VARCHAR" property="mqType"/>
        <result column="topic" jdbcType="VARCHAR" property="topic"/>
        <result column="filter_enabled" jdbcType="INTEGER" property="filterEnabled"/>
        <result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <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="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, consumer_group, in_charges, inlong_group_id,
        mq_type, topic, filter_enabled, inlong_stream_id,
        status, is_deleted, creator, modifier, create_time, modify_time
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from consumption
        where id = #{id,jdbcType=INTEGER} and is_deleted = 0
    </select>
    <select id="selectConsumptionExists" resultType="org.apache.inlong.manager.dao.entity.ConsumptionEntity">
        select
        <include refid="Base_Column_List"/>
        from consumption
        where inlong_group_id = #{groupId, jdbcType=VARCHAR}
        and topic = #{topic, jdbcType=VARCHAR}
        and consumer_group = #{consumerGroup, jdbcType=VARCHAR}
        and is_deleted = 0
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        update consumption
        set is_deleted = id
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
            parameterType="org.apache.inlong.manager.dao.entity.ConsumptionEntity">
        insert into consumption (id, consumer_group, in_charges,
                                 inlong_group_id, mq_type, topic,
                                 filter_enabled, inlong_stream_id,
                                 status, is_deleted,
                                 creator, modifier,
                                 create_time, modify_time)
        values (#{id,jdbcType=INTEGER}, #{consumerGroup,jdbcType=VARCHAR}, #{inCharges,jdbcType=VARCHAR},
                #{inlongGroupId,jdbcType=VARCHAR}, #{mqType,jdbcType=VARCHAR}, #{topic,jdbcType=VARCHAR},
                #{filterEnabled,jdbcType=INTEGER}, #{inlongStreamId,jdbcType=VARCHAR},
                #{status,jdbcType=INTEGER}, #{isDeleted,jdbcType=INTEGER},
                #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR},
                #{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
            parameterType="org.apache.inlong.manager.dao.entity.ConsumptionEntity">
        insert into consumption
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="consumerGroup != null">
                consumer_group,
            </if>
            <if test="inCharges != null">
                in_charges,
            </if>
            <if test="inlongGroupId != null">
                inlong_group_id,
            </if>
            <if test="mqType != null">
                mq_type,
            </if>
            <if test="topic != null">
                topic,
            </if>
            <if test="filterEnabled != null">
                filter_enabled,
            </if>
            <if test="inlongStreamId != null">
                inlong_stream_id,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="modifier != null">
                modifier,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="modifyTime != null">
                modify_time,
            </if>
            <if test="isDeleted != null">
                is_deleted,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="consumerGroup != null">
                #{consumerGroup,jdbcType=VARCHAR},
            </if>
            <if test="inCharges != null">
                #{inCharges,jdbcType=VARCHAR},
            </if>
            <if test="inlongGroupId != null">
                #{inlongGroupId,jdbcType=VARCHAR},
            </if>
            <if test="mqType != null">
                #{mqType,jdbcType=VARCHAR},
            </if>
            <if test="topic != null">
                #{topic,jdbcType=VARCHAR},
            </if>
            <if test="filterEnabled != null">
                #{filterEnabled,jdbcType=INTEGER},
            </if>
            <if test="inlongStreamId != null">
                #{inlongStreamId,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="creator != null">
                #{creator,jdbcType=VARCHAR},
            </if>
            <if test="modifier != null">
                #{modifier,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyTime != null">
                #{modifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="isDeleted != null">
                #{isDeleted,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective"
            parameterType="org.apache.inlong.manager.dao.entity.ConsumptionEntity">
        update consumption
        <set>
            <if test="consumerGroup != null">
                consumer_group = #{consumerGroup,jdbcType=VARCHAR},
            </if>
            <if test="inCharges != null">
                in_charges = #{inCharges,jdbcType=VARCHAR},
            </if>
            <if test="inlongGroupId != null">
                inlong_group_id = #{inlongGroupId,jdbcType=VARCHAR},
            </if>
            <if test="mqType != null">
                mq_type = #{mqType,jdbcType=VARCHAR},
            </if>
            <if test="topic != null">
                topic = #{topic,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="status != null">
                status = #{status,jdbcType=INTEGER},
            </if>
            <if test="creator != null">
                creator = #{creator,jdbcType=VARCHAR},
            </if>
            <if test="modifier != null">
                modifier = #{modifier,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyTime != null">
                modify_time = #{modifyTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER} and is_deleted=0
    </update>
    <update id="updateByPrimaryKey" parameterType="org.apache.inlong.manager.dao.entity.ConsumptionEntity">
        update consumption
        set consumer_group   = #{consumerGroup,jdbcType=VARCHAR},
            in_charges       = #{inCharges,jdbcType=VARCHAR},
            inlong_group_id  = #{inlongGroupId,jdbcType=VARCHAR},
            mq_type          = #{mqType,jdbcType=VARCHAR},
            topic            = #{topic,jdbcType=VARCHAR},
            filter_enabled   = #{filterEnabled,jdbcType=INTEGER},
            inlong_stream_id = #{inlongStreamId,jdbcType=VARCHAR},
            status           = #{status,jdbcType=INTEGER},
            creator          = #{creator,jdbcType=VARCHAR},
            modifier         = #{modifier,jdbcType=VARCHAR},
            create_time      = #{createTime,jdbcType=TIMESTAMP},
            modify_time      = #{modifyTime,jdbcType=TIMESTAMP},
            is_deleted       = #{isDeleted,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
          and is_deleted = 0
    </update>

    <select id="listByQuery"
            parameterType="org.apache.inlong.manager.common.pojo.consumption.ConsumptionQuery"
            resultMap="BaseResultMap">
        select
        c.*
        from consumption c
        where c.is_deleted=0
        <if test="consumerGroup != null and consumerGroup != ''">
            and c.consumer_group = #{consumerGroup,jdbcType=VARCHAR}
        </if>
        <if test="inlongGroupId != null and inlongGroupId != ''">
            and c.inlong_group_id = #{inlongGroupId,jdbcType=VARCHAR}
        </if>
        <if test="mqType != null and mqType != ''">
            and c.mq_type = #{mqType,jdbcType=VARCHAR}
        </if>
        <if test="topic != null and topic != ''">
            and c.topic like CONCAT('%', #{topic}, '%')
        </if>
        <if test="filterEnabled != null">
            and c.filter_enabled = #{filterEnabled,jdbcType=INTEGER}
        </if>
        <if test="inlongStreamId != null and inlongStreamId != ''">
            and c.inlong_stream_id = #{inlongStreamId,jdbcType=VARCHAR}
        </if>
        <if test="status != null">
            and c.status = #{status,jdbcType=INTEGER}
        </if>
        <if test="creator != null and creator != ''">
            and c.creator = #{creator,jdbcType=VARCHAR}
        </if>
        <if test="modifier != null and modifier != ''">
            and c.modifier = #{modifier,jdbcType=VARCHAR}
        </if>
        <if test="isAdminRole == false">
            and (
            FIND_IN_SET(#{userName,jdbcType=VARCHAR},c.in_charges)
            or c.creator = #{userName,jdbcType=VARCHAR}
            )
        </if>
        <if test="keyword != null and keyword !=''">
            and (c.topic like CONCAT('%', #{keyword}, '%') or c.consumer_group like CONCAT('%', #{keyword}, '%'))
        </if>
        <if test="lastConsumptionStatus != null and lastConsumptionStatus != 3">
            and cas.latest_record_state = #{lastConsumptionStatus, jdbcType=INTEGER}
        </if>
        <if test="lastConsumptionStatus != null and lastConsumptionStatus == 3">
            and (cas.latest_record_state = #{lastConsumptionStatus, jdbcType=INTEGER}
            or cas.latest_record_state is null)
        </if>
        order by id desc
    </select>

    <select id="countByQuery"
            parameterType="org.apache.inlong.manager.common.pojo.consumption.ConsumptionQuery"
            resultType="org.apache.inlong.manager.common.pojo.common.CountInfo">
        select status as `key`, count(1) as value
        from consumption
        where is_deleted=0
        <if test="consumerGroup != null and consumerGroup != ''">
            and consumer_group = #{consumerGroup,jdbcType=VARCHAR}
        </if>
        <if test="inCharges != null and inCharges != ''">
            and FIND_IN_SET(#{inCharges,jdbcType=VARCHAR},in_charges)
        </if>
        <if test="inlongGroupId != null and inlongGroupId != ''">
            and inlong_group_id = #{inlongGroupId,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,jdbcType=VARCHAR}
        </if>
        <if test="filterEnabled != null">
            and filter_enabled = #{filterEnabled,jdbcType=INTEGER}
        </if>
        <if test="inlongStreamId != null and inlongStreamId != ''">
            and inlong_stream_id = #{inlongStreamId,jdbcType=VARCHAR}
        </if>
        <if test="status != null">
            and status = #{status,jdbcType=INTEGER}
        </if>
        <if test="creator != null and creator != ''">
            and creator = #{creator,jdbcType=VARCHAR}
        </if>
        <if test="modifier != null and modifier != ''">
            and modifier = #{modifier,jdbcType=VARCHAR}
        </if>
        <if test="userName != null and userName !=''">
            and (
            FIND_IN_SET(#{userName,jdbcType=VARCHAR},in_charges)
            or creator = #{userName,jdbcType=VARCHAR}
            )
        </if>
        <if test="keyword != null and keyword !=''">
            and ( topic like CONCAT('%', #{keyword}, '%') or consumer_group like CONCAT('%', #{keyword}, '%') )
        </if>
        group by status
    </select>
</mapper>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy