<?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.shinsoft.sto.mapper.ware.StoreChangeMapper">

    <resultMap id="StoreChangeResultMap" type="com.shinsoft.sto.model.ware.StoreChange">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
        <result column="ware_id" property="wareId" jdbcType="VARCHAR"/>
        <result column="stack_id" property="stackId" jdbcType="VARCHAR"/>
        <result column="store_id" property="storeId" jdbcType="VARCHAR"/>
        <result column="layer_no" property="layerNo" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="QueryWhere">
        where 1=1
        <if test="parms.wareId != null and parms.wareId != ''">
            and ws.ware_id = #{parms.wareId}
        </if>
        <if test="parms.stackId != null and parms.stackId != ''">
            and ws.stack_id = #{parms.stackId}
        </if>
        <if test="parms.storeId != null and parms.storeId != ''">
            and ws.store_id = #{parms.storeId}
        </if>
        <if test="parms.layerNo != null and parms.layerNo != ''">
            and ws.layer_no = #{parms.layerNo}
        </if>
    </sql>

    <select id="selectStoreChangePage" resultMap="StoreChangeResultMap" parameterType="map">
        select
            ws.id,
            ws.belong_id,
            ws.ware_id,
            ws.stack_id,
            ws.store_id,
            ws.layer_no
        from T_WARE_STORE ws
        <include refid="QueryWhere"/>
        order by ws.id desc
    </select>
</mapper>

