<?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.fjhx.mapper.material.MaterialMapper">

    <select id="getMaterialBySupplierId" resultType="java.util.Map">
        select m.id              materialId,
               m.name            materialName,
               m.code            materialCode,
               m.safety_warn_day safetyWarnDay
        from supplier_price sp
                 inner join material m on sp.material_id = m.id
        where sp.supplier_id = #{supplierId}
    </select>

    <select id="getStockPage" resultType="java.util.LinkedHashMap">
        select m.id,
               m.name,
               m.code,
               ifnull(s.quantity, 0) quantity,
               m.unit,
               m.spec
        from material m
                 left join stock s on m.id = s.material_id
            ${ew.customSqlSegment}
    </select>

</mapper>
