This commit is contained in:
liulu 2024-11-25 14:19:45 +08:00
parent 856723e729
commit 7be43afa8b
2 changed files with 16 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import cn.hutool.core.thread.threadlocal.NamedThreadLocal;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.sunyard.chsm.model.R;
import com.sunyard.ssp.common.Result; import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.common.annotation.AuditControllerLog; import com.sunyard.ssp.common.annotation.AuditControllerLog;
import com.sunyard.ssp.modules.monitor.log.entity.AuditLog; import com.sunyard.ssp.modules.monitor.log.entity.AuditLog;
@ -12,6 +13,7 @@ import com.sunyard.ssp.modules.user.entity.ScUser;
import com.sunyard.ssp.utils.IpUtil; import com.sunyard.ssp.utils.IpUtil;
import com.sunyard.ssp.utils.SecurityUtil; import com.sunyard.ssp.utils.SecurityUtil;
import com.sunyard.ssp.utils.ThreadPoolUtil; import com.sunyard.ssp.utils.ThreadPoolUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature; import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterReturning;
@ -40,6 +42,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @author fyc * @author fyc
* @description 切点实现类 * @description 切点实现类
*/ */
@Slf4j
@Aspect @Aspect
@Component @Component
@SuppressWarnings("all") @SuppressWarnings("all")
@ -101,11 +104,18 @@ public class AuditLogAspect {
Map map = getAuditLogDescription(joinPoint); Map map = getAuditLogDescription(joinPoint);
auditLog.setOperateContent((String) map.get("description")); auditLog.setOperateContent((String) map.get("description"));
auditLog.setOperateType((String)map.get("operateType")); auditLog.setOperateType((String)map.get("operateType"));
Result<Object> result = (Result<Object>) res;
if(result.isSuccess()){ if (res instanceof R) {
auditLog.setOperateResult("成功"); auditLog.setOperateResult("成功");
}else { } else if (res instanceof Result) {
auditLog.setOperateResult("失败"); Result<Object> result = (Result<Object>) res;
if(result.isSuccess()){
auditLog.setOperateResult("成功");
}else {
auditLog.setOperateResult("失败");
}
} else {
log.warn("unrecognized return object: {}", res.getClass());
} }
//Ip信息 //Ip信息
@ -130,7 +140,7 @@ public class AuditLogAspect {
ThreadPoolUtil.getPool().execute(new SaveAuditLogThread(auditLog, auditLogService)); ThreadPoolUtil.getPool().execute(new SaveAuditLogThread(auditLog, auditLogService));
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); log.warn("记录操作日志异常", e);
} }
} }

View File

@ -1,5 +1,5 @@
CREATE TABLE "SC_AUDIT_LOG"( CREATE TABLE "SC_AUDIT_LOG"(
"ID" INT IDENTITY(4041, 1) NOT NULL, "ID" INT IDENTITY(1, 1) NOT NULL,
"CREATE_TIME" TIMESTAMP(0), "CREATE_TIME" TIMESTAMP(0),
"OPERATOR_NAME" VARCHAR(255), "OPERATOR_NAME" VARCHAR(255),
"OPERATOR_ID" INT, "OPERATOR_ID" INT,