<?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="org.springblade.modules.business.mapper.FacilityMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="facilityResultMap" type="org.springblade.modules.business.entity.Facility">
        <result column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="create_user_id" property="createUserId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user_id" property="updateUserId"/>
        <result column="update_time" property="updateTime"/>
        <result column="facility_no" property="facilityNo"/>
        <result column="shop_id" property="shopId"/>
        <result column="facility_name" property="facilityName"/>
        <result column="facility_type" property="facilityType"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="facility_status" property="facilityStatus"/>
        <result column="heartbeat_time" property="heartbeatTime"/>
        <result column="add_time" property="addTime"/>
    </resultMap>


    <select id="selectFacilityPage" resultMap="facilityResultMap">
        select * from t_facility where is_delete = 0
    </select>
    <select id="selectGoods" resultType="org.springblade.modules.mall.vo.GoodsInfoVO">
        SELECT
            gi.id,
            gi.goods_name,
            gi.goods_cover,
            fcw.goods_store totalStock,
            fcw.discount,
            fcw.sale_price,
            fcw.id cargoWayId,
            fcw.cargo_no cargoWayNo
        FROM
            t_facility_cargo_way fcw
                JOIN t_goods_info gi ON fcw.goods_id = gi.id
        where fcw.facility_id = #{deviceId}
        <if test="cargoWayId != null">
            and fcw.id = #{cargoWayId}
        </if>
    </select>

</mapper>
