<?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.LadderGroupWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.LadderGroup">
    <id column="group_id" property="groupId" />
    <result column="group_name" property="groupName" />
    <result column="start_time" property="startTime" />
    <result column="end_time" property="endTime" />
    <result column="label_id" property="labelId" />
    <result column="label_name" property="labelName" />
    <result column="balance_time" property="balanceTime" />
    <result column="buy_limit_num" property="buyLimitNum" />
    <result column="is_refund_deposit" property="isRefundDeposit" />
    <result column="discount_type" property="discountType" />
    <result column="goods_id" property="goodsId" />
    <result column="goods_name" property="goodsName" />
    <result column="state" property="state" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="create_vendor_id" property="createVendorId" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="groupName != null">
        `group_name`,
      </if>
      <if test="startTime != null">
        `start_time`,
      </if>
      <if test="endTime != null">
        `end_time`,
      </if>
      <if test="labelId != null">
        `label_id`,
      </if>
      <if test="labelName != null">
        `label_name`,
      </if>
      <if test="balanceTime != null">
        `balance_time`,
      </if>
      <if test="buyLimitNum != null">
        `buy_limit_num`,
      </if>
      <if test="isRefundDeposit != null">
        `is_refund_deposit`,
      </if>
      <if test="discountType != null">
        `discount_type`,
      </if>
      <if test="goodsId != null">
        `goods_id`,
      </if>
      <if test="goodsName != null">
        `goods_name`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="storeName != null">
        `store_name`,
      </if>
      <if test="createVendorId != null">
        `create_vendor_id`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="updateTime != null">
        `update_time`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `group_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.groupIdNotEquals != null">
          AND `group_id` != #{example.groupIdNotEquals}
        </if>
        <if test="example.groupIdIn != null">
          AND `group_id` in (${example.groupIdIn})
        </if>
        <if test="example.groupName != null">
          AND `group_name` = #{example.groupName}
        </if>
        <if test="example.groupNameLike != null">
          AND `group_name` like concat('%',#{example.groupNameLike},'%')
        </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.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.balanceTime != null">
          AND `balance_time` = #{example.balanceTime}
        </if>
        <if test="example.buyLimitNum != null">
          AND `buy_limit_num` = #{example.buyLimitNum}
        </if>
        <if test="example.isRefundDeposit != null">
          AND `is_refund_deposit` = #{example.isRefundDeposit}
        </if>
        <if test="example.discountType != null">
          AND `discount_type` = #{example.discountType}
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </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.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>
        <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.createVendorId != null">
          AND `create_vendor_id` = #{example.createVendorId}
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.updateTimeAfter != null">
          AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
        </if>
        <if test="example.updateTimeBefore != null">
          AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `group_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.LadderGroupExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_ladder_group`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_ladder_group`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_ladder_group`
    <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_ladder_group`
    <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_ladder_group`
    <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_ladder_group`
    <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_ladder_group`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `promotion_ladder_group`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="group_id" keyProperty="groupId" parameterType="com.slodon.b2b2c.promotion.pojo.LadderGroup" useGeneratedKeys="true">
    INSERT INTO `promotion_ladder_group`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="groupName != null">
        #{groupName},
      </if>
      <if test="startTime != null">
        #{startTime},
      </if>
      <if test="endTime != null">
        #{endTime},
      </if>
      <if test="labelId != null">
        #{labelId},
      </if>
      <if test="labelName != null">
        #{labelName},
      </if>
      <if test="balanceTime != null">
        #{balanceTime},
      </if>
      <if test="buyLimitNum != null">
        #{buyLimitNum},
      </if>
      <if test="isRefundDeposit != null">
        #{isRefundDeposit},
      </if>
      <if test="discountType != null">
        #{discountType},
      </if>
      <if test="goodsId != null">
        #{goodsId},
      </if>
      <if test="goodsName != null">
        #{goodsName},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="storeName != null">
        #{storeName},
      </if>
      <if test="createVendorId != null">
        #{createVendorId},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="updateTime != null">
        #{updateTime},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `promotion_ladder_group`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.groupName != null">
        `group_name` = #{record.groupName},
      </if>
      <if test="record.startTime != null">
        `start_time` = #{record.startTime},
      </if>
      <if test="record.endTime != null">
        `end_time` = #{record.endTime},
      </if>
      <if test="record.labelId != null">
        `label_id` = #{record.labelId},
      </if>
      <if test="record.labelName != null">
        `label_name` = #{record.labelName},
      </if>
      <if test="record.balanceTime != null">
        `balance_time` = #{record.balanceTime},
      </if>
      <if test="record.buyLimitNum != null">
        `buy_limit_num` = #{record.buyLimitNum},
      </if>
      <if test="record.isRefundDeposit != null">
        `is_refund_deposit` = #{record.isRefundDeposit},
      </if>
      <if test="record.discountType != null">
        `discount_type` = #{record.discountType},
      </if>
      <if test="record.goodsId != null">
        `goods_id` = #{record.goodsId},
      </if>
      <if test="record.goodsName != null">
        `goods_name` = #{record.goodsName},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.storeName != null">
        `store_name` = #{record.storeName},
      </if>
      <if test="record.createVendorId != null">
        `create_vendor_id` = #{record.createVendorId},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        `update_time` = #{record.updateTime},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `promotion_ladder_group`
    <trim prefix="SET" suffixOverrides=",">
      <if test="groupName != null">
        `group_name` = #{groupName},
      </if>
      <if test="startTime != null">
        `start_time` = #{startTime},
      </if>
      <if test="endTime != null">
        `end_time` = #{endTime},
      </if>
      <if test="labelId != null">
        `label_id` = #{labelId},
      </if>
      <if test="labelName != null">
        `label_name` = #{labelName},
      </if>
      <if test="balanceTime != null">
        `balance_time` = #{balanceTime},
      </if>
      <if test="buyLimitNum != null">
        `buy_limit_num` = #{buyLimitNum},
      </if>
      <if test="isRefundDeposit != null">
        `is_refund_deposit` = #{isRefundDeposit},
      </if>
      <if test="discountType != null">
        `discount_type` = #{discountType},
      </if>
      <if test="goodsId != null">
        `goods_id` = #{goodsId},
      </if>
      <if test="goodsName != null">
        `goods_name` = #{goodsName},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="storeName != null">
        `store_name` = #{storeName},
      </if>
      <if test="createVendorId != null">
        `create_vendor_id` = #{createVendorId},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="updateTime != null">
        `update_time` = #{updateTime},
      </if>
    </trim>
    WHERE `group_id` = #{groupId}
  </update>
</mapper>