<?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.slodon.b2b2c.dao.write.msg.StoreReceiveWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.msg.pojo.StoreReceive">
    <id column="receive_id" property="receiveId" />
    <result column="tpl_code" property="tplCode" />
    <result column="store_id" property="storeId" />
    <result column="vendor_id" property="vendorId" />
    <result column="msg_content" property="msgContent" />
    <result column="msg_link_info" property="msgLinkInfo" />
    <result column="msg_send_time" property="msgSendTime" />
    <result column="msg_operate_time" property="msgOperateTime" />
    <result column="msg_state" property="msgState" />
    <result column="push_id" property="pushId" />
    <result column="source" property="source" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="tplCode != null">
        `tpl_code`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="vendorId != null">
        `vendor_id`,
      </if>
      <if test="msgContent != null">
        `msg_content`,
      </if>
      <if test="msgLinkInfo != null">
        `msg_link_info`,
      </if>
      <if test="msgSendTime != null">
        `msg_send_time`,
      </if>
      <if test="msgOperateTime != null">
        `msg_operate_time`,
      </if>
      <if test="msgState != null">
        `msg_state`,
      </if>
      <if test="pushId != null">
        `push_id`,
      </if>
      <if test="source != null">
        `source`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `receive_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.receiveIdNotEquals != null">
          AND `receive_id` != #{example.receiveIdNotEquals}
        </if>
        <if test="example.receiveIdIn != null">
          AND `receive_id` in (${example.receiveIdIn})
        </if>
        <if test="example.tplCode != null">
          AND `tpl_code` = #{example.tplCode}
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.vendorId != null">
          AND `vendor_id` = #{example.vendorId}
        </if>
        <if test="example.msgContent != null">
          AND `msg_content` = #{example.msgContent}
        </if>
        <if test="example.msgContentLike != null">
          AND `msg_content` like concat('%',#{example.msgContentLike},'%')
        </if>
        <if test="example.msgLinkInfo != null">
          AND `msg_link_info` = #{example.msgLinkInfo}
        </if>
        <if test="example.msgSendTimeAfter != null">
          AND `msg_send_time` <![CDATA[ >= ]]> #{example.msgSendTimeAfter}
        </if>
        <if test="example.msgSendTimeBefore != null">
          AND `msg_send_time` <![CDATA[ <= ]]> #{example.msgSendTimeBefore}
        </if>
        <if test="example.msgOperateTimeAfter != null">
          AND `msg_operate_time` <![CDATA[ >= ]]> #{example.msgOperateTimeAfter}
        </if>
        <if test="example.msgOperateTimeBefore != null">
          AND `msg_operate_time` <![CDATA[ <= ]]> #{example.msgOperateTimeBefore}
        </if>
        <if test="example.msgState != null">
          AND `msg_state` = #{example.msgState}
        </if>
        <if test="example.pushId != null">
          AND `push_id` = #{example.pushId}
        </if>
        <if test="example.source != null">
          AND `source` = #{example.source}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `receive_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.msg.example.StoreReceiveExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `msg_store_receive`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `msg_store_receive`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `msg_store_receive`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `msg_store_receive`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `msg_store_receive`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `msg_store_receive`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `msg_store_receive`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `msg_store_receive`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="receive_id" keyProperty="receiveId" parameterType="com.slodon.b2b2c.msg.pojo.StoreReceive" useGeneratedKeys="true">
    INSERT INTO `msg_store_receive`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="tplCode != null">
        #{tplCode},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="vendorId != null">
        #{vendorId},
      </if>
      <if test="msgContent != null">
        #{msgContent},
      </if>
      <if test="msgLinkInfo != null">
        #{msgLinkInfo},
      </if>
      <if test="msgSendTime != null">
        #{msgSendTime},
      </if>
      <if test="msgOperateTime != null">
        #{msgOperateTime},
      </if>
      <if test="msgState != null">
        #{msgState},
      </if>
      <if test="pushId != null">
        #{pushId},
      </if>
      <if test="source != null">
        #{source},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `msg_store_receive`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.tplCode != null">
        `tpl_code` = #{record.tplCode},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.vendorId != null">
        `vendor_id` = #{record.vendorId},
      </if>
      <if test="record.msgContent != null">
        `msg_content` = #{record.msgContent},
      </if>
      <if test="record.msgLinkInfo != null">
        `msg_link_info` = #{record.msgLinkInfo},
      </if>
      <if test="record.msgSendTime != null">
        `msg_send_time` = #{record.msgSendTime},
      </if>
      <if test="record.msgOperateTime != null">
        `msg_operate_time` = #{record.msgOperateTime},
      </if>
      <if test="record.msgState != null">
        `msg_state` = #{record.msgState},
      </if>
      <if test="record.pushId != null">
        `push_id` = #{record.pushId},
      </if>
      <if test="record.source != null">
        `source` = #{record.source},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `msg_store_receive`
    <trim prefix="SET" suffixOverrides=",">
      <if test="tplCode != null">
        `tpl_code` = #{tplCode},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="vendorId != null">
        `vendor_id` = #{vendorId},
      </if>
      <if test="msgContent != null">
        `msg_content` = #{msgContent},
      </if>
      <if test="msgLinkInfo != null">
        `msg_link_info` = #{msgLinkInfo},
      </if>
      <if test="msgSendTime != null">
        `msg_send_time` = #{msgSendTime},
      </if>
      <if test="msgOperateTime != null">
        `msg_operate_time` = #{msgOperateTime},
      </if>
      <if test="msgState != null">
        `msg_state` = #{msgState},
      </if>
      <if test="pushId != null">
        `push_id` = #{pushId},
      </if>
      <if test="source != null">
        `source` = #{source},
      </if>
    </trim>
    WHERE `receive_id` = #{receiveId}
  </update>
</mapper>