use of com.albedo.java.modules.sys.domain.LogOperateDo in project albedo by somowhere.
the class SysLogUtils method getSysLogOperate.
public LogOperateDo getSysLogOperate() {
HttpServletRequest request = RequestHolder.getHttpServletRequest();
LogOperateDo logOperateDo = new LogOperateDo();
logOperateDo.setCreatedBy(getUserId());
logOperateDo.setCreatedDate(LocalDateTime.now());
logOperateDo.setUsername(getUsername());
logOperateDo.setIpAddress(WebUtil.getIp(request));
logOperateDo.setIpLocation(AddressUtil.getRegion(logOperateDo.getIpAddress()));
logOperateDo.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
UserAgent userAgent = UserAgentUtil.parse(logOperateDo.getUserAgent());
logOperateDo.setBrowser(userAgent.getBrowser().getName());
logOperateDo.setOs(userAgent.getOs().getName());
logOperateDo.setRequestUri(URLUtil.getPath(request.getRequestURI()));
return logOperateDo;
}
use of com.albedo.java.modules.sys.domain.LogOperateDo in project albedo by somowhere.
the class LogOperateResource method download.
@LogOperate(value = "操作日志导出")
@GetMapping(value = "/download")
@PreAuthorize("@pms.hasPermission('sys_logOperate_export')")
public void download(LogOperateQueryCriteria logOperateQueryCriteria, HttpServletResponse response) {
QueryWrapper wrapper = QueryWrapperUtil.getWrapper(logOperateQueryCriteria);
ExcelUtil<LogOperateDo> util = new ExcelUtil(LogOperateDo.class);
util.exportExcel(logOperateService.list(wrapper), "操作日志", response);
}
use of com.albedo.java.modules.sys.domain.LogOperateDo in project albedo by somowhere.
the class SysLogAspect method around.
@Around("@annotation(logOperate)")
@SneakyThrows
public Object around(ProceedingJoinPoint point, com.albedo.java.common.log.annotation.LogOperate logOperate) {
MethodSignature signature = (MethodSignature) point.getSignature();
String strClassName = point.getTarget().getClass().getName();
String strMethodName = point.getSignature().getName();
SysLogAspect.log.debug("[Class]:{},[Method]:{}", strClassName, strMethodName);
// 方法路径
String methodName = point.getTarget().getClass().getName() + StrPool.DOT + signature.getName() + "()";
StringBuilder params = new StringBuilder("{");
// 参数值
Object[] argValues = point.getArgs();
// 参数名称
String[] argNames = ((MethodSignature) point.getSignature()).getParameterNames();
if (argValues != null) {
for (int i = 0; i < argValues.length; i++) {
params.append(" ").append(argNames[i]).append(": ").append(argValues[i]);
}
}
LogOperateDo logOperateDoVo = SysLogUtils.getSysLogOperate();
logOperateDoVo.setTitle(logOperate.value());
logOperateDoVo.setMethod(methodName);
logOperateDoVo.setParams(params + " }");
logOperateDoVo.setOperatorType(logOperate.operatorType().name());
setDescription(point, logOperate, logOperateDoVo);
Long startTime = System.currentTimeMillis();
Object obj;
try {
obj = point.proceed();
logOperateDoVo.setLogType(LogType.INFO.name());
} catch (Exception e) {
logOperateDoVo.setDescription(e.getMessage());
if (e instanceof BizException) {
logOperateDoVo.setLogType(LogType.WARN.name());
} else {
logOperateDoVo.setException(ExceptionUtil.stacktraceToString(e));
logOperateDoVo.setLogType(LogType.ERROR.name());
}
throw e;
} finally {
saveLog(System.currentTimeMillis() - startTime, logOperateDoVo, logOperate);
}
return obj;
}
use of com.albedo.java.modules.sys.domain.LogOperateDo in project albedo by somowhere.
the class SysLogOperateListener method saveSysLog.
@Async
@Order
@EventListener(SysLogOperateEvent.class)
public void saveSysLog(SysLogOperateEvent event) {
LogOperateDo logOperateDo = (LogOperateDo) event.getSource();
logOperateService.saveOrUpdate(logOperateDo);
}
Aggregations