mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
【优化】增强访问日志,支持是否记录、脱敏、操作信息等功能
This commit is contained in:
@ -44,8 +44,11 @@ public class ApiAccessLogCreateReqDTO {
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String requestParams;
|
||||
/**
|
||||
* 响应结果
|
||||
*/
|
||||
private String responseBody;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
@ -57,6 +60,21 @@ public class ApiAccessLogCreateReqDTO {
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
private String operateModule;
|
||||
/**
|
||||
* 操作名
|
||||
*/
|
||||
private String operateName;
|
||||
/**
|
||||
* 操作分类
|
||||
*
|
||||
* 枚举,参见 OperateTypeEnum 类
|
||||
*/
|
||||
private Integer operateType;
|
||||
|
||||
/**
|
||||
* 开始请求时间
|
||||
*/
|
||||
|
@ -48,6 +48,10 @@ public class ApiAccessLogRespVO {
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "响应结果")
|
||||
@ExcelProperty("响应结果")
|
||||
private String responseBody;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
@ -56,6 +60,19 @@ public class ApiAccessLogRespVO {
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "操作模块", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品模块")
|
||||
@ExcelProperty("操作模块")
|
||||
private String operateModule;
|
||||
|
||||
@Schema(description = "操作名", requiredMode = Schema.RequiredMode.REQUIRED, example = "创建商品")
|
||||
@ExcelProperty("操作名")
|
||||
private String operateName;
|
||||
|
||||
@Schema(description = "操作分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "操作分类", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.OPERATE_TYPE)
|
||||
private Integer operateType;
|
||||
|
||||
@Schema(description = "开始请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("开始请求时间")
|
||||
private LocalDateTime beginTime;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
@ -70,6 +71,10 @@ public class ApiAccessLogDO extends BaseDO {
|
||||
* body: Quest Body
|
||||
*/
|
||||
private String requestParams;
|
||||
/**
|
||||
* 响应结果
|
||||
*/
|
||||
private String responseBody;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
@ -81,6 +86,21 @@ public class ApiAccessLogDO extends BaseDO {
|
||||
|
||||
// ========== 执行相关字段 ==========
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
private String operateModule;
|
||||
/**
|
||||
* 操作名
|
||||
*/
|
||||
private String operateName;
|
||||
/**
|
||||
* 操作分类
|
||||
*
|
||||
* 枚举 {@link OperateTypeEnum}
|
||||
*/
|
||||
private Integer operateType;
|
||||
|
||||
/**
|
||||
* 开始请求时间
|
||||
*/
|
||||
@ -93,6 +113,7 @@ public class ApiAccessLogDO extends BaseDO {
|
||||
* 执行时长,单位:毫秒
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 结果码
|
||||
*
|
||||
|
@ -94,8 +94,12 @@ CREATE TABLE IF NOT EXISTS "infra_api_access_log" (
|
||||
"request_method" varchar(16) not null default '',
|
||||
"request_url" varchar(255) not null default '',
|
||||
"request_params" varchar(8000) not null default '',
|
||||
"response_body" varchar(8000) not null default '',
|
||||
"user_ip" varchar(50) not null,
|
||||
"user_agent" varchar(512) not null,
|
||||
`operate_module` varchar(50) NOT NULL,
|
||||
`operate_name` varchar(50) NOT NULL,
|
||||
`operate_type` bigint(4) NOT NULL DEFAULT '0',
|
||||
"begin_time" timestamp not null,
|
||||
"end_time" timestamp not null,
|
||||
"duration" integer not null,
|
||||
@ -108,7 +112,7 @@ CREATE TABLE IF NOT EXISTS "infra_api_access_log" (
|
||||
"deleted" bit not null default false,
|
||||
"tenant_id" bigint not null default '0',
|
||||
primary key ("id")
|
||||
) COMMENT 'API 访问日志表';
|
||||
) COMMENT 'API 访问日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "infra_api_error_log" (
|
||||
"id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
|
||||
|
Reference in New Issue
Block a user