<?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.seller.StoreGradeReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.seller.pojo.StoreGrade">
    <id column="grade_id" property="gradeId" />
    <result column="web_site" property="webSite" />
    <result column="grade_name" property="gradeName" />
    <result column="goods_limit" property="goodsLimit" />
    <result column="recommend_limit" property="recommendLimit" />
    <result column="price" property="price" />
    <result column="confirm" property="confirm" />
    <result column="sort" property="sort" />
    <result column="description" property="description" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `grade_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.gradeIdNotEquals != null">
          AND `grade_id` != #{example.gradeIdNotEquals}
        </if>
        <if test="example.gradeIdIn != null">
          AND `grade_id` in (${example.gradeIdIn})
        </if>
        <if test="example.webSite != null">
          AND `web_site` = #{example.webSite}
        </if>
        <if test="example.gradeName != null">
          AND `grade_name` = #{example.gradeName}
        </if>
        <if test="example.gradeNameLike != null">
          AND `grade_name` like concat('%',#{example.gradeNameLike},'%')
        </if>
        <if test="example.goodsLimit != null">
          AND `goods_limit` = #{example.goodsLimit}
        </if>
        <if test="example.recommendLimit != null">
          AND `recommend_limit` = #{example.recommendLimit}
        </if>
        <if test="example.price != null">
          AND `price` = #{example.price}
        </if>
        <if test="example.confirm != null">
          AND `confirm` = #{example.confirm}
        </if>
        <if test="example.sort != null">
          AND `sort` = #{example.sort}
        </if>
        <if test="example.description != null">
          AND `description` = #{example.description}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `grade_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.seller.example.StoreGradeExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `store_grade`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `store_grade`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `store_grade`
    <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 `store_grade`
    <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 `store_grade`
    <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 `store_grade`
    <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>