<?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.OperationLogMapper">
     <select id="selectOperationLog" resultType="vip.xiaonuo.disk.vo.operationLog.OperationLogBeanVo">
         SELECT
             a.user_file_id AS userFileId,
             b.file_name AS fileName,
             a.time
         FROM
             operationlog a
                 LEFT JOIN userfile b ON
                 a.USER_FILE_ID = b.USER_FILE_ID
         WHERE
             a.TYPE = #{type} AND a.user_id=#{userId}

          order by a.time desc
         limit 10
     </select>

    <select id="getAllList" resultType="map">
        SELECT
            a.user_file_id AS userFileId,
            b.file_name AS fileName,
            a.time timedate,
            a.type typeNum,
            a.user_id userId,
            su.name
        FROM
            operationlog a
        LEFT JOIN userfile b ON
        a.USER_FILE_ID = b.USER_FILE_ID
        LEFT JOIN sys_user su ON
        a.user_id = su.ID
        <where>
            <if test="type != null and type != ''">
                AND a.type = #{type}
            </if>
            <if test="startDate != null and startDate != ''">
                AND a.time >= #{startDate}
            </if>
            <if test="endDate != null and endDate != ''">
                AND a.time &lt;= #{endDate}
            </if>
        </where>
    </select>



</mapper>
