mirror of https://gitee.com/stylefeng/roses
【8.0】【log】更新业务日志的非http环境的问题
parent
44e8896c7f
commit
8f56455fbe
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
package cn.stylefeng.roses.kernel.log.business.aop;
|
package cn.stylefeng.roses.kernel.log.business.aop;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||||
import cn.stylefeng.roses.kernel.log.api.constants.LogFileConstants;
|
import cn.stylefeng.roses.kernel.log.api.constants.LogFileConstants;
|
||||||
|
@ -82,7 +83,9 @@ public class BusinessLogRecordAop implements Ordered {
|
||||||
// 业务日志进行保存
|
// 业务日志进行保存
|
||||||
SysLogBusiness logContext = BusinessLogHolder.getContext();
|
SysLogBusiness logContext = BusinessLogHolder.getContext();
|
||||||
List<String> contentList = BusinessLogHolder.getContent();
|
List<String> contentList = BusinessLogHolder.getContent();
|
||||||
|
if (ObjectUtil.isNotEmpty(logContext) && ObjectUtil.isNotEmpty(contentList)) {
|
||||||
sysLogBusinessService.saveBatchLogs(logContext, contentList);
|
sysLogBusinessService.saveBatchLogs(logContext, contentList);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -119,9 +122,10 @@ public class BusinessLogRecordAop implements Ordered {
|
||||||
// 设置业务日志的类型编码
|
// 设置业务日志的类型编码
|
||||||
sysLogBusiness.setLogTypeCode(bizLog.logTypeCode());
|
sysLogBusiness.setLogTypeCode(bizLog.logTypeCode());
|
||||||
|
|
||||||
|
// http相关的信息可以为空
|
||||||
|
try {
|
||||||
// 设置请求的URL
|
// 设置请求的URL
|
||||||
String servletPath = HttpServletUtil.getRequest().getServletPath();
|
sysLogBusiness.setRequestUrl(HttpServletUtil.getRequest().getServletPath());
|
||||||
sysLogBusiness.setRequestUrl(servletPath);
|
|
||||||
|
|
||||||
// 设置HTTP请求方式
|
// 设置HTTP请求方式
|
||||||
sysLogBusiness.setHttpMethod(HttpServletUtil.getRequest().getMethod());
|
sysLogBusiness.setHttpMethod(HttpServletUtil.getRequest().getMethod());
|
||||||
|
@ -129,6 +133,9 @@ public class BusinessLogRecordAop implements Ordered {
|
||||||
// 设置客户端IP
|
// 设置客户端IP
|
||||||
String requestClientIp = HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest());
|
String requestClientIp = HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest());
|
||||||
sysLogBusiness.setClientIp(requestClientIp);
|
sysLogBusiness.setClientIp(requestClientIp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
// 设置当前登录用户id
|
// 设置当前登录用户id
|
||||||
LoginUser loginUserNullable = LoginContext.me().getLoginUserNullable();
|
LoginUser loginUserNullable = LoginContext.me().getLoginUserNullable();
|
||||||
|
|
Loading…
Reference in New Issue