42 lines
1.5 KiB
Java
42 lines
1.5 KiB
Java
|
package com.guwan.backend.mapper;
|
||
|
|
||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
import com.guwan.backend.entity.SysLog;
|
||
|
import org.apache.ibatis.annotations.Mapper;
|
||
|
import org.apache.ibatis.annotations.Param;
|
||
|
import org.apache.ibatis.annotations.Select;
|
||
|
|
||
|
import java.time.LocalDateTime;
|
||
|
import java.util.List;
|
||
|
|
||
|
@Mapper
|
||
|
public interface SysLogMapper extends BaseMapper<SysLog> {
|
||
|
|
||
|
/**
|
||
|
* 分页查询日志
|
||
|
*/
|
||
|
@Select("SELECT * FROM sys_log WHERE user_id = #{userId} ORDER BY create_time DESC")
|
||
|
IPage<SysLog> selectPageByUserId(Page<SysLog> page, @Param("userId") Long userId);
|
||
|
|
||
|
/**
|
||
|
* 查询指定时间范围内的日志
|
||
|
*/
|
||
|
@Select("SELECT * FROM sys_log WHERE create_time BETWEEN #{startTime} AND #{endTime}")
|
||
|
List<SysLog> selectByTimeRange(@Param("startTime") LocalDateTime startTime,
|
||
|
@Param("endTime") LocalDateTime endTime);
|
||
|
|
||
|
/**
|
||
|
* 查询用户的操作统计
|
||
|
*/
|
||
|
@Select("SELECT operation, COUNT(*) as count FROM sys_log " +
|
||
|
"WHERE user_id = #{userId} GROUP BY operation")
|
||
|
List<OperationCount> selectUserOperationCount(@Param("userId") Long userId);
|
||
|
|
||
|
/**
|
||
|
* 查询错误日志
|
||
|
*/
|
||
|
@Select("SELECT * FROM sys_log WHERE status = 0 ORDER BY create_time DESC LIMIT #{limit}")
|
||
|
List<SysLog> selectLatestErrors(@Param("limit") Integer limit);
|
||
|
}
|