<?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.inspection.mapper.TestRecordMapper">

    <resultMap id="testRecordMap" type="digital.laboratory.platform.inspetion.api.entity.TestRecord">
        <id property="id" column="id"/>
        <result property="testUserId" column="test_user_id"/>
        <result property="businessType" column="business_type"/>
        <result property="testSerialNumber" column="test_serial_number"/>
        <result property="sampleTestList" column="sample_test_list" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="deviceIdList" column="device_id_list" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="reagentConsumablesList" column="reagent_consumables_list" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="standardSolution" column="standard_solution" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="sampleSolution" column="sample_solution" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="testMethodList" column="test_method_list" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="deviceUseCondition" column="device_use_condition" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
        <result property="testAtlas" column="test_atlas"/>
    </resultMap>

    <resultMap id="testRecordMapVo" type="digital.laboratory.platform.inspetion.api.vo.TestRecordVo"
               extends="testRecordMap">
        <result property="testUserName" column="test_user_name"></result>
    </resultMap>

    <select id="getTestRecordMapById" resultMap="testRecordMapVo">
        select t.*,
               (select u.name from dlp_base.sys_user u where u.user_id = t.test_user_id) as test_user_name
        from b_test_record t
        where t.id = #{id}
    </select>

    <sql id="getTestRecordMapSQL">
        select t.*,
               (select u.name from dlp_base.sys_user u where u.user_id = t.test_user_id) as test_user_name
        from b_test_record t
    </sql>

    <select id="getTestRecordMapPage" resultMap="testRecordMapVo">
        <include refid="getTestRecordMapSQL"></include>
        ${ew.customSqlSegment}
    </select>

    <select id="getTestRecordMapList" resultMap="testRecordMapVo">
        <include refid="getTestRecordMapSQL"></include>
            ${ew.customSqlSegment}
    </select>
</mapper>
