<?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.stock.dao.StockDao">

    <!-- 查询结果列 -->
    <sql id="base_columns">
        t_stock.stock_id,
        t_stock.stock_code,
        t_stock.location_id,
        t_stock.status,
        t_stock.disabled_flag,
        t_stock.stock_type,
        t_stock.remark,
        t_stock.create_time
    </sql>

    <!-- 分页查询 -->
    <select id="queryPage" resultType="net.lab1024.sa.admin.module.business.wms.base.stock.domain.vo.StockVO">
        SELECT
        <include refid="base_columns"/>
        FROM t_stock
        <where>
            <!--容器-->
            <if test="queryForm.stockId != null ">
                AND t_stock.stock_id=#{queryForm.stockId}
            </if>
            <!--库位-->
            <if test="queryForm.locationId != null">
                AND t_stock.location_id=#{queryForm.locationId}
            </if>
            <!--状态-->
            <if test="queryForm.status != null and queryForm.status != ''">
                AND t_stock.status=#{queryForm.status}
            </if>
            <!--是否启用-->
            <if test="queryForm.disabledFlag != null">
                AND t_stock.disabled_flag=#{queryForm.disabledFlag}
            </if>
        </where>
        ORDER BY t_stock.stock_code
    </select>

    <select id="listByCursor" resultType="net.lab1024.sa.admin.module.business.wms.base.stock.domain.vo.StockVO">
        SELECT
        t_stock.stock_id,
        t_stock.stock_code,
        t_stock.location_id,
        t_stock.disabled_flag,
        t_stock.stock_type
        FROM t_stock
        <where>
            t_stock.stock_id > #{lastId}
            <!--容器-->
            <if test="queryForm.stockId != null ">
                AND t_stock.stock_id=#{queryForm.stockId}
            </if>
            <!--库位-->
            <if test="queryForm.locationId != null">
                AND t_stock.location_id=#{queryForm.locationId}
            </if>
            <!--状态-->
            <if test="queryForm.status != null and queryForm.status != ''">
                AND t_stock.status=#{queryForm.status}
            </if>
            <!--是否启用-->
            <if test="queryForm.disabledFlag != null">
                AND t_stock.disabled_flag=#{queryForm.disabledFlag}
            </if>
        </where>
        ORDER BY t_stock.stock_id ASC -- 必须升序
        LIMIT #{pageSize}
    </select>




</mapper>
