<?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.goafanti.common.dao.JtMessageConsumerMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.JtMessageConsumer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="aid" jdbcType="VARCHAR" property="aid" />
    <result column="message_id" jdbcType="VARCHAR" property="messageId" />
    <result column="is_read" jdbcType="BIT" property="isRead" />
    <result column="delete_sign" jdbcType="BIT" property="deleteSign" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    <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 - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    <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 - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    id, aid, message_id, is_read, delete_sign
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.JtMessageConsumerExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from jt_message_consumer
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from jt_message_consumer
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    delete from jt_message_consumer
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.JtMessageConsumerExample">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    delete from jt_message_consumer
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.JtMessageConsumer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    insert into jt_message_consumer (id, aid, message_id, 
      is_read, delete_sign)
    values (#{id,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, #{messageId,jdbcType=VARCHAR}, 
      #{isRead,jdbcType=BIT}, #{deleteSign,jdbcType=BIT})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.JtMessageConsumer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    insert into jt_message_consumer
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="aid != null">
        aid,
      </if>
      <if test="messageId != null">
        message_id,
      </if>
      <if test="isRead != null">
        is_read,
      </if>
      <if test="deleteSign != null">
        delete_sign,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="aid != null">
        #{aid,jdbcType=VARCHAR},
      </if>
      <if test="messageId != null">
        #{messageId,jdbcType=VARCHAR},
      </if>
      <if test="isRead != null">
        #{isRead,jdbcType=BIT},
      </if>
      <if test="deleteSign != null">
        #{deleteSign,jdbcType=BIT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.JtMessageConsumerExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    select count(*) from jt_message_consumer
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    update jt_message_consumer
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.aid != null">
        aid = #{record.aid,jdbcType=VARCHAR},
      </if>
      <if test="record.messageId != null">
        message_id = #{record.messageId,jdbcType=VARCHAR},
      </if>
      <if test="record.isRead != null">
        is_read = #{record.isRead,jdbcType=BIT},
      </if>
      <if test="record.deleteSign != null">
        delete_sign = #{record.deleteSign,jdbcType=BIT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    update jt_message_consumer
    set id = #{record.id,jdbcType=VARCHAR},
      aid = #{record.aid,jdbcType=VARCHAR},
      message_id = #{record.messageId,jdbcType=VARCHAR},
      is_read = #{record.isRead,jdbcType=BIT},
      delete_sign = #{record.deleteSign,jdbcType=BIT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.JtMessageConsumer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    update jt_message_consumer
    <set>
      <if test="aid != null">
        aid = #{aid,jdbcType=VARCHAR},
      </if>
      <if test="messageId != null">
        message_id = #{messageId,jdbcType=VARCHAR},
      </if>
      <if test="isRead != null">
        is_read = #{isRead,jdbcType=BIT},
      </if>
      <if test="deleteSign != null">
        delete_sign = #{deleteSign,jdbcType=BIT},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.JtMessageConsumer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Aug 29 09:46:33 CST 2018.
    -->
    update jt_message_consumer
    set aid = #{aid,jdbcType=VARCHAR},
      message_id = #{messageId,jdbcType=VARCHAR},
      is_read = #{isRead,jdbcType=BIT},
      delete_sign = #{deleteSign,jdbcType=BIT}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <!-- 批量新增数据 -->
  <insert id="addBatch" parameterType="java.util.List">
   insert into jt_message_consumer 
    (id, aid, message_id)
    values 
    <foreach collection="list" item="mc" separator=",">
     (#{mc.id,jdbcType=VARCHAR}, #{mc.aid,jdbcType=VARCHAR}, #{mc.messageId,jdbcType=VARCHAR})
    </foreach>
  </insert>
  <select id="selectById" resultType="com.goafanti.message.bo.AppMessageBo">
  	select a.id ,b.title,b.body,b.send_time as sendTime,b.create_time as createTime,a.is_read as isRead from jt_message_consumer a
	left join jt_message_producer b on a.message_id=b.id
	where a.delete_sign=0 and b.delete_sign=0 and  b.is_draft=0 and b.is_send=1
	and a.id=#{id,jdbcType=VARCHAR}
  </select>
</mapper>