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

    <resultMap id="evaluationFormMap" type="digital.laboratory.platform.reagent.entity.EvaluationForm">
        <id property="evaluationFormId" column="evaluation_form_id"/>
        <result property="commentsFromPrimary" column="comments_from_primary"/>
        <result property="commentsFromThreeLevel" column="comments_from_three_level"/>
        <result property="contactNumber" column="contact_number"/>
        <result property="contactPerson" column="contact_person"/>
        <result property="primaryUserId" column="primary_user_id"/>
        <result property="commentsFromSecondary" column="comments_from_secondary"/>
        <result property="secondaryUserId" column="secondary_user_id"/>
        <result property="serviceProviderAndSupplierId" column="service_provider_and_supplier_id"/>
        <result property="threeLevelUserId" column="three_level_user_id"/>
        <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="commentsDateFromPrimary" column="comments_date_from_primary"/>
        <result property="commentsResultFromSecondary" column="comments_result_from_secondary"/>
        <result property="commentsDateFromSecondary" column="comments_date_from_secondary"/>
        <result property="commentsResultFromThreeLevel" column="comments_result_from_three_level"/>
        <result property="commentsDateFromThreeLevel" column="comments_date_from_three_level"/>
        <result property="supplierBusinessLicense" column="supplier_business_license"/>
        <result property="supplierPassesQualityAssuranceSystem" column="supplier_passes_quality_assurance_system"/>
        <result property="supplierProductCertification" column="supplier_product_certification"/>
        <result property="checkAndCalibrateEfficiencyOfSupplies" column="check_and_calibrate_efficiency_of_supplies"/>
        <result property="overallSupplierServiceSatisfaction" column="overall_supplier_service_satisfaction"/>
        <result property="supplierAttitude" column="supplier_attitude"/>
        <result property="supplierEquipmentAndFacilities" column="supplier_equipment_and_facilities"/>
        <result property="supplierTechnologyAndManagementCapability"
                column="supplier_technology_and_management_capability"/>
        <result property="whetherTheSupplierDeliversOnTime" column="whether_the_supplier_delivers_on_time"/>
        <result property="supplierInformationId" column="supplier_information_id"/>
        <result property="status" column="status"/>
        <result property="number" column="number"/>
    </resultMap>
    <resultMap id="evaluationFormVO" type="digital.laboratory.platform.reagent.vo.EvaluationFormVO"
               extends="evaluationFormMap">
        <result property="primaryUserName" column="primary_user_name"></result>
        <result property="secondaryUserName" column="secondary_user_name"></result>
        <result property="threeLevelUserName" column="three_level_user_name"></result>
    </resultMap>
    <select id="getEvaluationForm" resultMap="evaluationFormVO"
            resultType="digital.laboratory.platform.reagent.vo.EvaluationFormVO">
        SELECT ef.*,
             (select user.name
        from dlp_base.sys_user user
        where user.user_id = ef.primary_user_id)
            AS primary_user_name,
            (select user.name
        from dlp_base.sys_user user
        where user.user_id = ef.secondary_user_id)
           AS secondary_user_name,
            (select user.name
        from dlp_base.sys_user user
        where user.user_id = ef.three_level_user_id)
            AS three_level_user_name
        FROM evaluation_form ef
        WHERE ef.evaluation_form_id = #{evaluationFormId}
    </select>
</mapper>
