<?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="net.lab1024.sa.admin.module.business.wms.base.address.dao.AddressDao">

    <!-- 查询结果列 -->
    <sql id="base_columns">
        t_address
        .
        address_id
        ,
        t_address.name,
        t_address.person,
        t_address.telephone,
        t_address.address,
        t_address.create_time
    </sql>

    <!-- 分页查询 -->
    <select id="queryPage" resultType="net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO">
        SELECT
        <include refid="base_columns"/>
        FROM t_address
        <where>
            <!--收货单位-->
            <if test="queryForm.addressId != null ">
                AND t_address.address_id=#{queryForm.addressId}
            </if>
        </where>
        order by t_address.address_id desc
    </select>

    <select id="queryAddress" resultType="net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO">
        SELECT
        <include refid="base_columns"/>
        FROM t_address
        <where>
            <!--收货单位-->
            <if test="addressSelect.name != null ">
                AND t_address.name like concat(#{addressSelect.name},'%')
            </if>
        </where>
    </select>

    <select id="listByCursor" resultType="net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO">
        SELECT
        t_address.address_id,
        t_address.name,
        t_address.person,
        t_address.telephone,
        t_address.address
        FROM t_address
        <where>
            t_address.address_id > #{lastId}
            <!--收货单位-->
            <if test="queryForm.addressId != null ">
                AND t_address.address_id= #{queryForm.addressId}
            </if>
        </where>
        ORDER BY t_address.address_id ASC -- 必须升序
        LIMIT #{pageSize}
    </select>

</mapper>
