<?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="vip.xiaonuo.disk.mapper.CommonFileMapper">

    <select id="selectCommonFileUser" parameterType="java.lang.Long" resultType="vip.xiaonuo.disk.vo.commonfile.CommonFileUser">
        SELECT c.USER_ID, (SELECT ACCOUNT FROM SYS_USER WHERE user.ID = c.USER_ID) username FROM commonfile a
        LEFT JOIN filepermission b ON a.COMMON_FILE_ID = b.COMMON_FILE_ID
        LEFT JOIN userfile c ON c.USER_FILE_ID = a.USER_FILE_ID
        WHERE b.USER_ID = #{userId}
    </select>

    <select id="selectCommonFileByUser" resultType="vip.xiaonuo.disk.vo.commonfile.CommonFileListVo">
        SELECT * FROM commonfile a
        LEFT JOIN userfile b ON b.USER_FILE_ID = a.USER_FILE_ID
        left join filepermission c on c.COMMON_FILE_ID = a.COMMON_FILE_ID
        WHERE b.USER_ID = #{userId} and c.USER_ID = #{sessionUserId}
    </select>


</mapper>
