<?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.czg.service.product.mapper.ProdConsRelationMapper">

    <select id="getProductListByConId" resultType="com.czg.product.dto.ProductBriefDTO">
        select t2.id,
               t2.category_id,
               t2.name,
               t2.cover_img
        from tb_prod_cons_relation t1
                 inner join tb_product t2 on t1.product_id = t2.id
        where t1.cons_info_id = #{conId}
    </select>
    <select id="selectListByProdId" resultType="com.czg.product.dto.ProdConsRelationDTO">
        SELECT t1.*,
               t2.con_unit,
               t2.con_name,
               t2.price,
               t2.stock_number,
               t1.surplus_stock
        FROM tb_prod_cons_relation t1
                 LEFT JOIN tb_cons_info t2 on t1.cons_info_id = t2.id
        WHERE t1.product_id = #{prodId}
    </select>
</mapper>