<?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.bonus.system.file.dao.FileUploadDao">

    <!--新增资源文件-->
    <insert id="addFileResource">
        INSERT INTO sys_file_source(file_name, file_suffix, file_path,
                                    file_type, source_id, source_type,
                                    create_user, update_user) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.fileName},
            #{item.fileSuffix},
            #{item.filePath},
            #{item.fileType},
            #{item.sourceId},
            #{item.sourceType},
            #{item.createUser},
            #{item.updateUser}
            )
        </foreach>
    </insert>
    <!--删除资源文件-->
    <update id="delFileResource">
        UPDATE sys_file_source SET del_flag = 0 WHERE source_id IN (
        <foreach collection="list" item="item" separator=",">
            #{item}
        </foreach>
        ) AND source_type = #{sourceType}
    </update>
    <!--获取考勤修改附件-->
    <select id="getFiles" resultType="com.bonus.system.att.entity.AttDataDetailsBean$FilesVo">
        SELECT file_name AS fileName,
               file_path AS filePath,
               SUBSTRING_INDEX(source_id,'@',-1) AS attType
        FROM sys_file_source
        WHERE source_id IN
        <foreach collection="list" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
        AND source_type = 1 AND del_flag = 1
    </select>
</mapper>