<?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="com.gz.mapper.borrow.ArchiveBorrowMapper">

    <select id="selectArchiveBorrowHistory" resultType="com.gz.rvo.borrow.ArchiveBorrowHistoryRVO" parameterType="int">
        SELECT ab.id,
               a.dh,
               a.tm,
               ab.create_time,
               ab.borrow_type,
               ab.return_time,
               ab.return_status,
               ab.estimate_return_time,
               ab.audit_status,
               ad.admin_name
        FROM tab_archive_borrow ab
                 LEFT JOIN
             tab_archives a
             ON ab.archive_id = a.id
                 left join
             tab_admin ad
             on ad.id = ab.admin_id
        where ab.deleted = 0
          and a.deleted = 0
          and ad.deleted = 0
          <if test="adminId != null and adminId != ''">
              and ad.id = #{adminId}
          </if>
    </select>

    <select id="selectBorrowInfo" resultType="com.gz.rvo.borrow.AuditInfoRVO">
        SELECT
            ad.admin_name,
            ad.dept_id,
            a.tm,
            ad.id_card,
            a.dh,
            ab.use_purpose,
            ab.create_time,
            ab.return_time,
            ab.borrow_type,
            ad.phone,
            f.original_file_name,
            f.server_file_path
        FROM
            `tab_archive_borrow` ab
                LEFT JOIN tab_archives a
                          ON ab.archive_id = a.id
                LEFT JOIN tab_admin ad
                          ON ab.admin_id = ad.id
                LEFT JOIN tab_file f
                          ON ab.relevant_certification = f.id
        WHERE a.deleted = 0
          AND ab.deleted = 0
          AND ad.deleted = 0
          AND ab.id = #{id}
    </select>
</mapper>
