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

    <resultMap id="destructionDetailMap" type="digital.laboratory.platform.imr.entity.DestructionDetail">
        <id property="id" column="id"/>
        <result property="destructionId" column="destruction_id"/>
        <result property="sampleId" column="sample_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"/>
    </resultMap>



    <resultMap id="outSampleVo" type="digital.laboratory.platform.imr.vo.OutSampleVO">
        <id property="id" column="id"/>
        <result column="sample_id" property="sampleId"/>
        <result property="sampleNo" column="sample_no"/>
        <result property="name" column="name"/>
        <result property="storageMethod" column="storage_method"/>
        <result property="category" column="category"/>
        <result property="sampleType" column="sample_type"/>
        <result property="form" column="form"/>
    </resultMap>


    <select id="getPublicityDetail" resultMap="outSampleVo">
        select s.sample_type,
               s.id as sample_id,
               s.storage_method,
               im.type as category,
               im.form,
               s.name,
               s.sample_no,
               dd.id
        from dlp_identification_material_repository.destruction_detail dd
        join dlp_identification_material_transfer.b_sample s
        on s.id = dd.sample_id
        join dlp_identification_material_transfer.identification_material im
        on s.identification_material_id = im.id
        where dd.destruction_id = #{id}
    </select>


    <!--
     查询审核人
     getApprove-->

    <resultMap id="userMap" type="digital.laboratory.platform.imr.dto.UserInfoDTO">
        <id property="userId" column="user_id"/>
        <result column="name" property="name"/>
        <result column="department" property="department"/>
        <result column="position" property="position"/>
    </resultMap>

    <!--List<UserInfoDTO>  getRecipient(String name);;-->

    <select id="getApprove" resultMap="userMap">
        select  u.name,
        u.user_id,
        u.department,
        u.position
        from dlp_base.b_staff b
        left join  dlp_base.sys_user u
        on b.user_id = u.user_id
        <where>
            <if test="name!=null and name!=''">
                u.name like concat('%',#{name},'%')
            </if>
            and u.user_id != #{userId}
        </where>
    </select>





</mapper>