use of com.cdeledu.model.system.SysLogEntity in project wechat by dllwh.
the class LogFactory method createOperateLog.
/**
* @方法描述 : 创建操作日志
*/
public static SysLogEntity createOperateLog(JoinPoint joinPoint, long time, Throwable throwable, Object opResult, String ip, String browser) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLogEntity sysLog = new SysLogEntity();
SystemLog systemLog = method.getAnnotation(SystemLog.class);
if (systemLog != null) {
// 注解上的描述
sysLog.setRemark(systemLog.desc());
// 注解上的操作相关表
sysLog.setTableName(StringUtils.join(systemLog.tableName(), ","));
// 注解上的操作类型
sysLog.setOpType(systemLog.opType().getValue());
}
// 请求方法名
// 获取目标类名
String targetName = joinPoint.getTarget().getClass().getName();
sysLog.setMethod(targetName + "." + signature.getName() + "()");
// 访问目标方法的参数:
Object[] args = joinPoint.getArgs();
String params = JSON.toJSONString(args[0]);
// sysLog.setParams(JsonMapper.toJsonString(joinPoint.getArgs()));
sysLog.setParams(params);
// 操作人的信息
int userId = -1;
if (ShiroHelper.isLogin()) {
userId = WebUtilHelper.getCurrentUserId();
}
sysLog.setUserCode(userId);
if (opResult != null) {
sysLog.setOpResult(JsonMapper.toJsonString(opResult));
}
if (throwable != null) {
sysLog.setLogType(-1);
sysLog.setExceptionCode(sysLog.getClass().getName());
sysLog.setExceptionDetail(throwable.getMessage());
}
sysLog.setIpAddress(ip);
sysLog.setBrowser(browser);
sysLog.setTime(time);
return sysLog;
}
Aggregations