<?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.njzscloud.dispose.wh.mapper.InOrderMapper">
    <resultMap id="BaseResultMap" type="com.njzscloud.dispose.wh.pojo.result.SearchInOrderResult">
        <id column="id" property="id"/>
        <result column="sn" property="sn"/>
        <result column="responsible_id" property="responsibleId"/>
        <result column="nickname" property="nickname"/>
        <result column="warehouse_id" property="warehouseId"/>
        <result column="warehouse_name" property="warehouseName"/>
        <result column="location" property="location"/>
        <result column="in_time" property="inTime"/>
        <result column="order_id" property="orderId"/>
        <result column="order_sn" property="orderSn"/>
        <result column="goods_category_id" property="goodsCategoryId"/>
        <result column="goods_category_name" property="goodsCategoryName"/>
        <result column="goods_id" property="goodsId"/>
        <result column="goods_name" property="goodsName"/>
        <result column="good_sn" property="goodSn"/>
        <result column="quantity" property="quantity"/>
        <result column="unit" property="unit"/>
        <result column="memo" property="memo"/>
        <result column="creator_id" property="creatorId"/>
        <result column="modifier_id" property="modifierId"/>
        <result column="create_time" property="createTime"/>
        <result column="modify_time" property="modifyTime"/>
        <result column="deleted" property="deleted"/>
    </resultMap>

    <sql id="Base_Column_List">
        wio.id AS id,
        wio.sn AS sn,
        wio.responsible_id AS responsible_id,
        su.nickname,
        wio.warehouse_id AS warehouse_id,
	    ww.warehouse_name,
        wio.location AS location,
        wio.in_time AS in_time,
        wio.order_id AS order_id,
        wio.order_sn AS order_sn,
        wio.goods_category_id AS goods_category_id,
        wio.goods_category_name AS goods_category_name,
        wio.goods_id AS goods_id,
        wio.goods_name AS goods_name,
        wio.good_sn AS good_sn,
        wio.quantity AS quantity,
        wio.unit AS unit,
        wio.memo AS memo,
        wio.creator_id AS creator_id,
        wio.modifier_id AS modifier_id,
        wio.create_time AS create_time,
        wio.modify_time AS modify_time,
        wio.deleted AS deleted
    </sql>

    <select id="detail" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM wh_in_order wio
        LEFT JOIN sys_user su ON su.id = wio.responsible_id
        LEFT JOIN wh_warehouse ww ON ww.id = wio.warehouse_id
        WHERE wio.id = #{id}
    </select>

    <select id="paging" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM wh_in_order wio
        LEFT JOIN sys_user su ON su.id = wio.responsible_id
        LEFT JOIN wh_warehouse ww ON ww.id = wio.warehouse_id
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
</mapper>
