This commit is contained in:
2025-07-28 21:01:45 +08:00
parent 2009009296
commit 076d5b99be
13 changed files with 74 additions and 19 deletions

View File

@@ -1,17 +1,13 @@
package com.njcn.web.advice;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.constant.SecurityConstants;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.pojo.constant.LogInfo;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.utils.ReflectCommonUtil;
import com.njcn.web.utils.RequestUtil;
import com.njcn.web.service.ILogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
@@ -19,7 +15,6 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

View File

@@ -84,19 +84,19 @@ public class LogServiceImpl implements ILogService {
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, userName, ip, methodDescribe, operateType, result.equalsIgnoreCase("失败") ? 0 : 1, "", severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex, LocalDateTime.now());
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
//推送审计消息功能
if(severity!=0){
if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)){
if (severity != 0) {
if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
//发送邮箱功能
if(severity==2&&logInfoDTO.getResult()==0){
if (severity == 2 && logInfoDTO.getResult() == 0) {
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
}
}
}
//如果存在设备日志注解,则记录设备日志
if(Objects.nonNull((returnType.getMethod()))&& (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)){
String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType();
DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName,deviceOperate,result.equalsIgnoreCase("失败") ? 0 : 1,"",loginName,userIndex);
if (Objects.nonNull((returnType.getMethod())) && (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)) {
String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType();
DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName, deviceOperate, result.equalsIgnoreCase("失败") ? 0 : 1, "", loginName, userIndex);
publisher.send("/deviceLog", PubUtils.obj2json(deviceLogDTO), 2, false);
}
@@ -169,8 +169,8 @@ public class LogServiceImpl implements ILogService {
private void auditPush(Integer severity, LogInfoDTO logInfoDTO) {
//推送审计消息功能
if(severity !=0){
if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
if (severity != 0) {
if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
//发送邮箱功能
if (severity == 2 && logInfoDTO.getResult() == 0) {