优化:优化日志表结构(新增 module 所属模块字段);优化日志引擎部分代码;使用 defaultIfNull() 和 blankToDefault 替换部分三元运算符代码(便于阅读及理解);将 BaseEntity 重命名为 BaseDO
This commit is contained in:
parent
1837047a9e
commit
21fe29b56f
@ -93,7 +93,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
||||
* ID
|
||||
* @return 详情信息
|
||||
*/
|
||||
@Operation(summary = "查看详情")
|
||||
@Operation(summary = "查看数据详情")
|
||||
@Parameter(name = "id", description = "ID", in = ParameterIn.PATH)
|
||||
@ResponseBody
|
||||
@GetMapping("/{id}")
|
||||
@ -109,7 +109,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
||||
* 创建信息
|
||||
* @return 自增 ID
|
||||
*/
|
||||
@Operation(summary = "新增")
|
||||
@Operation(summary = "新增数据")
|
||||
@ResponseBody
|
||||
@PostMapping
|
||||
protected R<Long> create(@Validated(BaseRequest.Create.class) @RequestBody C request) {
|
||||
@ -124,7 +124,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
||||
* 修改信息
|
||||
* @return /
|
||||
*/
|
||||
@Operation(summary = "修改")
|
||||
@Operation(summary = "修改数据")
|
||||
@ResponseBody
|
||||
@PutMapping
|
||||
protected R update(@Validated(BaseRequest.Update.class) @RequestBody C request) {
|
||||
@ -139,7 +139,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
|
||||
* ID 列表
|
||||
* @return /
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@Operation(summary = "删除数据")
|
||||
@Parameter(name = "ids", description = "ID 列表", in = ParameterIn.PATH)
|
||||
@ResponseBody
|
||||
@DeleteMapping("/{ids}")
|
||||
|
@ -31,7 +31,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
* @since 2022/12/12 23:02
|
||||
*/
|
||||
@Data
|
||||
public class BaseEntity implements Serializable {
|
||||
public class BaseDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -24,7 +24,7 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseEntity;
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
import top.charles7c.cnadmin.common.exception.ServiceException;
|
||||
import top.charles7c.cnadmin.common.util.helper.LoginHelper;
|
||||
|
||||
@ -60,15 +60,15 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
Long createUser = LoginHelper.getUserId();
|
||||
LocalDateTime createTime = LocalDateTime.now();
|
||||
if (metaObject.getOriginalObject() instanceof BaseEntity) {
|
||||
// 继承了 BaseEntity 的类,填充创建信息
|
||||
BaseEntity baseEntity = (BaseEntity)metaObject.getOriginalObject();
|
||||
baseEntity.setCreateUser(baseEntity.getCreateUser() != null ? baseEntity.getCreateUser() : createUser);
|
||||
baseEntity.setCreateTime(baseEntity.getCreateTime() != null ? baseEntity.getCreateTime() : createTime);
|
||||
baseEntity.setUpdateUser(baseEntity.getUpdateUser() != null ? baseEntity.getUpdateUser() : createUser);
|
||||
baseEntity.setUpdateTime(baseEntity.getUpdateTime() != null ? baseEntity.getUpdateTime() : createTime);
|
||||
if (metaObject.getOriginalObject() instanceof BaseDO) {
|
||||
// 继承了 BaseDO 的类,填充创建信息
|
||||
BaseDO baseDO = (BaseDO)metaObject.getOriginalObject();
|
||||
baseDO.setCreateUser(ObjectUtil.defaultIfNull(baseDO.getCreateUser(), createUser));
|
||||
baseDO.setCreateTime(ObjectUtil.defaultIfNull(baseDO.getCreateTime(), createTime));
|
||||
baseDO.setUpdateUser(ObjectUtil.defaultIfNull(baseDO.getUpdateUser(), createUser));
|
||||
baseDO.setUpdateTime(ObjectUtil.defaultIfNull(baseDO.getUpdateTime(), createTime));
|
||||
} else {
|
||||
// 未继承 BaseEntity 的类,根据类中拥有的创建信息进行填充,不存在创建信息不进行填充
|
||||
// 未继承 BaseDO 的类,根据类中拥有的创建信息进行填充,不存在创建信息不进行填充
|
||||
this.fillFieldValue(metaObject, CREATE_USER, createUser, false);
|
||||
this.fillFieldValue(metaObject, CREATE_TIME, createTime, false);
|
||||
this.fillFieldValue(metaObject, UPDATE_USER, createUser, false);
|
||||
@ -94,13 +94,13 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
Long updateUser = LoginHelper.getUserId();
|
||||
LocalDateTime updateTime = LocalDateTime.now();
|
||||
if (metaObject.getOriginalObject() instanceof BaseEntity) {
|
||||
// 继承了 BaseEntity 的类,填充修改信息
|
||||
BaseEntity baseEntity = (BaseEntity)metaObject.getOriginalObject();
|
||||
baseEntity.setUpdateUser(updateUser);
|
||||
baseEntity.setUpdateTime(updateTime);
|
||||
if (metaObject.getOriginalObject() instanceof BaseDO) {
|
||||
// 继承了 BaseDO 的类,填充修改信息
|
||||
BaseDO baseDO = (BaseDO)metaObject.getOriginalObject();
|
||||
baseDO.setUpdateUser(updateUser);
|
||||
baseDO.setUpdateTime(updateTime);
|
||||
} else {
|
||||
// 未继承 BaseEntity 的类,根据类中拥有的修改信息进行填充,不存在修改信息不进行填充
|
||||
// 未继承 BaseDO 的类,根据类中拥有的修改信息进行填充,不存在修改信息不进行填充
|
||||
this.fillFieldValue(metaObject, UPDATE_USER, updateUser, true);
|
||||
this.fillFieldValue(metaObject, UPDATE_TIME, updateTime, true);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class QueryHelper {
|
||||
// 如果没有单独指定属性名,就和使用该注解的属性的名称一致
|
||||
// 注意:数据库规范中列采用下划线连接法命名,程序规范中变量采用驼峰法命名
|
||||
String property = queryAnnotation.property();
|
||||
fieldName = StrUtil.isNotBlank(property) ? property : fieldName;
|
||||
fieldName = StrUtil.blankToDefault(property, fieldName);
|
||||
String columnName = StrUtil.toUnderlineCase(fieldName);
|
||||
switch (queryAnnotation.type()) {
|
||||
case EQUAL:
|
||||
|
@ -19,7 +19,7 @@ package top.charles7c.cnadmin.monitor.annotation;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 系统日志注解(用于接口方法或类上)
|
||||
* 系统日志注解(用于接口方法或类上,辅助 Spring Doc OpenAPI3 使用效果最佳)
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2022/12/23 20:00
|
||||
@ -30,12 +30,28 @@ import java.lang.annotation.*;
|
||||
public @interface Log {
|
||||
|
||||
/**
|
||||
* 日志描述
|
||||
* 日志描述(仅用于接口方法上)
|
||||
* <p>
|
||||
* 读取顺序:(越靠后优先级越高)<br>
|
||||
* 1、读取对应接口方法上的 @Operation(summary="描述") 内容<br>
|
||||
* 2、读取对应接口方法上的 @Log("描述") 内容<br>
|
||||
* </p>
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* 是否忽略日志记录
|
||||
* 所属模块(用于接口方法或类上)
|
||||
* <p>
|
||||
* 读取顺序:(越靠后优先级越高)<br>
|
||||
* 1、读取对应接口类上的 @Tag(name = "模块") 内容<br>
|
||||
* 2、读取对应接口类上的 @Log(module = "模块") 内容<br>
|
||||
* 3、读取对应接口方法上的 @Log(module = "模块") 内容
|
||||
* </p>
|
||||
*/
|
||||
String module() default "";
|
||||
|
||||
/**
|
||||
* 是否忽略日志记录(仅用于接口方法上)
|
||||
*/
|
||||
boolean ignore() default false;
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
@ -39,6 +39,7 @@ import org.springframework.web.util.WebUtils;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
@ -88,8 +89,11 @@ public class LogInterceptor implements HandlerInterceptor {
|
||||
return;
|
||||
}
|
||||
|
||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
||||
// 记录所属模块
|
||||
this.logModule(logDO, handlerMethod);
|
||||
// 记录日志描述
|
||||
this.logDescription(logDO, handler);
|
||||
this.logDescription(logDO, handlerMethod);
|
||||
// 记录请求信息
|
||||
this.logRequest(logDO, request);
|
||||
// 记录响应信息
|
||||
@ -140,24 +144,51 @@ public class LogInterceptor implements HandlerInterceptor {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录所属模块
|
||||
*
|
||||
* @param logDO
|
||||
* 系统日志信息
|
||||
* @param handlerMethod
|
||||
* 处理器方法
|
||||
*/
|
||||
private void logModule(LogDO logDO, HandlerMethod handlerMethod) {
|
||||
Tag classTag = handlerMethod.getBeanType().getDeclaredAnnotation(Tag.class);
|
||||
Log classLog = handlerMethod.getBeanType().getDeclaredAnnotation(Log.class);
|
||||
Log methodLog = handlerMethod.getMethodAnnotation(Log.class);
|
||||
|
||||
// 例如:@Tag(name = "部门管理") -> 部门管理
|
||||
// (本框架代码规范)例如:@Tag(name = "部门管理 API") -> 部门管理
|
||||
if (classTag != null) {
|
||||
String name = classTag.name();
|
||||
logDO.setModule(StrUtil.isNotBlank(name) ? name.replace("API", "").trim() : "请在该接口类上指定所属模块");
|
||||
}
|
||||
// 例如:@Log(module = "部门管理") -> 部门管理
|
||||
if (classLog != null && StrUtil.isNotBlank(classLog.module())) {
|
||||
logDO.setModule(classLog.module());
|
||||
}
|
||||
if (methodLog != null && StrUtil.isNotBlank(methodLog.module())) {
|
||||
logDO.setModule(methodLog.module());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志描述
|
||||
*
|
||||
* @param logDO
|
||||
* 系统日志信息
|
||||
* @param handler
|
||||
* 处理器
|
||||
* @param handlerMethod
|
||||
* 处理器方法
|
||||
*/
|
||||
private void logDescription(LogDO logDO, Object handler) {
|
||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
||||
Operation methodOperation = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Operation.class);
|
||||
Log methodLog = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Log.class);
|
||||
private void logDescription(LogDO logDO, HandlerMethod handlerMethod) {
|
||||
Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class);
|
||||
Log methodLog = handlerMethod.getMethodAnnotation(Log.class);
|
||||
|
||||
// 例如:@Operation(summary="新增部门") -> 新增部门
|
||||
if (methodOperation != null) {
|
||||
logDO.setDescription(
|
||||
StrUtil.isNotBlank(methodOperation.summary()) ? methodOperation.summary() : "请在该接口方法上指定日志描述");
|
||||
logDO.setDescription(StrUtil.blankToDefault(methodOperation.summary(), "请在该接口方法上指定日志描述"));
|
||||
}
|
||||
// 例如:@Log("获取验证码") -> 获取验证码
|
||||
// 例如:@Log("新增部门") -> 新增部门
|
||||
if (methodLog != null && StrUtil.isNotBlank(methodLog.value())) {
|
||||
logDO.setDescription(methodLog.value());
|
||||
}
|
||||
@ -184,7 +215,7 @@ public class LogInterceptor implements HandlerInterceptor {
|
||||
logDO.setClientIp(ServletUtil.getClientIP(request));
|
||||
logDO.setLocation(IpUtils.getCityInfo(logDO.getClientIp()));
|
||||
logDO.setBrowser(ServletUtils.getBrowser(request));
|
||||
logDO.setCreateUser(logDO.getCreateUser() == null ? LoginHelper.getUserId() : logDO.getCreateUser());
|
||||
logDO.setCreateUser(ObjectUtil.defaultIfNull(logDO.getCreateUser(), LoginHelper.getUserId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,13 +321,13 @@ public class LogInterceptor implements HandlerInterceptor {
|
||||
|
||||
// 3、排除不需要记录系统日志的接口
|
||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
||||
Log methodLog = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Log.class);
|
||||
// 3.1 请求方式不要求记录且请求上没有 @Log 注解,则不记录系统日志
|
||||
Log methodLog = handlerMethod.getMethodAnnotation(Log.class);
|
||||
// 3.1 请求方式不要求记录且接口方法上没有 @Log 注解,则不记录系统日志
|
||||
if (operationLogProperties.getExcludeMethods().contains(request.getMethod()) && methodLog == null) {
|
||||
return false;
|
||||
}
|
||||
// 3.2 如果接口上既没有 @Log 注解,也没有 @Operation 注解,则不记录系统日志
|
||||
Operation methodOperation = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Operation.class);
|
||||
// 3.2 如果接口方法上既没有 @Log 注解,也没有 @Operation 注解,则不记录系统日志
|
||||
Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class);
|
||||
if (methodLog == null && methodOperation == null) {
|
||||
return false;
|
||||
}
|
||||
@ -304,7 +335,7 @@ public class LogInterceptor implements HandlerInterceptor {
|
||||
if (methodOperation != null && methodOperation.hidden()) {
|
||||
return false;
|
||||
}
|
||||
// 3.4 如果接口上有 @Log 注解,但是要求忽略该接口,则不记录系统日志
|
||||
// 3.4 如果接口方法上有 @Log 注解,但是要求忽略该接口,则不记录系统日志
|
||||
return methodLog == null || !methodLog.ignore();
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,11 @@ public class LogDO implements Serializable {
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 所属模块
|
||||
*/
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* 请求URL
|
||||
*/
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
package top.charles7c.cnadmin.monitor.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -29,7 +32,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
* @since 2023/1/17 21:43
|
||||
*/
|
||||
@Data
|
||||
public class LogVO {
|
||||
public class LogVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
@ -42,4 +47,10 @@ public class LogVO {
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
private String createUserString;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
package top.charles7c.cnadmin.monitor.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -33,7 +30,7 @@ import top.charles7c.cnadmin.monitor.enums.LogStatusEnum;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "登录日志信息")
|
||||
public class LoginLogVO extends LogVO implements Serializable {
|
||||
public class LoginLogVO extends LogVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -78,10 +75,4 @@ public class LoginLogVO extends LogVO implements Serializable {
|
||||
*/
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
@Schema(description = "登录时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
package top.charles7c.cnadmin.monitor.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -33,7 +30,7 @@ import top.charles7c.cnadmin.monitor.enums.LogStatusEnum;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "操作日志信息")
|
||||
public class OperationLogVO extends LogVO implements Serializable {
|
||||
public class OperationLogVO extends LogVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -49,6 +46,12 @@ public class OperationLogVO extends LogVO implements Serializable {
|
||||
@Schema(description = "操作内容")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 所属模块
|
||||
*/
|
||||
@Schema(description = "所属模块")
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* 操作状态(1成功 2失败)
|
||||
*/
|
||||
@ -78,10 +81,4 @@ public class OperationLogVO extends LogVO implements Serializable {
|
||||
*/
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@Schema(description = "操作时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
package top.charles7c.cnadmin.monitor.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -31,7 +28,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "系统日志详情信息")
|
||||
public class SystemLogDetailVO extends LogVO implements Serializable {
|
||||
public class SystemLogDetailVO extends LogVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -112,10 +109,4 @@ public class SystemLogDetailVO extends LogVO implements Serializable {
|
||||
*/
|
||||
@Schema(description = "浏览器")
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
package top.charles7c.cnadmin.monitor.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -31,7 +28,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "系统日志信息")
|
||||
public class SystemLogVO extends LogVO implements Serializable {
|
||||
public class SystemLogVO extends LogVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -100,10 +97,4 @@ public class SystemLogVO extends LogVO implements Serializable {
|
||||
*/
|
||||
@Schema(description = "异常详情")
|
||||
private String exceptionDetail;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseEntity;
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_dept")
|
||||
public class DeptDO extends BaseEntity {
|
||||
public class DeptDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -23,7 +23,7 @@ import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseEntity;
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||
import top.charles7c.cnadmin.common.enums.GenderEnum;
|
||||
|
||||
@ -35,7 +35,7 @@ import top.charles7c.cnadmin.common.enums.GenderEnum;
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user")
|
||||
public class UserDO extends BaseEntity {
|
||||
public class UserDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -17,6 +17,7 @@ export interface LoginLogRecord extends LogRecord {
|
||||
}
|
||||
|
||||
export interface OperationLogRecord extends LogRecord {
|
||||
module: string;
|
||||
description: string;
|
||||
status: number;
|
||||
errorMsg: string;
|
||||
|
@ -155,6 +155,10 @@
|
||||
title: '操作内容',
|
||||
dataIndex: 'description',
|
||||
},
|
||||
{
|
||||
title: '所属模块',
|
||||
dataIndex: 'module',
|
||||
},
|
||||
{
|
||||
title: '操作状态',
|
||||
dataIndex: 'status',
|
||||
|
@ -83,6 +83,10 @@
|
||||
title: '操作内容',
|
||||
dataIndex: 'description',
|
||||
},
|
||||
{
|
||||
title: '所属模块',
|
||||
dataIndex: 'module',
|
||||
},
|
||||
{
|
||||
title: '操作状态',
|
||||
dataIndex: 'status',
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
|
||||
import top.charles7c.cnadmin.common.model.vo.R;
|
||||
import top.charles7c.cnadmin.monitor.annotation.Log;
|
||||
import top.charles7c.cnadmin.system.model.query.DeptQuery;
|
||||
import top.charles7c.cnadmin.system.model.vo.DeptVO;
|
||||
import top.charles7c.cnadmin.system.service.DeptService;
|
||||
@ -49,6 +50,7 @@ public class CommonController {
|
||||
|
||||
private final DeptService deptService;
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
||||
@GetMapping("/tree/dept")
|
||||
public R<List<Tree<Long>>> deptTree(@Validated DeptQuery query) {
|
||||
|
@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
import top.charles7c.cnadmin.common.model.vo.R;
|
||||
import top.charles7c.cnadmin.monitor.annotation.Log;
|
||||
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
|
||||
import top.charles7c.cnadmin.monitor.model.query.OperationLogQuery;
|
||||
import top.charles7c.cnadmin.monitor.model.query.SystemLogQuery;
|
||||
@ -53,6 +54,7 @@ public class LogController {
|
||||
|
||||
private final LogService logService;
|
||||
|
||||
@Log(module = "登录日志")
|
||||
@Operation(summary = "分页查询登录日志列表")
|
||||
@GetMapping("/login")
|
||||
public R<PageDataVO<LoginLogVO>> list(@Validated LoginLogQuery query, @Validated PageQuery pageQuery) {
|
||||
@ -60,6 +62,7 @@ public class LogController {
|
||||
return R.ok(pageDataVO);
|
||||
}
|
||||
|
||||
@Log(module = "操作日志")
|
||||
@Operation(summary = "分页查询操作日志列表")
|
||||
@GetMapping("/operation")
|
||||
public R<PageDataVO<OperationLogVO>> list(@Validated OperationLogQuery query, @Validated PageQuery pageQuery) {
|
||||
@ -67,6 +70,7 @@ public class LogController {
|
||||
return R.ok(pageDataVO);
|
||||
}
|
||||
|
||||
@Log(module = "系统日志")
|
||||
@Operation(summary = "分页查询系统日志列表")
|
||||
@GetMapping("/system")
|
||||
public R<PageDataVO<SystemLogVO>> list(@Validated SystemLogQuery query, @Validated PageQuery pageQuery) {
|
||||
@ -74,6 +78,7 @@ public class LogController {
|
||||
return R.ok(pageDataVO);
|
||||
}
|
||||
|
||||
@Log(module = "系统日志")
|
||||
@Operation(summary = "查看系统日志详情")
|
||||
@GetMapping("/system/{logId}")
|
||||
public R<SystemLogDetailVO> detail(@PathVariable Long logId) {
|
||||
|
@ -58,7 +58,7 @@ import top.charles7c.cnadmin.monitor.model.vo.*;
|
||||
@RequestMapping("/monitor/online/user")
|
||||
public class OnlineUserController {
|
||||
|
||||
@Operation(summary = "分页查询在线用户列表")
|
||||
@Operation(summary = "分页查询列表")
|
||||
@GetMapping
|
||||
public R<PageDataVO<OnlineUserVO>> list(@Validated OnlineUserQuery query, @Validated PageQuery pageQuery) {
|
||||
List<LoginUser> loginUserList = new ArrayList<>();
|
||||
|
@ -46,7 +46,7 @@ import top.charles7c.cnadmin.system.service.DeptService;
|
||||
public class DeptController extends BaseController<DeptService, DeptVO, DeptVO, DeptQuery, DeptRequest> {
|
||||
|
||||
@Override
|
||||
@Operation(summary = "查询部门列表树")
|
||||
@Operation(summary = "查询列表树")
|
||||
public R<List<DeptVO>> list(@Validated DeptQuery query) {
|
||||
List<DeptVO> list = baseService.list(query);
|
||||
return R.ok(baseService.buildListTree(list));
|
||||
|
@ -43,15 +43,16 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_log` (
|
||||
`log_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '日志ID',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '日志描述',
|
||||
`request_url` varchar(512) NOT NULL DEFAULT '' COMMENT '请求URL',
|
||||
`request_method` varchar(10) DEFAULT NULL COMMENT '请求方式',
|
||||
`request_headers` text COMMENT '请求头',
|
||||
`description` varchar(255) NOT NULL COMMENT '日志描述',
|
||||
`module` varchar(255) NOT NULL COMMENT '所属模块',
|
||||
`request_url` varchar(512) NOT NULL COMMENT '请求URL',
|
||||
`request_method` varchar(10) NOT NULL COMMENT '请求方式',
|
||||
`request_headers` text DEFAULT NULL COMMENT '请求头',
|
||||
`request_body` text DEFAULT NULL COMMENT '请求体',
|
||||
`status_code` int(11) unsigned DEFAULT NULL COMMENT '状态码',
|
||||
`status_code` int(11) unsigned NOT NULL COMMENT '状态码',
|
||||
`response_headers` text DEFAULT NULL COMMENT '响应头',
|
||||
`response_body` mediumtext DEFAULT NULL COMMENT '响应体',
|
||||
`elapsed_time` bigint(20) unsigned DEFAULT NULL COMMENT '请求耗时(ms)',
|
||||
`elapsed_time` bigint(20) unsigned NOT NULL COMMENT '请求耗时(ms)',
|
||||
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '操作状态(1成功 2失败)',
|
||||
`client_ip` varchar(255) DEFAULT NULL COMMENT '客户端IP',
|
||||
`location` varchar(512) DEFAULT NULL COMMENT 'IP归属地',
|
||||
|
Loading…
Reference in New Issue
Block a user