refactor: 💥 适配 ContiNew Starter Log(日志模块)

1.continew-starter 1.0.1-SNAPSHOT => 1.1.0-SNAPSHOT
2.日志表结构及相关管理 UI 变更
This commit is contained in:
2023-12-17 14:07:44 +08:00
parent 349899b4fc
commit 9bf015059b
35 changed files with 308 additions and 893 deletions

View File

@@ -43,13 +43,13 @@ import top.charles7c.continew.admin.common.constant.CacheConstants;
import top.charles7c.continew.admin.common.model.dto.LoginUser;
import top.charles7c.continew.admin.common.util.SecureUtils;
import top.charles7c.continew.admin.common.util.helper.LoginHelper;
import top.charles7c.continew.admin.monitor.annotation.Log;
import top.charles7c.continew.admin.system.model.resp.UserDetailResp;
import top.charles7c.continew.admin.system.service.UserService;
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
import top.charles7c.continew.starter.core.util.ExceptionUtils;
import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
import top.charles7c.continew.starter.extension.crud.model.resp.R;
import top.charles7c.continew.starter.log.common.annotation.Log;
/**
* 认证 API
@@ -115,9 +115,10 @@ public class AuthController {
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx",
in = ParameterIn.HEADER)
@PostMapping("/logout")
public R logout() {
public R<Object> logout() {
Object loginId = StpUtil.getLoginId(-1L);
StpUtil.logout();
return R.ok();
return R.ok(loginId);
}
@Log(ignore = true)

View File

@@ -32,10 +32,10 @@ import cn.dev33.satoken.stp.StpUtil;
import top.charles7c.continew.admin.auth.model.resp.LoginResp;
import top.charles7c.continew.admin.auth.service.LoginService;
import top.charles7c.continew.admin.monitor.annotation.Log;
import top.charles7c.continew.starter.core.exception.BadRequestException;
import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
import top.charles7c.continew.starter.extension.crud.model.resp.R;
import top.charles7c.continew.starter.log.common.annotation.Log;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;

View File

@@ -45,7 +45,6 @@ import cn.hutool.core.util.StrUtil;
import top.charles7c.continew.admin.common.config.properties.LocalStorageProperties;
import top.charles7c.continew.admin.common.constant.CacheConstants;
import top.charles7c.continew.admin.common.model.resp.LabelValueResp;
import top.charles7c.continew.admin.monitor.annotation.Log;
import top.charles7c.continew.admin.system.model.query.DeptQuery;
import top.charles7c.continew.admin.system.model.query.MenuQuery;
import top.charles7c.continew.admin.system.model.query.OptionQuery;
@@ -59,6 +58,7 @@ import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
import top.charles7c.continew.starter.data.mybatis.plus.enums.IBaseEnum;
import top.charles7c.continew.starter.extension.crud.model.query.SortQuery;
import top.charles7c.continew.starter.extension.crud.model.resp.R;
import top.charles7c.continew.starter.log.common.annotation.Log;
/**
* 公共 API

View File

@@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.charles7c.continew.admin.monitor.annotation.Log;
import top.charles7c.continew.admin.monitor.model.resp.DashboardAccessTrendResp;
import top.charles7c.continew.admin.monitor.model.resp.DashboardGeoDistributionResp;
import top.charles7c.continew.admin.monitor.model.resp.DashboardPopularModuleResp;
@@ -40,6 +39,7 @@ import top.charles7c.continew.admin.monitor.service.DashboardService;
import top.charles7c.continew.admin.system.model.resp.DashboardAnnouncementResp;
import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
import top.charles7c.continew.starter.extension.crud.model.resp.R;
import top.charles7c.continew.starter.log.common.annotation.Log;
/**
* 仪表盘 API

View File

@@ -29,7 +29,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.charles7c.continew.admin.monitor.annotation.Log;
import top.charles7c.continew.admin.monitor.model.query.LoginLogQuery;
import top.charles7c.continew.admin.monitor.model.query.OperationLogQuery;
import top.charles7c.continew.admin.monitor.model.query.SystemLogQuery;
@@ -41,6 +40,7 @@ import top.charles7c.continew.admin.monitor.service.LogService;
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
import top.charles7c.continew.starter.extension.crud.model.resp.PageDataResp;
import top.charles7c.continew.starter.extension.crud.model.resp.R;
import top.charles7c.continew.starter.log.common.annotation.Log;
/**
* 日志管理 API

View File

@@ -29,7 +29,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.charles7c.continew.admin.common.util.helper.LoginHelper;
import top.charles7c.continew.admin.monitor.annotation.Log;
import top.charles7c.continew.admin.system.model.query.MessageQuery;
import top.charles7c.continew.admin.system.model.resp.MessageResp;
import top.charles7c.continew.admin.system.model.resp.MessageUnreadResp;
@@ -38,6 +37,7 @@ import top.charles7c.continew.admin.system.service.MessageUserService;
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
import top.charles7c.continew.starter.extension.crud.model.resp.PageDataResp;
import top.charles7c.continew.starter.extension.crud.model.resp.R;
import top.charles7c.continew.starter.log.common.annotation.Log;
/**
* 消息管理 API

View File

@@ -25,19 +25,21 @@ project:
--- ### 日志配置(重叠部分,优先级高于 logback-spring.xml 中的配置)
logging:
config: classpath:logback-spring.xml
## 系统日志配置
system:
# 是否启用系统日志
## 日志配置
continew-starter:
log:
enabled: true
# 是否记录内网 IP 操作
includeInnerIp: true
# 排除请求方式
#excludeMethods:
# - GET
# 脱敏字段
desensitizeFields:
- password
- Authorization
include:
- DESCRIPTION
- MODULE
- REQUEST_HEADERS
- REQUEST_BODY
- IP_ADDRESS
- BROWSER
- OS
- RESPONSE_HEADERS
- RESPONSE_BODY
- TIME_TAKEN
--- ### 接口文档配置
springdoc:

View File

@@ -123,17 +123,17 @@ CREATE TABLE IF NOT EXISTS `sys_log` (
`status_code` int NOT NULL COMMENT '状态码',
`response_headers` text DEFAULT NULL COMMENT '响应头',
`response_body` mediumtext DEFAULT NULL COMMENT '响应体',
`elapsed_time` bigint(20) NOT NULL COMMENT '请求耗时ms',
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '操作状态1成功2失败',
`client_ip` varchar(100) DEFAULT NULL COMMENT '客户端IP',
`location` varchar(255) DEFAULT NULL COMMENT 'IP归属地',
`time_taken` bigint(20) NOT NULL COMMENT '耗时ms',
`ip` varchar(100) DEFAULT NULL COMMENT 'IP',
`address` varchar(255) DEFAULT NULL COMMENT 'IP归属地',
`browser` varchar(100) DEFAULT NULL COMMENT '浏览器',
`os` varchar(100) DEFAULT NULL COMMENT '操作系统',
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态1成功2失败',
`error_msg` text DEFAULT NULL COMMENT '错误信息',
`exception_detail` mediumtext DEFAULT NULL COMMENT '异常详情',
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
`create_time` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_module`(`module`) USING BTREE,
INDEX `idx_client_ip`(`client_ip`) USING BTREE,
INDEX `idx_ip`(`ip`) USING BTREE,
INDEX `idx_create_time`(`create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统日志表';