<?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.StoreBindCategoryReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.seller.pojo.StoreBindCategory">
    <id column="bind_id" property="bindId" />
    <result column="store_id" property="storeId" />
    <result column="web_site" property="webSite" />
    <result column="create_vendor_id" property="createVendorId" />
    <result column="create_time" property="createTime" />
    <result column="goods_cate_name" property="goodsCateName" />
    <result column="scaling" property="scaling" />
    <result column="state" property="state" />
    <result column="audit_admin_id" property="auditAdminId" />
    <result column="audit_time" property="auditTime" />
    <result column="refuse_reason" property="refuseReason" />
    <result column="goods_category_id1" property="goodsCategoryId1" />
    <result column="goods_category_id2" property="goodsCategoryId2" />
    <result column="goods_category_id3" property="goodsCategoryId3" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `bind_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.bindIdNotEquals != null">
          AND `bind_id` != #{example.bindIdNotEquals}
        </if>
        <if test="example.bindIdIn != null">
          AND `bind_id` in (${example.bindIdIn})
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.storeIdNotEquals != null">
          AND `store_id` != #{example.storeIdNotEquals}
        </if>
        <if test="example.webSite != null">
          AND `web_site` = #{example.webSite}
        </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.goodsCateName != null">
          AND `goods_cate_name` = #{example.goodsCateName}
        </if>
        <if test="example.goodsCateNameLike != null">
          AND `goods_cate_name` like concat('%',#{example.goodsCateNameLike},'%')
        </if>
        <if test="example.scaling != null">
          AND `scaling` = #{example.scaling}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
        <if test="example.auditAdminId != null">
          AND `audit_admin_id` = #{example.auditAdminId}
        </if>
        <if test="example.auditTimeAfter != null">
          AND `audit_time` <![CDATA[ >= ]]> #{example.auditTimeAfter}
        </if>
        <if test="example.auditTimeBefore != null">
          AND `audit_time` <![CDATA[ <= ]]> #{example.auditTimeBefore}
        </if>
        <if test="example.refuseReason != null">
          AND `refuse_reason` = #{example.refuseReason}
        </if>
        <if test="example.refuseReasonLike != null">
          AND `refuse_reason` like concat('%',#{example.refuseReasonLike},'%')
        </if>
        <if test="example.goodsCategoryId1 != null">
          AND `goods_category_id1` = #{example.goodsCategoryId1}
        </if>
        <if test="example.goodsCategoryId2 != null">
          AND `goods_category_id2` = #{example.goodsCategoryId2}
        </if>
        <if test="example.goodsCategoryId3 != null">
          AND `goods_category_id3` = #{example.goodsCategoryId3}
        </if>
        <if test="example.storeNameLike != null and example.webSite==1">
          AND `store_id` in (select `store_id` from `store` where `store_name` like concat('%',#{example.storeNameLike},'%'))
        </if>
        <if test="example.storeNameLike != null and example.webSite==2">
          AND `store_id` in (select `store_id` from `store_name` where `store_name` like concat('%',#{example.storeNameLike},'%') and `web_site` = #{example.webSite})
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `bind_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.StoreBindCategoryExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `store_bind_category`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `store_bind_category`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `store_bind_category`
    <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_bind_category`
    <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_bind_category`
    <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_bind_category`
    <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>