Add SysLog
This commit is contained in:
@@ -18,4 +18,33 @@ create table if not exists t_user
|
|||||||
constraint t_user_unique unique (username, deleted)
|
constraint t_user_unique unique (username, deleted)
|
||||||
) comment '用户表';
|
) comment '用户表';
|
||||||
|
|
||||||
insert into t_user (id, username, password, locking, enable) value (0, 'admin', '$2a$10$3wDGdzTZlC..7eY6u2XM5u78xUQo0z5Sj5yOpneD4QJ0q/TA5TY0S', 0, 1)
|
insert into t_user (id, username, password, locking, enable) value (0, 'admin',
|
||||||
|
'$2a$10$3wDGdzTZlC..7eY6u2XM5u78xUQo0z5Sj5yOpneD4QJ0q/TA5TY0S',
|
||||||
|
0, 1);
|
||||||
|
|
||||||
|
drop table if exists t_sys_log;
|
||||||
|
create table t_sys_log
|
||||||
|
(
|
||||||
|
id bigint not null,
|
||||||
|
log_type varchar(50) not null comment '日志类型',
|
||||||
|
operate_user_id bigint not null comment '操作用户',
|
||||||
|
operate_time datetime not null default (utc_timestamp()) comment '操作时间',
|
||||||
|
request_uri varchar(500) default null comment '请求 URI',
|
||||||
|
request_method varchar(10) default null comment '请求方式',
|
||||||
|
request_params text comment '请求参数',
|
||||||
|
request_ip varchar(20) not null comment '请求 IP',
|
||||||
|
request_server_address varchar(50) not null comment '请求服务器地址',
|
||||||
|
is_exception char(1) default null comment '是否异常',
|
||||||
|
exception_info text comment '异常信息',
|
||||||
|
start_time datetime not null comment '开始时间',
|
||||||
|
end_time datetime not null comment '结束时间',
|
||||||
|
execute_time int default null comment '执行时间',
|
||||||
|
user_agent varchar(500) default null comment '用户代理',
|
||||||
|
device_name varchar(100) default null comment '操作系统',
|
||||||
|
browser_name varchar(100) default null comment '浏览器名称',
|
||||||
|
primary key (id) using btree,
|
||||||
|
key idx_sys_log_log_type (log_type) using btree,
|
||||||
|
key idx_sys_log_operate_user_id (operate_user_id) using btree,
|
||||||
|
key idx_sys_log_is_exception (is_exception) using btree,
|
||||||
|
key idx_sys_log_operate_time (operate_time) using btree
|
||||||
|
) comment '系统日志表';
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package top.fatweb.api.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统日志表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author FatttSnake
|
||||||
|
* @since 2023-10-18
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/sysLog")
|
||||||
|
class SysLogController
|
||||||
|
|
||||||
122
src/main/kotlin/top/fatweb/api/entity/SysLog.kt
Normal file
122
src/main/kotlin/top/fatweb/api/entity/SysLog.kt
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package top.fatweb.api.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统日志表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author FatttSnake
|
||||||
|
* @since 2023-10-18
|
||||||
|
*/
|
||||||
|
@TableName("t_sys_log")
|
||||||
|
class SysLog : Serializable {
|
||||||
|
|
||||||
|
@TableId("id")
|
||||||
|
var id: Long? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志类型
|
||||||
|
*/
|
||||||
|
@TableField("log_type")
|
||||||
|
var logType: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作用户
|
||||||
|
*/
|
||||||
|
@TableField("operate_user_id")
|
||||||
|
var operateUserId: Long? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
@TableField("operate_time")
|
||||||
|
var operateTime: LocalDateTime? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求 URI
|
||||||
|
*/
|
||||||
|
@TableField("request_uri")
|
||||||
|
var requestUri: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求方式
|
||||||
|
*/
|
||||||
|
@TableField("request_method")
|
||||||
|
var requestMethod: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@TableField("request_params")
|
||||||
|
var requestParams: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求 IP
|
||||||
|
*/
|
||||||
|
@TableField("request_ip")
|
||||||
|
var requestIp: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求服务器地址
|
||||||
|
*/
|
||||||
|
@TableField("request_server_address")
|
||||||
|
var requestServerAddress: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否异常
|
||||||
|
*/
|
||||||
|
@TableField("is_exception")
|
||||||
|
var isException: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常信息
|
||||||
|
*/
|
||||||
|
@TableField("exception_info")
|
||||||
|
var exceptionInfo: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@TableField("start_time")
|
||||||
|
var startTime: LocalDateTime? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
@TableField("end_time")
|
||||||
|
var endTime: LocalDateTime? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行时间
|
||||||
|
*/
|
||||||
|
@TableField("execute_time")
|
||||||
|
var executeTime: Int? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户代理
|
||||||
|
*/
|
||||||
|
@TableField("user_agent")
|
||||||
|
var userAgent: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作系统
|
||||||
|
*/
|
||||||
|
@TableField("device_name")
|
||||||
|
var deviceName: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览器名称
|
||||||
|
*/
|
||||||
|
@TableField("browser_name")
|
||||||
|
var browserName: String? = null
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "SysLog(id=$id, logType=$logType, operateUserId=$operateUserId, operateTime=$operateTime, requestUri=$requestUri, requestMethod=$requestMethod, requestParams=$requestParams, requestIp=$requestIp, requestServerAddress=$requestServerAddress, isException=$isException, exceptionInfo=$exceptionInfo, startTime=$startTime, endTime=$endTime, executeTime=$executeTime, userAgent=$userAgent, deviceName=$deviceName, browserName=$browserName)"
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/main/kotlin/top/fatweb/api/mapper/SysLogMapper.kt
Normal file
16
src/main/kotlin/top/fatweb/api/mapper/SysLogMapper.kt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package top.fatweb.api.mapper;
|
||||||
|
|
||||||
|
import top.fatweb.api.entity.SysLog;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统日志表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author FatttSnake
|
||||||
|
* @since 2023-10-18
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
interface SysLogMapper : BaseMapper<SysLog>
|
||||||
14
src/main/kotlin/top/fatweb/api/service/ISysLogService.kt
Normal file
14
src/main/kotlin/top/fatweb/api/service/ISysLogService.kt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package top.fatweb.api.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService
|
||||||
|
import top.fatweb.api.entity.SysLog
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统日志表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author FatttSnake
|
||||||
|
* @since 2023-10-18
|
||||||
|
*/
|
||||||
|
interface ISysLogService : IService<SysLog>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package top.fatweb.api.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
import top.fatweb.api.entity.SysLog
|
||||||
|
import top.fatweb.api.mapper.SysLogMapper
|
||||||
|
import top.fatweb.api.service.ISysLogService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统日志表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author FatttSnake
|
||||||
|
* @since 2023-10-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
class SysLogServiceImpl : ServiceImpl<SysLogMapper, SysLog>(), ISysLogService
|
||||||
5
src/main/resources/mapper/SysLogMapper.xml
Normal file
5
src/main/resources/mapper/SysLogMapper.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?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="top.fatweb.api.mapper.SysLogMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user