案件日志
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
package com.ruoyi.framework.aspectj;
|
||||
|
||||
|
||||
import com.ruoyi.common.annotation.CaseLog;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.CaseLogRecordMapper;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 案件操作日志记录处理
|
||||
*
|
||||
* @author wangqiong
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class CaseLogAspect {
|
||||
@Autowired
|
||||
private CaseLogRecordMapper logRecordMapper;
|
||||
private static final Logger log = LoggerFactory.getLogger(CaseLogAspect.class);
|
||||
|
||||
|
||||
/**
|
||||
* 处理请求前执行
|
||||
*/
|
||||
@Before(value = "@annotation(controllerLog)")
|
||||
public void boBefore(JoinPoint joinPoint, CaseLog controllerLog) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理完请求后执行
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
*/
|
||||
@AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
|
||||
public void doAfterReturning(JoinPoint joinPoint, CaseLog controllerLog, Object jsonResult) {
|
||||
handleLog(joinPoint, controllerLog, null, jsonResult);
|
||||
}
|
||||
|
||||
protected void handleLog(final JoinPoint joinPoint, CaseLog controllerLog, final Exception e, Object jsonResult) {
|
||||
try {
|
||||
// 获取当前的用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String nickName = loginUser.getUser().getNickName();
|
||||
|
||||
// *========数据库日志=========*//
|
||||
CaseLogRecord operLog = new CaseLogRecord();
|
||||
operLog.setCreateBy(nickName);
|
||||
operLog.setUpdateBy(nickName);
|
||||
// 处理设置注解上的参数
|
||||
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
||||
|
||||
// 保存数据库
|
||||
logRecordMapper.insertCaseLogRecord(operLog);
|
||||
} catch (Exception exp) {
|
||||
// 记录本地异常日志
|
||||
log.error("异常信息:{}", exp.getMessage());
|
||||
exp.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||
*
|
||||
* @param log 日志
|
||||
* @param operLog 操作日志
|
||||
* @throws Exception
|
||||
*/
|
||||
public void getControllerMethodDescription(JoinPoint joinPoint, CaseLog log, CaseLogRecord operLog, Object jsonResult) throws Exception {
|
||||
// 设置案件id
|
||||
operLog.setCaseAppliId(log.caseAppliId());
|
||||
// 设置案件节点
|
||||
operLog.setNotes(log.caseNode());
|
||||
// 设置备注
|
||||
operLog.setNotes(log.notes());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user