<?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.promotion.SeckillStageProductWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.SeckillStageProduct">
    <id column="stage_product_id" property="stageProductId" />
    <result column="start_time" property="startTime" />
    <result column="end_time" property="endTime" />
    <result column="product_id" property="productId" />
    <result column="goods_id" property="goodsId" />
    <result column="main_image" property="mainImage" />
    <result column="goods_name" property="goodsName" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="product_price" property="productPrice" />
    <result column="seckill_price" property="seckillPrice" />
    <result column="seckill_stock" property="seckillStock" />
    <result column="upper_limit" property="upperLimit" />
    <result column="buyer_count" property="buyerCount" />
    <result column="buy_quantity" property="buyQuantity" />
    <result column="verify_state" property="verifyState" />
    <result column="remark" property="remark" />
    <result column="seckill_id" property="seckillId" />
    <result column="seckill_name" property="seckillName" />
    <result column="stage_id" property="stageId" />
    <result column="stage_name" property="stageName" />
    <result column="label_id" property="labelId" />
    <result column="label_name" property="labelName" />
    <result column="product_stock" property="productStock" />
    <result column="state" property="state" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="startTime != null">
        `start_time`,
      </if>
      <if test="endTime != null">
        `end_time`,
      </if>
      <if test="productId != null">
        `product_id`,
      </if>
      <if test="goodsId != null">
        `goods_id`,
      </if>
      <if test="mainImage != null">
        `main_image`,
      </if>
      <if test="goodsName != null">
        `goods_name`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="storeName != null">
        `store_name`,
      </if>
      <if test="productPrice != null">
        `product_price`,
      </if>
      <if test="seckillPrice != null">
        `seckill_price`,
      </if>
      <if test="seckillStock != null">
        `seckill_stock`,
      </if>
      <if test="upperLimit != null">
        `upper_limit`,
      </if>
      <if test="buyerCount != null">
        `buyer_count`,
      </if>
      <if test="buyQuantity != null">
        `buy_quantity`,
      </if>
      <if test="verifyState != null">
        `verify_state`,
      </if>
      <if test="remark != null">
        `remark`,
      </if>
      <if test="seckillId != null">
        `seckill_id`,
      </if>
      <if test="seckillName != null">
        `seckill_name`,
      </if>
      <if test="stageId != null">
        `stage_id`,
      </if>
      <if test="stageName != null">
        `stage_name`,
      </if>
      <if test="labelId != null">
        `label_id`,
      </if>
      <if test="labelName != null">
        `label_name`,
      </if>
      <if test="productStock != null">
        `product_stock`,
      </if>
      <if test="state != null">
        `state`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `stage_product_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.stageProductIdNotEquals != null">
          AND `stage_product_id` != #{example.stageProductIdNotEquals}
        </if>
        <if test="example.stageProductIdIn != null">
          AND `stage_product_id` in (${example.stageProductIdIn})
        </if>
        <if test="example.startTimeAfter != null">
          AND `start_time` <![CDATA[ >= ]]> #{example.startTimeAfter}
        </if>
        <if test="example.startTimeBefore != null">
          AND `start_time` <![CDATA[ <= ]]> #{example.startTimeBefore}
        </if>
        <if test="example.endTimeAfter != null">
          AND `end_time` <![CDATA[ >= ]]> #{example.endTimeAfter}
        </if>
        <if test="example.endTimeBefore != null">
          AND `end_time` <![CDATA[ <= ]]> #{example.endTimeBefore}
        </if>
        <if test="example.productId != null">
          AND `product_id` = #{example.productId}
        </if>
        <if test="example.productIdIn != null">
          AND `product_id` in (${example.productIdIn})
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </if>
        <if test="example.goodsIdIn != null">
          AND `goods_id` in (${example.goodsIdIn})
        </if>
        <if test="example.mainImage != null">
          AND `main_image` = #{example.mainImage}
        </if>
        <if test="example.goodsName != null">
          AND `goods_name` = #{example.goodsName}
        </if>
        <if test="example.goodsNameLike != null">
          AND `goods_name` like concat('%',#{example.goodsNameLike},'%')
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.storeName != null">
          AND `store_name` = #{example.storeName}
        </if>
        <if test="example.storeNameLike != null">
          AND `store_name` like concat('%',#{example.storeNameLike},'%')
        </if>
        <if test="example.productPrice != null">
          AND `product_price` = #{example.productPrice}
        </if>
        <if test="example.seckillPrice != null">
          AND `seckill_price` = #{example.seckillPrice}
        </if>
        <if test="example.seckillStock != null">
          AND `seckill_stock` = #{example.seckillStock}
        </if>
        <if test="example.upperLimit != null">
          AND `upper_limit` = #{example.upperLimit}
        </if>
        <if test="example.buyerCount != null">
          AND `buyer_count` = #{example.buyerCount}
        </if>
        <if test="example.buyQuantity != null">
          AND `buy_quantity` = #{example.buyQuantity}
        </if>
        <if test="example.verifyState != null">
          AND `verify_state` = #{example.verifyState}
        </if>
        <if test="example.verifyStateIn != null">
          AND `verify_state` in (${example.verifyStateIn})
        </if>
        <if test="example.verifyStateNotIn != null">
          AND `verify_state` not in (${example.verifyStateNotIn})
        </if>
        <if test="example.verifyStateNotEquals != null">
          AND `verify_state` != #{example.verifyStateNotEquals}
        </if>
        <if test="example.remark != null">
          AND `remark` = #{example.remark}
        </if>
        <if test="example.seckillId != null">
          AND `seckill_id` = #{example.seckillId}
        </if>
        <if test="example.seckillName != null">
          AND `seckill_name` = #{example.seckillName}
        </if>
        <if test="example.seckillNameLike != null">
          AND `seckill_name` like concat('%',#{example.seckillNameLike},'%')
        </if>
        <if test="example.stageId != null">
          AND `stage_id` = #{example.stageId}
        </if>
        <if test="example.stageName != null">
          AND `stage_name` = #{example.stageName}
        </if>
        <if test="example.stageNameLike != null">
          AND `stage_name` like concat('%',#{example.stageNameLike},'%')
        </if>
        <if test="example.labelId != null">
          AND `label_id` = #{example.labelId}
        </if>
        <if test="example.labelName != null">
          AND `label_name` = #{example.labelName}
        </if>
        <if test="example.labelNameLike != null">
          AND `label_name` like concat('%',#{example.labelNameLike},'%')
        </if>
        <if test="example.productStock != null">
          AND `product_stock` = #{example.productStock}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.stateIn != null">
          AND `state` in (${example.stateIn})
        </if>
        <if test="example.stateNotIn != null">
          AND `state` not in (${example.stateNotIn})
        </if>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `stage_product_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.promotion.example.SeckillStageProductExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_seckill_stage_product`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_seckill_stage_product`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_seckill_stage_product`
    <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 `promotion_seckill_stage_product`
    <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 `promotion_seckill_stage_product`
    <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 `promotion_seckill_stage_product`
    <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 `promotion_seckill_stage_product`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `promotion_seckill_stage_product`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="stage_product_id" keyProperty="stageProductId" parameterType="com.slodon.b2b2c.promotion.pojo.SeckillStageProduct" useGeneratedKeys="true">
    INSERT INTO `promotion_seckill_stage_product`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="startTime != null">
        #{startTime},
      </if>
      <if test="endTime != null">
        #{endTime},
      </if>
      <if test="productId != null">
        #{productId},
      </if>
      <if test="goodsId != null">
        #{goodsId},
      </if>
      <if test="mainImage != null">
        #{mainImage},
      </if>
      <if test="goodsName != null">
        #{goodsName},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="storeName != null">
        #{storeName},
      </if>
      <if test="productPrice != null">
        #{productPrice},
      </if>
      <if test="seckillPrice != null">
        #{seckillPrice},
      </if>
      <if test="seckillStock != null">
        #{seckillStock},
      </if>
      <if test="upperLimit != null">
        #{upperLimit},
      </if>
      <if test="buyerCount != null">
        #{buyerCount},
      </if>
      <if test="buyQuantity != null">
        #{buyQuantity},
      </if>
      <if test="verifyState != null">
        #{verifyState},
      </if>
      <if test="remark != null">
        #{remark},
      </if>
      <if test="seckillId != null">
        #{seckillId},
      </if>
      <if test="seckillName != null">
        #{seckillName},
      </if>
      <if test="stageId != null">
        #{stageId},
      </if>
      <if test="stageName != null">
        #{stageName},
      </if>
      <if test="labelId != null">
        #{labelId},
      </if>
      <if test="labelName != null">
        #{labelName},
      </if>
      <if test="productStock != null">
        #{productStock},
      </if>
      <if test="state != null">
        #{state},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `promotion_seckill_stage_product`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.startTime != null">
        `start_time` = #{record.startTime},
      </if>
      <if test="record.endTime != null">
        `end_time` = #{record.endTime},
      </if>
      <if test="record.productId != null">
        `product_id` = #{record.productId},
      </if>
      <if test="record.goodsId != null">
        `goods_id` = #{record.goodsId},
      </if>
      <if test="record.mainImage != null">
        `main_image` = #{record.mainImage},
      </if>
      <if test="record.goodsName != null">
        `goods_name` = #{record.goodsName},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.storeName != null">
        `store_name` = #{record.storeName},
      </if>
      <if test="record.productPrice != null">
        `product_price` = #{record.productPrice},
      </if>
      <if test="record.seckillPrice != null">
        `seckill_price` = #{record.seckillPrice},
      </if>
      <if test="record.seckillStock != null">
        `seckill_stock` = #{record.seckillStock},
      </if>
      <if test="record.upperLimit != null">
        `upper_limit` = #{record.upperLimit},
      </if>
      <if test="record.buyerCount != null">
        `buyer_count` = #{record.buyerCount},
      </if>
      <if test="record.buyQuantity != null">
        `buy_quantity` = #{record.buyQuantity},
      </if>
      <if test="record.verifyState != null">
        `verify_state` = #{record.verifyState},
      </if>
      <if test="record.remark != null">
        `remark` = #{record.remark},
      </if>
      <if test="record.seckillId != null">
        `seckill_id` = #{record.seckillId},
      </if>
      <if test="record.seckillName != null">
        `seckill_name` = #{record.seckillName},
      </if>
      <if test="record.stageId != null">
        `stage_id` = #{record.stageId},
      </if>
      <if test="record.stageName != null">
        `stage_name` = #{record.stageName},
      </if>
      <if test="record.labelId != null">
        `label_id` = #{record.labelId},
      </if>
      <if test="record.labelName != null">
        `label_name` = #{record.labelName},
      </if>
      <if test="record.productStock != null">
        `product_stock` = #{record.productStock},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `promotion_seckill_stage_product`
    <trim prefix="SET" suffixOverrides=",">
      <if test="startTime != null">
        `start_time` = #{startTime},
      </if>
      <if test="endTime != null">
        `end_time` = #{endTime},
      </if>
      <if test="productId != null">
        `product_id` = #{productId},
      </if>
      <if test="goodsId != null">
        `goods_id` = #{goodsId},
      </if>
      <if test="mainImage != null">
        `main_image` = #{mainImage},
      </if>
      <if test="goodsName != null">
        `goods_name` = #{goodsName},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="storeName != null">
        `store_name` = #{storeName},
      </if>
      <if test="productPrice != null">
        `product_price` = #{productPrice},
      </if>
      <if test="seckillPrice != null">
        `seckill_price` = #{seckillPrice},
      </if>
      <if test="seckillStock != null">
        `seckill_stock` = #{seckillStock},
      </if>
      <if test="upperLimit != null">
        `upper_limit` = #{upperLimit},
      </if>
      <if test="buyerCount != null">
        `buyer_count` = #{buyerCount},
      </if>
      <if test="buyQuantity != null">
        `buy_quantity` = #{buyQuantity},
      </if>
      <if test="verifyState != null">
        `verify_state` = #{verifyState},
      </if>
      <if test="remark != null">
        `remark` = #{remark},
      </if>
      <if test="seckillId != null">
        `seckill_id` = #{seckillId},
      </if>
      <if test="seckillName != null">
        `seckill_name` = #{seckillName},
      </if>
      <if test="stageId != null">
        `stage_id` = #{stageId},
      </if>
      <if test="stageName != null">
        `stage_name` = #{stageName},
      </if>
      <if test="labelId != null">
        `label_id` = #{labelId},
      </if>
      <if test="labelName != null">
        `label_name` = #{labelName},
      </if>
      <if test="productStock != null">
        `product_stock` = #{productStock},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
    </trim>
    WHERE `stage_product_id` = #{stageProductId}
  </update>
</mapper>