<?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.entrustment.mapper.EntrustMaterialCheckoutResultMapper">

    <resultMap id="BaseResultMap" type="digital.laboratory.platform.entrustment.entity.EntrustMaterialCheckoutResult">
            <id property="id" column="entrust_material_id" jdbcType="VARCHAR"/>
            <result property="entrustId" column="entrust_id" jdbcType="VARCHAR"/>
            <result property="qualitativeResult" column="qualitative_result" jdbcType="VARCHAR" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
            <result property="quantitativeResult" column="quantitative_result" jdbcType="VARCHAR"/>
            <result property="otherResult" column="other_result" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="EntrustMaterialCheckoutResultVO" type="digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO" extends="BaseResultMap">
        <result property="name" column ="name"/>
        <result property="orderNo" column ="order_no"/>
    </resultMap>

    <sql id="Base_Column_List">
        emr.entrust_material_id,
        emr.entrust_id,
        emr.qualitative_result,
        emr.quantitative_result,
        emr.other_result,
        emr.create_time,
        emr.create_by,
        emr.update_time,
        emr.update_by
    </sql>

    <sql id="getEntrustMaterialCheckoutResultVO">
        SELECT
               <include refid="Base_Column_List"/>,
            em.name,
            em.entrustment_id,
            em.order_no
        FROM b_entrust_material_checkout_result emr
        LEFT JOIN b_entrustment_identification_material em
        ON emr.entrust_material_id = em.id
    </sql>

    <select id="getEntrustMaterialCheckoutResultVOPage" resultMap="EntrustMaterialCheckoutResultVO" resultType="digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO">
        <include refid="getEntrustMaterialCheckoutResultVO"/>
        ${ew.customSqlSegment}
    </select>

    <select id="voList" resultMap="EntrustMaterialCheckoutResultVO" resultType="digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO">
        <include refid="getEntrustMaterialCheckoutResultVO"/>
        ${ew.customSqlSegment}
    </select>
</mapper>
