<?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.helpdesk.HelpdeskTransferReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.helpdesk.pojo.HelpdeskTransfer">
    <id column="transfer_id" property="transferId" />
    <result column="member_id" property="memberId" />
    <result column="src_vendor_id" property="srcVendorId" />
    <result column="dst_vendor_id" property="dstVendorId" />
    <result column="switch_time" property="switchTime" />
    <result column="store_id" property="storeId" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `transfer_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.transferIdNotEquals != null">
          AND `transfer_id` != #{example.transferIdNotEquals}
        </if>
        <if test="example.transferIdIn != null">
          AND `transfer_id` in (${example.transferIdIn})
        </if>
        <if test="example.memberId != null">
          AND `member_id` = #{example.memberId}
        </if>
        <if test="example.srcVendorId != null">
          AND `src_vendor_id` = #{example.srcVendorId}
        </if>
        <if test="example.dstVendorId != null">
          AND `dst_vendor_id` = #{example.dstVendorId}
        </if>
        <if test="example.switchTimeAfter != null">
          AND `switch_time` <![CDATA[ >= ]]> #{example.switchTimeAfter}
        </if>
        <if test="example.switchTimeBefore != null">
          AND `switch_time` <![CDATA[ <= ]]> #{example.switchTimeBefore}
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `transfer_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.helpdesk.example.HelpdeskTransferExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `helpdesk_transfer`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `helpdesk_transfer`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `helpdesk_transfer`
    <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 `helpdesk_transfer`
    <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 `helpdesk_transfer`
    <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 `helpdesk_transfer`
    <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>