<?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.StorePushWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.msg.pojo.StorePush">
    <id column="push_id" property="pushId" />
    <result column="content" property="content" />
    <result column="store_id" property="storeId" />
    <result column="send_time" property="sendTime" />
    <result column="send_way" property="sendWay" />
    <result column="is_check" property="isCheck" />
    <result column="description" property="description" />
    <result column="create_id" property="createId" />
    <result column="receive_ids" property="receiveIds" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="content != null">
        `content`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="sendTime != null">
        `send_time`,
      </if>
      <if test="sendWay != null">
        `send_way`,
      </if>
      <if test="isCheck != null">
        `is_check`,
      </if>
      <if test="description != null">
        `description`,
      </if>
      <if test="createId != null">
        `create_id`,
      </if>
      <if test="receiveIds != null">
        `receive_ids`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `push_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.pushIdNotEquals != null">
          AND `push_id` != #{example.pushIdNotEquals}
        </if>
        <if test="example.pushIdIn != null">
          AND `push_id` in (${example.pushIdIn})
        </if>
        <if test="example.content != null">
          AND `content` = #{example.content}
        </if>
        <if test="example.contentLike != null">
          AND `content` like concat('%',#{example.contentLike},'%')
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.sendTimeAfter != null">
          AND `send_time` <![CDATA[ >= ]]> #{example.sendTimeAfter}
        </if>
        <if test="example.sendTimeBefore != null">
          AND `send_time` <![CDATA[ <= ]]> #{example.sendTimeBefore}
        </if>
        <if test="example.sendWay != null">
          AND `send_way` = #{example.sendWay}
        </if>
        <if test="example.isCheck != null">
          AND `is_check` = #{example.isCheck}
        </if>
        <if test="example.description != null">
          AND `description` = #{example.description}
        </if>
        <if test="example.createId != null">
          AND `create_id` = #{example.createId}
        </if>
        <if test="example.receiveIds != null">
          AND `receive_ids` = #{example.receiveIds}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `push_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.StorePushExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `msg_store_push`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `msg_store_push`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `msg_store_push`
    <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_push`
    <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_push`
    <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_push`
    <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_push`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `msg_store_push`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="push_id" keyProperty="pushId" parameterType="com.slodon.b2b2c.msg.pojo.StorePush" useGeneratedKeys="true">
    INSERT INTO `msg_store_push`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="content != null">
        #{content},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="sendTime != null">
        #{sendTime},
      </if>
      <if test="sendWay != null">
        #{sendWay},
      </if>
      <if test="isCheck != null">
        #{isCheck},
      </if>
      <if test="description != null">
        #{description},
      </if>
      <if test="createId != null">
        #{createId},
      </if>
      <if test="receiveIds != null">
        #{receiveIds},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `msg_store_push`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.content != null">
        `content` = #{record.content},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.sendTime != null">
        `send_time` = #{record.sendTime},
      </if>
      <if test="record.sendWay != null">
        `send_way` = #{record.sendWay},
      </if>
      <if test="record.isCheck != null">
        `is_check` = #{record.isCheck},
      </if>
      <if test="record.description != null">
        `description` = #{record.description},
      </if>
      <if test="record.createId != null">
        `create_id` = #{record.createId},
      </if>
      <if test="record.receiveIds != null">
        `receive_ids` = #{record.receiveIds},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `msg_store_push`
    <trim prefix="SET" suffixOverrides=",">
      <if test="content != null">
        `content` = #{content},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="sendTime != null">
        `send_time` = #{sendTime},
      </if>
      <if test="sendWay != null">
        `send_way` = #{sendWay},
      </if>
      <if test="isCheck != null">
        `is_check` = #{isCheck},
      </if>
      <if test="description != null">
        `description` = #{description},
      </if>
      <if test="createId != null">
        `create_id` = #{createId},
      </if>
      <if test="receiveIds != null">
        `receive_ids` = #{receiveIds},
      </if>
    </trim>
    WHERE `push_id` = #{pushId}
  </update>
</mapper>