<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bailuntec.mapper.DcBaseQueueMapper">
    <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="type" jdbcType="VARCHAR" property="type"/>
        <result column="message" jdbcType="VARCHAR" property="message"/>
        <result column="submit_date" jdbcType="TIMESTAMP" property="submitDate"/>
        <result column="consume_date" jdbcType="TIMESTAMP" property="consumeDate"/>
        <result column="error_message" jdbcType="VARCHAR" property="errorMessage"/>
        <result column="queue_type" jdbcType="INTEGER" property="queueType"/>
    </resultMap>
    <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <result column="error_stack_trace" jdbcType="LONGVARCHAR" property="errorStackTrace"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <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>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="example.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>
        </where>
    </sql>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        id, type, message, submit_date, consume_date, error_message, queue_type
    </sql>
    <sql id="Blob_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        error_stack_trace
    </sql>
    <select id="selectByExampleWithBLOBs" parameterType="com.bailuntec.domain.example.DcBaseQueueExample" resultMap="ResultMapWithBLOBs">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        ,
        <include refid="Blob_Column_List"/>
        from dc_base_queue
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="rows != null">
            <if test="offset != null">
                limit ${offset}, ${rows}
            </if>
            <if test="offset == null">
                limit ${rows}
            </if>
        </if>
    </select>
    <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcBaseQueueExample" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from dc_base_queue
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="rows != null">
            <if test="offset != null">
                limit ${offset}, ${rows}
            </if>
            <if test="offset == null">
                limit ${rows}
            </if>
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        ,
        <include refid="Blob_Column_List"/>
        from dc_base_queue
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_base_queue
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.DcBaseQueueExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_base_queue
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_queue (id, type, message,
        submit_date, consume_date, error_message,
        queue_type, error_stack_trace)
        values (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR},
        #{submitDate,jdbcType=TIMESTAMP}, #{consumeDate,jdbcType=TIMESTAMP}, #{errorMessage,jdbcType=VARCHAR},
        #{queueType,jdbcType=INTEGER}, #{errorStackTrace,jdbcType=LONGVARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_queue
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="type != null">
                type,
            </if>
            <if test="message != null">
                message,
            </if>
            <if test="submitDate != null">
                submit_date,
            </if>
            <if test="consumeDate != null">
                consume_date,
            </if>
            <if test="errorMessage != null">
                error_message,
            </if>
            <if test="queueType != null">
                queue_type,
            </if>
            <if test="errorStackTrace != null">
                error_stack_trace,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=VARCHAR},
            </if>
            <if test="message != null">
                #{message,jdbcType=VARCHAR},
            </if>
            <if test="submitDate != null">
                #{submitDate,jdbcType=TIMESTAMP},
            </if>
            <if test="consumeDate != null">
                #{consumeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="errorMessage != null">
                #{errorMessage,jdbcType=VARCHAR},
            </if>
            <if test="queueType != null">
                #{queueType,jdbcType=INTEGER},
            </if>
            <if test="errorStackTrace != null">
                #{errorStackTrace,jdbcType=LONGVARCHAR},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.bailuntec.domain.example.DcBaseQueueExample" resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from dc_base_queue
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_queue
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.type != null">
                type = #{record.type,jdbcType=VARCHAR},
            </if>
            <if test="record.message != null">
                message = #{record.message,jdbcType=VARCHAR},
            </if>
            <if test="record.submitDate != null">
                submit_date = #{record.submitDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.consumeDate != null">
                consume_date = #{record.consumeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.errorMessage != null">
                error_message = #{record.errorMessage,jdbcType=VARCHAR},
            </if>
            <if test="record.queueType != null">
                queue_type = #{record.queueType,jdbcType=INTEGER},
            </if>
            <if test="record.errorStackTrace != null">
                error_stack_trace = #{record.errorStackTrace,jdbcType=LONGVARCHAR},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExampleWithBLOBs" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_queue
        set id = #{record.id,jdbcType=INTEGER},
        type = #{record.type,jdbcType=VARCHAR},
        message = #{record.message,jdbcType=VARCHAR},
        submit_date = #{record.submitDate,jdbcType=TIMESTAMP},
        consume_date = #{record.consumeDate,jdbcType=TIMESTAMP},
        error_message = #{record.errorMessage,jdbcType=VARCHAR},
        queue_type = #{record.queueType,jdbcType=INTEGER},
        error_stack_trace = #{record.errorStackTrace,jdbcType=LONGVARCHAR}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_queue
        set id = #{record.id,jdbcType=INTEGER},
        type = #{record.type,jdbcType=VARCHAR},
        message = #{record.message,jdbcType=VARCHAR},
        submit_date = #{record.submitDate,jdbcType=TIMESTAMP},
        consume_date = #{record.consumeDate,jdbcType=TIMESTAMP},
        error_message = #{record.errorMessage,jdbcType=VARCHAR},
        queue_type = #{record.queueType,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_queue
        <set>
            <if test="type != null">
                type = #{type,jdbcType=VARCHAR},
            </if>
            <if test="message != null">
                message = #{message,jdbcType=VARCHAR},
            </if>
            <if test="submitDate != null">
                submit_date = #{submitDate,jdbcType=TIMESTAMP},
            </if>
            <if test="consumeDate != null">
                consume_date = #{consumeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="errorMessage != null">
                error_message = #{errorMessage,jdbcType=VARCHAR},
            </if>
            <if test="queueType != null">
                queue_type = #{queueType,jdbcType=INTEGER},
            </if>
            <if test="errorStackTrace != null">
                error_stack_trace = #{errorStackTrace,jdbcType=LONGVARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_queue
        set type = #{type,jdbcType=VARCHAR},
        message = #{message,jdbcType=VARCHAR},
        submit_date = #{submitDate,jdbcType=TIMESTAMP},
        consume_date = #{consumeDate,jdbcType=TIMESTAMP},
        error_message = #{errorMessage,jdbcType=VARCHAR},
        queue_type = #{queueType,jdbcType=INTEGER},
        error_stack_trace = #{errorStackTrace,jdbcType=LONGVARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_queue
        set type = #{type,jdbcType=VARCHAR},
        message = #{message,jdbcType=VARCHAR},
        submit_date = #{submitDate,jdbcType=TIMESTAMP},
        consume_date = #{consumeDate,jdbcType=TIMESTAMP},
        error_message = #{errorMessage,jdbcType=VARCHAR},
        queue_type = #{queueType,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_queue
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="type != null">
                type,
            </if>
            <if test="message != null">
                message,
            </if>
            <if test="submitDate != null">
                submit_date,
            </if>
            <if test="consumeDate != null">
                consume_date,
            </if>
            <if test="errorMessage != null">
                error_message,
            </if>
            <if test="queueType != null">
                queue_type,
            </if>
            <if test="errorStackTrace != null">
                error_stack_trace,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=VARCHAR},
            </if>
            <if test="message != null">
                #{message,jdbcType=VARCHAR},
            </if>
            <if test="submitDate != null">
                #{submitDate,jdbcType=TIMESTAMP},
            </if>
            <if test="consumeDate != null">
                #{consumeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="errorMessage != null">
                #{errorMessage,jdbcType=VARCHAR},
            </if>
            <if test="queueType != null">
                #{queueType,jdbcType=INTEGER},
            </if>
            <if test="errorStackTrace != null">
                #{errorStackTrace,jdbcType=LONGVARCHAR},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=VARCHAR},
            </if>
            <if test="message != null">
                message = #{message,jdbcType=VARCHAR},
            </if>
            <if test="submitDate != null">
                submit_date = #{submitDate,jdbcType=TIMESTAMP},
            </if>
            <if test="consumeDate != null">
                consume_date = #{consumeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="errorMessage != null">
                error_message = #{errorMessage,jdbcType=VARCHAR},
            </if>
            <if test="queueType != null">
                queue_type = #{queueType,jdbcType=INTEGER},
            </if>
            <if test="errorStackTrace != null">
                error_stack_trace = #{errorStackTrace,jdbcType=LONGVARCHAR},
            </if>
        </trim>
    </insert>
    <insert id="upsert" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_queue
        (id, type, message, submit_date, consume_date, error_message, queue_type)
        values
        (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR}, #{submitDate,jdbcType=TIMESTAMP},
        #{consumeDate,jdbcType=TIMESTAMP}, #{errorMessage,jdbcType=VARCHAR}, #{queueType,jdbcType=INTEGER}
        )
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        type = #{type,jdbcType=VARCHAR},
        message = #{message,jdbcType=VARCHAR},
        submit_date = #{submitDate,jdbcType=TIMESTAMP},
        consume_date = #{consumeDate,jdbcType=TIMESTAMP},
        error_message = #{errorMessage,jdbcType=VARCHAR},
        queue_type = #{queueType,jdbcType=INTEGER}
    </insert>
    <insert id="upsertWithBLOBs" parameterType="com.bailuntec.domain.entity.DcBaseQueue">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_queue
        (id, type, message, submit_date, consume_date, error_message, queue_type, error_stack_trace
        )
        values
        (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR}, #{submitDate,jdbcType=TIMESTAMP},
        #{consumeDate,jdbcType=TIMESTAMP}, #{errorMessage,jdbcType=VARCHAR}, #{queueType,jdbcType=INTEGER},
        #{errorStackTrace,jdbcType=LONGVARCHAR})
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        type = #{type,jdbcType=VARCHAR},
        message = #{message,jdbcType=VARCHAR},
        submit_date = #{submitDate,jdbcType=TIMESTAMP},
        consume_date = #{consumeDate,jdbcType=TIMESTAMP},
        error_message = #{errorMessage,jdbcType=VARCHAR},
        queue_type = #{queueType,jdbcType=INTEGER},
        error_stack_trace = #{errorStackTrace,jdbcType=LONGVARCHAR}
    </insert>
    <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcBaseQueueExample" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_base_queue
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>
    <select id="selectOneByExampleWithBLOBs" parameterType="com.bailuntec.domain.example.DcBaseQueueExample" resultMap="ResultMapWithBLOBs">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        select
        <include refid="Base_Column_List"/>
        ,
        <include refid="Blob_Column_List"/>
        from dc_base_queue
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>

    <select id="poll" resultType="com.bailuntec.domain.entity.DcBaseQueue">
        select *
        from dc_base_queue
        where consume_date is null
          and queue_type = 1
          and id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        limit 1000
    </select>

</mapper>
