mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
修正单词拼写错误
This commit is contained in:
parent
7cdeb3d3d7
commit
2ed0b62cfc
@ -12,7 +12,7 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OperLogEvent implements Serializable {
|
public class OperationLogEvent implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -4,7 +4,7 @@ import cn.hutool.core.lang.Dict;
|
|||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.domain.event.OperLogEvent;
|
import com.ruoyi.common.core.domain.event.OperationLogEvent;
|
||||||
import com.ruoyi.common.enums.BusinessStatus;
|
import com.ruoyi.common.enums.BusinessStatus;
|
||||||
import com.ruoyi.common.enums.HttpMethod;
|
import com.ruoyi.common.enums.HttpMethod;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
@ -66,28 +66,28 @@ public class LogAspect {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
// *========数据库日志=========*//
|
// *========数据库日志=========*//
|
||||||
OperLogEvent operLog = new OperLogEvent();
|
OperationLogEvent operationLog = new OperationLogEvent();
|
||||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
operationLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||||
// 请求的地址
|
// 请求的地址
|
||||||
String ip = ServletUtils.getClientIP();
|
String ip = ServletUtils.getClientIP();
|
||||||
operLog.setOperIp(ip);
|
operationLog.setOperIp(ip);
|
||||||
operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
|
operationLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
|
||||||
operLog.setOperName(LoginHelper.getUsername());
|
operationLog.setOperName(LoginHelper.getUsername());
|
||||||
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
operLog.setStatus(BusinessStatus.FAIL.ordinal());
|
operationLog.setStatus(BusinessStatus.FAIL.ordinal());
|
||||||
operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
|
operationLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
|
||||||
}
|
}
|
||||||
// 设置方法名称
|
// 设置方法名称
|
||||||
String className = joinPoint.getTarget().getClass().getName();
|
String className = joinPoint.getTarget().getClass().getName();
|
||||||
String methodName = joinPoint.getSignature().getName();
|
String methodName = joinPoint.getSignature().getName();
|
||||||
operLog.setMethod(className + "." + methodName + "()");
|
operationLog.setMethod(className + "." + methodName + "()");
|
||||||
// 设置请求方式
|
// 设置请求方式
|
||||||
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
operationLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
||||||
// 处理设置注解上的参数
|
// 处理设置注解上的参数
|
||||||
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
getControllerMethodDescription(joinPoint, controllerLog, operationLog, jsonResult);
|
||||||
// 发布事件保存数据库
|
// 发布事件保存数据库
|
||||||
SpringUtils.context().publishEvent(operLog);
|
SpringUtils.context().publishEvent(operationLog);
|
||||||
} catch (Exception exp) {
|
} catch (Exception exp) {
|
||||||
// 记录本地异常日志
|
// 记录本地异常日志
|
||||||
log.error("异常信息:{}", exp.getMessage());
|
log.error("异常信息:{}", exp.getMessage());
|
||||||
@ -99,44 +99,44 @@ public class LogAspect {
|
|||||||
* 获取注解中对方法的描述信息 用于Controller层注解
|
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||||
*
|
*
|
||||||
* @param log 日志
|
* @param log 日志
|
||||||
* @param operLog 操作日志
|
* @param operationLog 操作日志
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, OperLogEvent operLog, Object jsonResult) throws Exception {
|
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, OperationLogEvent operationLog, Object jsonResult) throws Exception {
|
||||||
// 设置action动作
|
// 设置action动作
|
||||||
operLog.setBusinessType(log.businessType().ordinal());
|
operationLog.setBusinessType(log.businessType().ordinal());
|
||||||
// 设置标题
|
// 设置标题
|
||||||
operLog.setTitle(log.title());
|
operationLog.setTitle(log.title());
|
||||||
// 设置操作人类别
|
// 设置操作人类别
|
||||||
operLog.setOperatorType(log.operatorType().ordinal());
|
operationLog.setOperatorType(log.operatorType().ordinal());
|
||||||
// 是否需要保存request,参数和值
|
// 是否需要保存request,参数和值
|
||||||
if (log.isSaveRequestData()) {
|
if (log.isSaveRequestData()) {
|
||||||
// 获取参数的信息,传入到数据库中。
|
// 获取参数的信息,传入到数据库中。
|
||||||
setRequestValue(joinPoint, operLog, log.excludeParamNames());
|
setRequestValue(joinPoint, operationLog, log.excludeParamNames());
|
||||||
}
|
}
|
||||||
// 是否需要保存response,参数和值
|
// 是否需要保存response,参数和值
|
||||||
if (log.isSaveResponseData() && ObjectUtil.isNotNull(jsonResult)) {
|
if (log.isSaveResponseData() && ObjectUtil.isNotNull(jsonResult)) {
|
||||||
operLog.setJsonResult(StringUtils.substring(JsonUtils.toJsonString(jsonResult), 0, 2000));
|
operationLog.setJsonResult(StringUtils.substring(JsonUtils.toJsonString(jsonResult), 0, 2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取请求的参数,放到log中
|
* 获取请求的参数,放到log中
|
||||||
*
|
*
|
||||||
* @param operLog 操作日志
|
* @param operationLog 操作日志
|
||||||
* @throws Exception 异常
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
private void setRequestValue(JoinPoint joinPoint, OperLogEvent operLog, String[] excludeParamNames) throws Exception {
|
private void setRequestValue(JoinPoint joinPoint, OperationLogEvent operationLog, String[] excludeParamNames) throws Exception {
|
||||||
Map<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
Map<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
||||||
String requestMethod = operLog.getRequestMethod();
|
String requestMethod = operationLog.getRequestMethod();
|
||||||
if (MapUtil.isEmpty(paramsMap)
|
if (MapUtil.isEmpty(paramsMap)
|
||||||
&& HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) {
|
&& HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) {
|
||||||
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
||||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
operationLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
||||||
} else {
|
} else {
|
||||||
MapUtil.removeAny(paramsMap, EXCLUDE_PROPERTIES);
|
MapUtil.removeAny(paramsMap, EXCLUDE_PROPERTIES);
|
||||||
MapUtil.removeAny(paramsMap, excludeParamNames);
|
MapUtil.removeAny(paramsMap, excludeParamNames);
|
||||||
operLog.setOperParam(StringUtils.substring(JsonUtils.toJsonString(paramsMap), 0, 2000));
|
operationLog.setOperParam(StringUtils.substring(JsonUtils.toJsonString(paramsMap), 0, 2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class EncryptorManager {
|
|||||||
*
|
*
|
||||||
* @param encryptContext 加密执行者需要的相关配置参数
|
* @param encryptContext 加密执行者需要的相关配置参数
|
||||||
*/
|
*/
|
||||||
public IEncryptor registAndGetEncryptor(EncryptContext encryptContext) {
|
public IEncryptor registerAndGetEncryptor(EncryptContext encryptContext) {
|
||||||
if (encryptorMap.containsKey(encryptContext)) {
|
if (encryptorMap.containsKey(encryptContext)) {
|
||||||
return encryptorMap.get(encryptContext);
|
return encryptorMap.get(encryptContext);
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class EncryptorManager {
|
|||||||
* @param encryptContext 加密相关的配置信息
|
* @param encryptContext 加密相关的配置信息
|
||||||
*/
|
*/
|
||||||
public String encrypt(String value, EncryptContext encryptContext) {
|
public String encrypt(String value, EncryptContext encryptContext) {
|
||||||
IEncryptor encryptor = this.registAndGetEncryptor(encryptContext);
|
IEncryptor encryptor = this.registerAndGetEncryptor(encryptContext);
|
||||||
return encryptor.encrypt(value, encryptContext.getEncode());
|
return encryptor.encrypt(value, encryptContext.getEncode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public class EncryptorManager {
|
|||||||
* @param encryptContext 加密相关的配置信息
|
* @param encryptContext 加密相关的配置信息
|
||||||
*/
|
*/
|
||||||
public String decrypt(String value, EncryptContext encryptContext) {
|
public String decrypt(String value, EncryptContext encryptContext) {
|
||||||
IEncryptor encryptor = this.registAndGetEncryptor(encryptContext);
|
IEncryptor encryptor = this.registerAndGetEncryptor(encryptContext);
|
||||||
return encryptor.decrypt(value);
|
return encryptor.decrypt(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import cn.hutool.core.util.ArrayUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.event.OperLogEvent;
|
import com.ruoyi.common.core.domain.event.OperationLogEvent;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.ip.AddressUtils;
|
import com.ruoyi.common.utils.ip.AddressUtils;
|
||||||
@ -36,12 +36,12 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||||||
/**
|
/**
|
||||||
* 操作日志记录
|
* 操作日志记录
|
||||||
*
|
*
|
||||||
* @param operLogEvent 操作日志事件
|
* @param operationLogEvent 操作日志事件
|
||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
@EventListener
|
@EventListener
|
||||||
public void recordOper(OperLogEvent operLogEvent) {
|
public void recordOper(OperationLogEvent operationLogEvent) {
|
||||||
SysOperLog operLog = BeanUtil.toBean(operLogEvent, SysOperLog.class);
|
SysOperLog operLog = BeanUtil.toBean(operationLogEvent, SysOperLog.class);
|
||||||
// 远程查询操作地点
|
// 远程查询操作地点
|
||||||
operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
|
operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
|
||||||
insertOperlog(operLog);
|
insertOperlog(operLog);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user