<?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.jeethink.receive.mapper.ArchivesFileMapper">
    <insert id="insertArchivesFile" parameterType="ArchivesFile">
        insert into archives_file (archives_file_id, rs_file_type, jk_file_date, check_hospital, check_conclusion, check_date, archives_id, create_time, update_time, create_user, update_user, deleted)
            VALUES (#{archivesFileId}, #{rsFileType}, #{jkFileDate}, #{checkHospital}, #{checkConclusion}, #{checkDate}, #{archivesId}, now(), now(), #{createUser}, #{updateUser}, '0')
    </insert>
    <update id="removeByArchivesId">
        update archives_file set deleted = '1' where archives_id = #{0}
    </update>
    <select id="selectArchivesFileList" resultType="ArchivesFile">
        select archives_file_id, rs_file_type, jk_file_date, check_hospital, check_conclusion, check_date, archives_id, create_time, update_time, create_user, update_user
        from archives_file where deleted = '0' and archives_id = #{0}
        order by cast(rs_file_type as SIGNED) asc, jk_file_date desc
    </select>
    <select id="selectArchiveFileId"  resultType="String">
        select archives_file_id fileObjectId from archives_file f
        LEFT JOIN archives_master m on f.archives_id=m.archives_id
        LEFT JOIN sys_user u on u.user_id=m.user_id
        where  u.user_num=#{userNumber} and f.rs_file_type=#{type} and f.deleted='0' and m.deleted='0' and u.del_flag='0'
        limit 1
    </select>
    <select id="selectArchivesFileById" parameterType="String" resultType="java.util.HashMap">
        select sf.file_name fileName ,sf.FILE_URL feilePath from system_file sf
        LEFT JOIN archives_file af on af.archives_file_id=sf.FILE_OBJECT_ID
        LEFT JOIN archives_master am on af.archives_id=am.archives_id
        WHERE am.archives_id=#{archivesId} and sf.FILE_DELETE_TYPE='0' and af.deleted='0'
    </select>
</mapper>