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

    <resultMap id="requisitionRecordMap" type="digital.laboratory.platform.reagent.entity.RequisitionRecord">
        <id property="requisitionRecordId" column="requisition_record_id"/>
        <result property="dateOfClaim" column="date_of_claim"/>
        <result property="drawingAmount" column="drawing_amount"/>
        <result property="reagentConsumableId" column="reagent_consumable_id"/>
        <result property="recipientId" column="recipient_id"/>
        <result property="remarks" column="remarks"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="specificationAndModel" column="specification_and_model"/>
        <result property="number" column="number"/>

    </resultMap>

    <resultMap id="requisitionRecordVO" type="digital.laboratory.platform.reagent.vo.RequisitionRecordVO"
               extends="requisitionRecordMap">
        <result property="recipientName" column="recipient_name"></result>
        <result property="reagentConsumableName" column="reagent_consumable_name"></result>
    </resultMap>

    <sql id="getRequisitionRecordVOSQL">
        SELECT rr.*,
               (select rc.reagent_consumable_name
                from reagent_consumables rc
                where rc.reagent_consumable_id = rr.reagent_consumable_id) as reagent_consumable_name,
               (SELECT user.name
                FROM dlp_base.sys_user user
        WHERE user.user_id=rr.recipient_id
            ) AS recipient_name

        FROM requisition_record rr
    </sql>

    <select id="getRequisitionRecordVOPage" resultMap="requisitionRecordVO" resultType="digital.laboratory.platform.reagent.vo.RequisitionRecordVO">
        <include refid="getRequisitionRecordVOSQL"></include>
    </select>
</mapper>
