<?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.system.ExpressReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.Express">
    <id column="express_id" property="expressId" />
    <result column="express_name" property="expressName" />
    <result column="express_state" property="expressState" />
    <result column="express_code" property="expressCode" />
    <result column="express_letter" property="expressLetter" />
    <result column="sort" property="sort" />
    <result column="website" property="website" />
    <result column="source" property="source" />
    <result column="template_id" property="templateId" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `express_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.expressIdNotEquals != null">
          AND `express_id` != #{example.expressIdNotEquals}
        </if>
        <if test="example.expressIdIn != null">
          AND `express_id` in (${example.expressIdIn})
        </if>
        <if test="example.expressIdNotIn != null">
          AND `express_id` not in (${example.expressIdNotIn})
        </if>
        <if test="example.expressName != null">
          AND `express_name` = #{example.expressName}
        </if>
        <if test="example.expressNameLike != null">
          AND `express_name` like concat('%',#{example.expressNameLike},'%')
        </if>
        <if test="example.expressState != null">
          AND `express_state` = #{example.expressState}
        </if>
        <if test="example.expressStateIn != null">
          AND `express_state` in (${example.expressStateIn})
        </if>
        <if test="example.expressStateNotIn != null">
          AND `express_state` not in (${example.expressStateNotIn})
        </if>
        <if test="example.expressStateNotEquals != null">
          AND `express_state` != #{example.expressStateNotEquals}
        </if>
        <if test="example.expressCode != null">
          AND `express_code` = #{example.expressCode}
        </if>
        <if test="example.expressLetter != null">
          AND `express_letter` = #{example.expressLetter}
        </if>
        <if test="example.sort != null">
          AND `sort` = #{example.sort}
        </if>
        <if test="example.website != null">
          AND `website` = #{example.website}
        </if>
        <if test="example.source != null">
          AND `source` = #{example.source}
        </if>
        <if test="example.templateId != null">
          AND `template_id` = #{example.templateId}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `express_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.system.example.ExpressExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `sys_express`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `sys_express`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `sys_express`
    <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 `sys_express`
    <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 `sys_express`
    <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 `sys_express`
    <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>