<?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.read.promotion.FullNldRuleReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.FullNldRule">
    <id column="rule_id" property="ruleId" />
    <result column="full_id" property="fullId" />
    <result column="full_value" property="fullValue" />
    <result column="minus_value" property="minusValue" />
    <result column="send_integral" property="sendIntegral" />
    <result column="send_coupon_ids" property="sendCouponIds" />
    <result column="send_goods_ids" property="sendGoodsIds" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `rule_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.ruleIdNotEquals != null">
          AND `rule_id` != #{example.ruleIdNotEquals}
        </if>
        <if test="example.ruleIdIn != null">
          AND `rule_id` in (${example.ruleIdIn})
        </if>
        <if test="example.fullId != null">
          AND `full_id` = #{example.fullId}
        </if>
        <if test="example.fullValue != null">
          AND `full_value` = #{example.fullValue}
        </if>
        <if test="example.minusValue != null">
          AND `minus_value` = #{example.minusValue}
        </if>
        <if test="example.sendIntegral != null">
          AND `send_integral` = #{example.sendIntegral}
        </if>
        <if test="example.sendCouponIds != null">
          AND `send_coupon_ids` = #{example.sendCouponIds}
        </if>
        <if test="example.sendGoodsIds != null">
          AND `send_goods_ids` = #{example.sendGoodsIds}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `rule_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.FullNldRuleExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_full_nld_rule`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_full_nld_rule`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_full_nld_rule`
    <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_full_nld_rule`
    <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_full_nld_rule`
    <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_full_nld_rule`
    <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>
</mapper>