<?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.LadderGroupGoodsReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.LadderGroupGoods">
    <id column="group_goods_id" property="groupGoodsId" />
    <result column="group_id" property="groupId" />
    <result column="goods_id" property="goodsId" />
    <result column="goods_name" property="goodsName" />
    <result column="goods_brief" property="goodsBrief" />
    <result column="goods_image" property="goodsImage" />
    <result column="spec_values" property="specValues" />
    <result column="product_id" property="productId" />
    <result column="product_price" property="productPrice" />
    <result column="stock" property="stock" />
    <result column="sales_volume" property="salesVolume" />
    <result column="advance_deposit" property="advanceDeposit" />
    <result column="ladder_price1" property="ladderPrice1" />
    <result column="ladder_price2" property="ladderPrice2" />
    <result column="ladder_price3" property="ladderPrice3" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `group_goods_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.groupGoodsIdNotEquals != null">
          AND `group_goods_id` != #{example.groupGoodsIdNotEquals}
        </if>
        <if test="example.groupGoodsIdIn != null">
          AND `group_goods_id` in (${example.groupGoodsIdIn})
        </if>
        <if test="example.groupId != null">
          AND `group_id` = #{example.groupId}
        </if>
        <if test="example.groupIdIn != null">
          AND `group_id` in (${example.groupIdIn})
        </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.goodsBrief != null">
          AND `goods_brief` = #{example.goodsBrief}
        </if>
        <if test="example.goodsImage != null">
          AND `goods_image` = #{example.goodsImage}
        </if>
        <if test="example.specValues != null">
          AND `spec_values` = #{example.specValues}
        </if>
        <if test="example.productId != null">
          AND `product_id` = #{example.productId}
        </if>
        <if test="example.productPrice != null">
          AND `product_price` = #{example.productPrice}
        </if>
        <if test="example.stock != null">
          AND `stock` = #{example.stock}
        </if>
        <if test="example.salesVolume != null">
          AND `sales_volume` = #{example.salesVolume}
        </if>
        <if test="example.advanceDeposit != null">
          AND `advance_deposit` = #{example.advanceDeposit}
        </if>
        <if test="example.ladderPrice1 != null">
          AND `ladder_price1` = #{example.ladderPrice1}
        </if>
        <if test="example.ladderPrice2 != null">
          AND `ladder_price2` = #{example.ladderPrice2}
        </if>
        <if test="example.ladderPrice3 != null">
          AND `ladder_price3` = #{example.ladderPrice3}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `group_goods_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.LadderGroupGoodsExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_ladder_group_goods`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_ladder_group_goods`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_ladder_group_goods`
    <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_goods`
    <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_goods`
    <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_goods`
    <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>