<?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.file.mapper.ShareMapper">

    <select id="selectShareList" resultType="com.ruoyi.file.vo.share.ShareListVO">
        SELECT * FROM share a
        LEFT JOIN sharefile b ON b.shareBatchNum = a.shareBatchNum
        LEFT JOIN userfile c ON c.userFileId = b.userFileId
        LEFT JOIN file d ON d.fileId = c.fileId
        WHERE shareFilePath = #{shareFilePath}
        <if test="shareBatchNum != null">
            AND a.shareBatchNum = #{shareBatchNum}
        </if>
        AND c.userId = #{userId}
        order BY shareTime desc
        limit #{beginCount}, #{pageCount}
    </select>

    <select id="selectShareListTotalCount" resultType="java.lang.Integer">
        SELECT count(*) FROM share a
        LEFT JOIN sharefile b ON b.shareBatchNum = a.shareBatchNum
        LEFT JOIN userfile c ON c.userFileId = b.userFileId
        LEFT JOIN file d ON d.fileId = c.fileId
        WHERE shareFilePath = #{shareFilePath}
        <if test="shareBatchNum != null">
            AND a.shareBatchNum = #{shareBatchNum}
        </if>
        AND c.userId = #{userId}
    </select>


</mapper>
