From 8beb75cbc876e6dee437f195202b48fe9e5bbf48 Mon Sep 17 00:00:00 2001 From: ovo Date: Sat, 7 Dec 2024 19:06:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guwan/backend/mapper/SysLogMapper.java | 42 +++++++++++++++++++ src/main/resources/mapper/SysLogMapper.xml | 42 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/main/java/com/guwan/backend/mapper/SysLogMapper.java create mode 100644 src/main/resources/mapper/SysLogMapper.xml diff --git a/src/main/java/com/guwan/backend/mapper/SysLogMapper.java b/src/main/java/com/guwan/backend/mapper/SysLogMapper.java new file mode 100644 index 0000000..b2668ab --- /dev/null +++ b/src/main/java/com/guwan/backend/mapper/SysLogMapper.java @@ -0,0 +1,42 @@ +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 { + + /** + * 分页查询日志 + */ + @Select("SELECT * FROM sys_log WHERE user_id = #{userId} ORDER BY create_time DESC") + IPage selectPageByUserId(Page page, @Param("userId") Long userId); + + /** + * 查询指定时间范围内的日志 + */ + @Select("SELECT * FROM sys_log WHERE create_time BETWEEN #{startTime} AND #{endTime}") + List 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 selectUserOperationCount(@Param("userId") Long userId); + + /** + * 查询错误日志 + */ + @Select("SELECT * FROM sys_log WHERE status = 0 ORDER BY create_time DESC LIMIT #{limit}") + List selectLatestErrors(@Param("limit") Integer limit); +} \ No newline at end of file diff --git a/src/main/resources/mapper/SysLogMapper.xml b/src/main/resources/mapper/SysLogMapper.xml new file mode 100644 index 0000000..d76f157 --- /dev/null +++ b/src/main/resources/mapper/SysLogMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + \ No newline at end of file