<?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="top.continew.admin.system.mapper.FileMapper">

    <select id="selectFilesPage" resultType="top.continew.admin.system.model.resp.FileResp">
        SELECT
        id,
        NAME,
        size,
        extension,
        type,
        thumbnail_size,
        thumbnail_url,
        storage_id,
        dept_id,
        create_user,
        create_time,
        update_user,
        update_time,
        CONCAT( ( SELECT domain FROM sys_storage WHERE `status` = 1 ), "/", url ) url,
        CONCAT( ( SELECT domain FROM sys_storage WHERE `status` = 1 ), "/", thumbnail_url ) thumbnailUrl
        FROM
        sys_file
        <where>
            1=1
                 <if test="query.createUser!=null and query.createUser!=''">
                     and (create_user = #{query.createUser}
                    or  create_user in(select id from sys_user where dept_id=#{query.createUser})
                    or create_user in( select id from sys_user where dept_id in(
                     select id from sys_dept where FIND_IN_SET(#{query.createUser},ancestors)
                     ))
                     )
                 </if>
        order by create_time desc
        </where>
    </select>


</mapper>
