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

mappers.InlongGroupEntityMapper.xml Maven / Gradle / Ivy

<?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.InlongGroupEntityMapper">
    <resultMap id="BaseResultMap" type="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="tenant" jdbcType="VARCHAR" property="tenant"/>
        <result column="mq_type" jdbcType="VARCHAR" property="mqType"/>
        <result column="mq_resource" jdbcType="VARCHAR" property="mqResource"/>
        <result column="daily_records" jdbcType="INTEGER" property="dailyRecords"/>
        <result column="daily_storage" jdbcType="INTEGER" property="dailyStorage"/>
        <result column="peak_records" jdbcType="INTEGER" property="peakRecords"/>
        <result column="max_length" jdbcType="INTEGER" property="maxLength"/>
        <result column="enable_zookeeper" jdbcType="INTEGER" property="enableZookeeper"/>
        <result column="enable_create_resource" jdbcType="INTEGER" property="enableCreateResource"/>
        <result column="inlong_group_mode" jdbcType="INTEGER" property="inlongGroupMode"/>
        <result column="data_report_type" jdbcType="INTEGER" property="dataReportType"/>
        <result column="inlong_cluster_tag" jdbcType="VARCHAR" property="inlongClusterTag"/>
        <result column="ext_params" jdbcType="LONGVARCHAR" property="extParams"/>

        <result column="in_charges" jdbcType="VARCHAR" property="inCharges"/>
        <result column="followers" jdbcType="VARCHAR" property="followers"/>
        <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>

    <resultMap id="statusCountMap" type="java.util.Map">
        <result column="status" property="status" jdbcType="INTEGER"/>
        <result column="total" property="count" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, inlong_group_id, name, description, tenant, mq_type, mq_resource, daily_records, daily_storage,
        peak_records, max_length, enable_zookeeper, enable_create_resource, inlong_group_mode, data_report_type,
        inlong_cluster_tag, ext_params, in_charges, followers, 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.InlongGroupEntity">
        insert into inlong_group
        <trim prefix="(" suffix=")" suffixOverrides="," >
            tenant,
            <if test="id != null">
                id,
            </if>
            <if test="inlongGroupId != null and inlongGroupId != ''">
                inlong_group_id,
            </if>
            <if test="name != null and name != ''">
                name,
            </if>
            <if test="description != null and description != ''">
                description,
            </if>
            <if test="mqType != null and mqType != ''">
                mq_type,
            </if>
            <if test="mqResource != null and mqResource != ''">
                mq_resource,
            </if>
            <if test="dailyRecords != null">
                daily_records,
            </if>
            <if test="dailyStorage != null">
                daily_storage,
            </if>
            <if test="peakRecords != null">
                peak_records,
            </if>
            <if test="maxLength != null">
                max_length,
            </if>
            <if test="enableZookeeper != null">
                enable_zookeeper,
            </if>
            <if test="enableCreateResource != null">
                enable_create_resource,
            </if>
            <if test="inlongGroupMode != null">
                inlong_group_mode,
            </if>
            <if test="dataReportType != null">
                data_report_type,
            </if>
            <if test="inlongClusterTag != null and inlongClusterTag != ''">
                inlong_cluster_tag,
            </if>
            <if test="extParams != null and extParams != ''">
                ext_params,
            </if>
            <if test="inCharges != null and inCharges != ''">
                in_charges,
            </if>
            <if test="followers != null and followers != ''">
                followers,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="previousStatus != null">
                previous_status,
            </if>
            <if test="creator != null and creator != ''">
                creator,
            </if>
            <if test="modifier != null and modifier != ''">
                modifier
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            #{tenant,jdbcType=VARCHAR},
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="inlongGroupId != null and inlongGroupId != ''">
                #{inlongGroupId,jdbcType=VARCHAR},
            </if>
            <if test="name != null and name != ''">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="description != null and description != ''">
                #{description,jdbcType=VARCHAR},
            </if>
            <if test="mqType != null and mqType != ''">
                #{mqType,jdbcType=VARCHAR},
            </if>
            <if test="mqResource != null and mqResource != ''">
                #{mqResource,jdbcType=VARCHAR},
            </if>
            <if test="dailyRecords != null">
                #{dailyRecords,jdbcType=INTEGER},
            </if>
            <if test="dailyStorage != null">
                #{dailyStorage,jdbcType=INTEGER},
            </if>
            <if test="peakRecords != null">
                #{peakRecords,jdbcType=INTEGER},
            </if>
            <if test="maxLength != null">
                #{maxLength,jdbcType=INTEGER},
            </if>
            <if test="enableZookeeper != null">
                #{enableZookeeper,jdbcType=INTEGER},
            </if>
            <if test="enableCreateResource != null">
                #{enableCreateResource,jdbcType=INTEGER},
            </if>
            <if test="inlongGroupMode != null">
                #{inlongGroupMode,jdbcType=INTEGER},
            </if>
            <if test="dataReportType != null">
                #{dataReportType,jdbcType=INTEGER},
            </if>
            <if test="inlongClusterTag != null and inlongClusterTag != ''">
                #{inlongClusterTag,jdbcType=VARCHAR},
            </if>
            <if test="extParams != null and extParams != ''">
                #{extParams,jdbcType=LONGVARCHAR},
            </if>
            <if test="inCharges != null and inCharges != ''">
                #{inCharges,jdbcType=VARCHAR},
            </if>
            <if test="followers != null and followers != ''">
                #{followers,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="previousStatus != null">
                #{previousStatus,jdbcType=INTEGER},
            </if>
            <if test="creator != null and creator != ''">
                #{creator,jdbcType=VARCHAR},
            </if>
            <if test="modifier != null and modifier != ''">
                #{modifier,jdbcType=VARCHAR}
            </if>
        </trim>
    </insert>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            id = #{id,jdbcType=INTEGER}
            <if test="_isInlongService == false">
                and tenant = #{tenant,jdbcType=VARCHAR}
            </if>
        </where>
    </select>
    <select id="countGroupByUser" resultMap="statusCountMap">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select count(*) as total, status
        from inlong_group
        <where>
            <if test="_isInlongService == false">
                tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and is_deleted = 0
            <if test="inlongGroupMode != null">
                and inlong_group_mode = #{inlongGroupMode,jdbcType=TINYINT}
            </if>
            and (creator = #{username,jdbcType=VARCHAR} or find_in_set(#{username,jdbcType=VARCHAR}, in_charges))
        </where>
        group by status
    </select>
    <select id="selectByGroupId" resultMap="BaseResultMap">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            inlong_group_id = #{groupId, jdbcType=VARCHAR}
            and is_deleted = 0
            <if test="_isInlongService == false">
                and tenant = #{tenant,jdbcType=VARCHAR}
            </if>
        </where>
    </select>
    <select id="selectByGroupIdWithoutTenant" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            inlong_group_id = #{groupId, jdbcType=VARCHAR}
            and is_deleted = 0
        </where>
    </select>
    <select id="selectByGroupIdForUpdate" resultMap="BaseResultMap">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            inlong_group_id = #{groupId, jdbcType=VARCHAR}
            and is_deleted = 0
            <if test="_isInlongService == false">
                and tenant = #{tenant,jdbcType=VARCHAR}
            </if>
        </where>
         for update
    </select>
    <select id="selectByCondition" resultMap="BaseResultMap"
            parameterType="org.apache.inlong.manager.pojo.group.InlongGroupPageRequest">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            <if test="_isInlongService == false">
                tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and is_deleted = 0
            <if test="keyword != null and keyword != ''">
                and (inlong_group_id like CONCAT('%',#{keyword},'%') or name like CONCAT('%',#{keyword},'%'))
            </if>
            <if test="groupIdList != null and groupIdList.size() > 0">
                and inlong_group_id in
                <foreach collection="groupIdList" item="inlongGroupId" index="index" open="(" close=")" separator=",">
                    #{inlongGroupId}
                </foreach>
            </if>
            <if test="mqType != null and mqType != ''">
                and mq_type = #{mqType, jdbcType=VARCHAR}
            </if>
            <if test="status != null and status != ''">
                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>
            <if test="clusterTagList != null and clusterTagList.size() > 0">
                and inlong_cluster_tag in
                <foreach collection="clusterTagList" item="tag" index="index" open="(" close=")" separator=",">
                    #{tag}
                </foreach>
            </if>
            <if test="inlongGroupMode != null">
                and inlong_group_mode = #{inlongGroupMode,jdbcType=TINYINT}
            </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.group.InlongGroupPageRequest"
            resultType="org.apache.inlong.manager.pojo.group.InlongGroupBriefInfo">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select id, inlong_group_id, name, mq_type, mq_resource, inlong_cluster_tag, ext_params,
               in_charges, status, creator, modifier, create_time, modify_time
        from inlong_group
        <where>
            <if test="_isInlongService == false">
            tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and is_deleted = 0
            <if test="mqType != null and mqType != ''">
                and mq_type = #{mqType, jdbcType=VARCHAR}
            </if>
            <if test="status != null and status != ''">
                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>
            <if test="clusterTagList != null and clusterTagList.size() > 0">
                and inlong_cluster_tag in
                <foreach collection="clusterTagList" item="tag" index="index" open="(" close=")" separator=",">
                    #{tag}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectByTopicRequest" resultType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            <if test="_isInlongService == false">
            tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and is_deleted = 0
            <if test="groupIdList != null and groupIdList.size() > 0">
                and inlong_group_id in
                <foreach collection="groupIdList" item="inlongGroupId" index="index" open="(" close=")" separator=",">
                    #{inlongGroupId}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectByInlongGroupIds" resultType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            inlong_group_id in
            <foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </where>
    </select>
    <select id="selectByClusterTag" resultType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            <if test="_isInlongService == false">
                tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and is_deleted = 0
            and inlong_cluster_tag = #{inlongClusterTag, jdbcType=VARCHAR}
        </where>
        limit 10
    </select>
    <select id="selectByClusterTagWithoutTenant" resultType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            and is_deleted = 0
            and inlong_cluster_tag = #{inlongClusterTag, jdbcType=VARCHAR}
        </where>
    </select>
    <select id="selectAllGroups" resultType="org.apache.inlong.manager.pojo.sort.standalone.SortSourceGroupInfo">
        select inlong_group_id    as groupId,
               inlong_cluster_tag as clusterTag,
               mq_resource        as mqResource,
               ext_params         as extParams,
               mq_type            as mqType
        from inlong_group
        <where>
            and is_deleted = 0
        </where>
    </select>
    <select id="selectDeletedGroupIdsWithTimeBefore" resultType="java.lang.String">
        select inlong_group_id
        from inlong_group
        where modify_time &lt;= #{timeBefore, jdbcType=TIMESTAMP}
        group by inlong_group_id
        having min(is_deleted) > 0
        limit #{limit, jdbcType=INTEGER}
    </select>
    <select id="selectDeletedGroupIdsWithTimeAfter" resultType="java.lang.String">
        select inlong_group_id
        from inlong_group
        where modify_time >= #{timeAfter, jdbcType=TIMESTAMP}
        group by inlong_group_id
        having min(is_deleted) > 0
        limit #{limit, jdbcType=INTEGER}
    </select>

    <update id="updateByPrimaryKey" parameterType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        update inlong_group
        set inlong_group_id        = #{inlongGroupId,jdbcType=VARCHAR},
            name                   = #{name,jdbcType=VARCHAR},
            description            = #{description,jdbcType=VARCHAR},
            mq_type                = #{mqType,jdbcType=VARCHAR},
            mq_resource            = #{mqResource,jdbcType=VARCHAR},
            daily_records          = #{dailyRecords,jdbcType=INTEGER},
            daily_storage          = #{dailyStorage,jdbcType=INTEGER},
            peak_records           = #{peakRecords,jdbcType=INTEGER},
            max_length             = #{maxLength,jdbcType=INTEGER},

            enable_zookeeper       = #{enableZookeeper,jdbcType=INTEGER},
            enable_create_resource = #{enableCreateResource,jdbcType=INTEGER},
            inlong_group_mode      = #{inlongGroupMode,jdbcType=INTEGER},
            data_report_type       = #{dataReportType,jdbcType=INTEGER},
            inlong_cluster_tag     = #{inlongClusterTag,jdbcType=VARCHAR},

            ext_params             = #{extParams,jdbcType=LONGVARCHAR},
            in_charges             = #{inCharges,jdbcType=VARCHAR},
            followers              = #{followers,jdbcType=VARCHAR},
            previous_status        = status,
            status                 = #{status,jdbcType=INTEGER},
            is_deleted             = #{isDeleted,jdbcType=INTEGER},
            modifier               = #{modifier,jdbcType=VARCHAR},
            version                = #{version,jdbcType=INTEGER} + 1
        <where>
            <if test="_isInlongService == false">
                tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and id = #{id,jdbcType=INTEGER}
            and version = #{version,jdbcType=INTEGER}
        </where>
    </update>
    <update id="updateByIdentifierSelective" parameterType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        update inlong_group
        <set>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                description = #{description,jdbcType=VARCHAR},
            </if>
            <if test="mqType != null">
                mq_type = #{mqType,jdbcType=VARCHAR},
            </if>
            <if test="mqResource != null">
                mq_resource = #{mqResource,jdbcType=VARCHAR},
            </if>
            <if test="dailyRecords != null">
                daily_records = #{dailyRecords,jdbcType=INTEGER},
            </if>
            <if test="dailyStorage != null">
                daily_storage = #{dailyStorage,jdbcType=INTEGER},
            </if>
            <if test="peakRecords != null">
                peak_records = #{peakRecords,jdbcType=INTEGER},
            </if>
            <if test="maxLength != null">
                max_length = #{maxLength,jdbcType=INTEGER},
            </if>
            <if test="enableZookeeper != null">
                enable_zookeeper = #{enableZookeeper,jdbcType=INTEGER},
            </if>
            <if test="enableCreateResource != null">
                enable_create_resource = #{enableCreateResource,jdbcType=INTEGER},
            </if>
            <if test="inlongGroupMode != null">
                inlong_group_mode = #{inlongGroupMode,jdbcType=INTEGER},
            </if>
            <if test="dataReportType != null">
                data_report_type = #{dataReportType,jdbcType=INTEGER},
            </if>
            <if test="inlongClusterTag != null">
                inlong_cluster_tag = #{inlongClusterTag,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="followers != null">
                followers = #{followers,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>
            inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}
            <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_group
        set previous_status = status,
            status          = #{status, jdbcType=INTEGER},
            modifier        = #{modifier, jdbcType=VARCHAR}
        <where>
            inlong_group_id = #{groupId, jdbcType=VARCHAR}
            <if test="_isInlongService == false">
                and tenant = #{tenant,jdbcType=VARCHAR}
            </if>
            and is_deleted = 0
        </where>
    </update>
    <update id="migrate">
        update inlong_group
        set tenant = #{targetTenant, jdbcType=VARCHAR}
        <where>
            inlong_group_id = #{groupId, jdbcType=VARCHAR}
            and is_deleted = 0
            and tenant = #{sourceTenant, jdbcType=VARCHAR}
        </where>
    </update>
    <delete id="deleteByPrimaryKey">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        delete
        from inlong_group
        <where>
            id = #{id,jdbcType=INTEGER}
            <if test="_isInlongService == false">
                and tenant = #{tenant,jdbcType=VARCHAR}
            </if>
        </where>
    </delete>
    <delete id="deleteByInlongGroupIds">
        <bind name="_isInlongService" value="LoginUser.InlongService"/>
        delete
        from inlong_group
        <where>
            inlong_group_id in
            <foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=",">
                #{item}
            </foreach>
            <if test="_isInlongService == false">
                and tenant = #{tenant,jdbcType=VARCHAR}
            </if>
        </where>
    </delete>
    <select id="selectAllGroupsByTenant" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from inlong_group
        <where>
            tenant = #{tenant,jdbcType=VARCHAR}
            and is_deleted = 0
        </where>
    </select>
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy