<?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="digital.laboratory.platform.reagent.mapper.PurchaseListDetailsMapper">

    <resultMap id="purchaseListDetailsMap" type="digital.laboratory.platform.reagent.entity.PurchaseListDetails">
        <id property="purchaseListDetailsId" column="purchase_list_details_id"/>
        <result property="purchaseCatalogueNumber" column="purchase_catalogue_number"/>
        <result property="purchaseListId" column="purchase_list_id"/>
        <result property="purchaseQuantity" column="purchase_quantity"/>
        <result property="reagentConsumableId" column="reagent_consumable_id"/>
        <result property="remarks" column="remarks"/>
        <result property="supplierId" column="supplier_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>

    </resultMap>

    <resultMap id="purchaseListDetailsVO" type="digital.laboratory.platform.reagent.vo.PurchaseListDetailsVO"
               extends="purchaseListDetailsMap">
        <result property="reagentConsumableName" column="reagent_consumable_name"/>
        <result property="supplierName" column="supplier_name"/>
    </resultMap>

    <select id="getPurchaseListDetailsVOList" resultMap="purchaseListDetailsVO" resultType="digital.laboratory.platform.reagent.vo.PurchaseListDetailsVO">
        SELECT pd.*,
               (select rc.reagent_consumable_name from reagent_consumables rc where rc.reagent_consumable_id = pd.reagent_consumable_id) AS reagent_consumable_name
        FROM purchase_list_details pd
        WHERE pd.purchase_list_id = #{purchaseListId}
    </select>
</mapper>
