<?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.imr.mapper.SampleApplyDetailedMapper">

    <resultMap id="sampleApplyDetailedMap" type="digital.laboratory.platform.imr.entity.SampleApplyDetailed">
        <id property="id" column="id"/>
        <result property="sampleId" column="sample_id"/>
        <result property="applyId" column="apply_id"/>
        <result property="status" column="status"/>
        <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="detail" type="digital.laboratory.platform.imr.vo.ApplySampleVO" extends="sampleApplyDetailedMap">
        <result property="name" column="name"/>
        <result property="sampleNo" column="sample_no"/>
        <result property="form" column="form"/>
        <result property="sampleType" column="sample_type"/>
        <result property="category" column="category"/>
        <result property="storageMethod" column="storage_method"/>
    </resultMap>

    <select id="getDetail" resultMap="detail">
        select detailed.*,
               sample.sample_no,
               sample.sample_type,
               sample.name,
               im.form,
               sample.storage_method,
               im.type as category
        from dlp_identification_material_repository.sample_apply_detailed detailed
        join dlp_identification_material_transfer.b_sample sample
        on sample.id = detailed.sample_id
        join dlp_identification_material_transfer.identification_material im
        on im.id = sample.identification_material_id
        where detailed.apply_id = #{id}
    </select>
</mapper>
