<?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.ruoyi.oa.mapper.EmployeeFilesMapper">

    <resultMap type="com.ruoyi.oa.domain.EmployeeFiles" id="EmployeeFilesResult">
        <result property="fileId" column="file_id"/>
        <result property="userId" column="user_id"/>

        <result property="fileType" column="file_type"/>
        <result property="fileName" column="file_name"/>
        <result property="filePath" column="file_path"/>
        <result property="uploadTime" column="upload_time"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>

    <delete id="deleteByUserId" parameterType="Long">
        delete from employee_files where user_id = #{userId}
    </delete>


    <select id="selectFileUserVoPage" resultType="com.ruoyi.oa.domain.vo.FileUser">
        select su.user_id, su.nick_name, joining_date, count(file_id) AS fileTotal
        from sys_user su
                 left join employee_onboarding eo on su.user_id = eo.user_id
                 left join fad_oa.employee_files ef on su.user_id = ef.user_id AND ef.del_flag = '0'
            ${ew.getCustomSqlSegment}
        GROUP BY su.user_id,
                 su.nick_name,
                 eo.joining_date

    </select>
    <select id="selectVoListPlus" resultType="com.ruoyi.oa.domain.vo.EmployeeFilesVo">
        select
            employee_files.upload_time as uploadTime,
               so.oss_id as ossId,
               original_name as fileName,
               url as filePath,
               so.create_time,
               so.create_by,
               so.update_time,
               so.update_by
        from employee_files
                 left join sys_oss so on find_in_set(so.oss_id, file_path)
            ${ew.getCustomSqlSegment}
    </select>


</mapper>
