<?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.DetailsOfCentralizedMapper">

    <resultMap id="detailsOfCentralizedMap" type="digital.laboratory.platform.reagent.entity.DetailsOfCentralized">
        <id property="detailsOfCentralizedId" column="details_of_centralized_id"/>
        <result property="quantityPurchased" column="quantity_purchased"/>
        <result property="reagentConsumableId" column="reagent_consumable_id"/>
        <result property="centralizedRequestId" column="centralized_request_id"/>
        <result property="remarks" column="remarks"/>
        <result property="purchaseCatalogueNumber" column="purchase_catalogue_number"/>
        <result property="numberOfApplications" column="number_of_applications"/>
        <result property="replacementReagentConsumableId" column="replacement_reagent_consumable_id"/>
        <result property="replacementQuantity" column="replacement_quantity"/>
    </resultMap>

    <resultMap id="DetailsOfCentralizedVO" type="digital.laboratory.platform.reagent.vo.DetailsOfCentralizedVO"
               extends="detailsOfCentralizedMap">
        <result property="reagentConsumableName" column="reagent_consumable_name"/>
    </resultMap>


    <!-- 根据条件取 DetailsOfCentralizedVO 列表 -->
    <select id="getDetailsOfCentralizedVOList" resultMap="DetailsOfCentralizedVO"
            resultType="digital.laboratory.platform.reagent.vo.DetailsOfCentralizedVO">
        select dc.*,
               (SELECT rc.reagent_consumable_name
                FROM reagent_consumables rc
                WHERE rc.reagent_consumable_id = dc.reagent_consumable_id) AS reagent_consumable_name
        from details_of_centralized dc
        where dc.centralized_request_id = #{centralizedRequestId}
    </select>


</mapper>
