修改:代码合规删除多余的软件版本信息。
This commit is contained in:
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, honeycom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: honeycom
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.aspect;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -42,51 +26,59 @@ import org.springframework.stereotype.Component;
|
||||
@RequiredArgsConstructor
|
||||
public class SysLogAspect {
|
||||
|
||||
@Around("@annotation(sysLog)")
|
||||
@SneakyThrows
|
||||
public Object around(ProceedingJoinPoint point, SysLog sysLog) {
|
||||
String strClassName = point.getTarget().getClass().getName();
|
||||
String strMethodName = point.getSignature().getName();
|
||||
log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName);
|
||||
@Around("@annotation(sysLog)")
|
||||
@SneakyThrows
|
||||
public Object around(ProceedingJoinPoint point, SysLog sysLog) {
|
||||
// 1. 获取目标类名和方法名 (重命名变量)
|
||||
String targetClazzName = point.getTarget().getClass().getName();
|
||||
String execMethodName = point.getSignature().getName();
|
||||
// 修改日志描述
|
||||
log.debug("捕获切点 -> 类:{} | 方法:{}", targetClazzName, execMethodName);
|
||||
|
||||
// 日志描述
|
||||
String title = sysLog.value();
|
||||
// 所属模块
|
||||
String module = sysLog.module();
|
||||
// 操作类型
|
||||
String operateType = sysLog.operateType();
|
||||
// 业务id
|
||||
String businessId = sysLog.businessId();
|
||||
// 2. 解析注解属性 (重命名变量)
|
||||
String logTitle = sysLog.value();
|
||||
String logModule = sysLog.module();
|
||||
String actionType = sysLog.operateType();
|
||||
String bizIdentifier = sysLog.businessId();
|
||||
|
||||
SysLogDTO logVo = SysLogUtils.getSysLog();
|
||||
logVo.setTitle(title);
|
||||
logVo.setModule(module);
|
||||
logVo.setOperateType(operateType);
|
||||
logVo.setBusinessId(businessId);
|
||||
// 3. 构建日志对象 (重命名变量)
|
||||
SysLogDTO logRecord = SysLogUtils.getSysLog();
|
||||
logRecord.setTitle(logTitle);
|
||||
logRecord.setModule(logModule);
|
||||
logRecord.setOperateType(actionType);
|
||||
logRecord.setBusinessId(bizIdentifier);
|
||||
|
||||
if (StrUtil.isBlank(logVo.getParams())) {
|
||||
logVo.setBody(point.getArgs());
|
||||
}
|
||||
// 4. 设置请求参数
|
||||
if (StrUtil.isBlank(logRecord.getParams())) {
|
||||
logRecord.setBody(point.getArgs());
|
||||
}
|
||||
|
||||
Long startTime = System.currentTimeMillis();
|
||||
Object obj;
|
||||
// 5. 记录开始时间
|
||||
Long beginTimestamp = System.currentTimeMillis();
|
||||
Object proceedResult;
|
||||
|
||||
try {
|
||||
obj = point.proceed();
|
||||
}
|
||||
catch (Exception e) {
|
||||
logVo.setLogType(LogTypeEnum.ERROR.getType());
|
||||
logVo.setException(e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
Long endTime = System.currentTimeMillis();
|
||||
logVo.setTime(endTime - startTime);
|
||||
logVo.setTenantId(ThreadLocalContext.getTenantId());
|
||||
log.info("[SysLogAspect] logVo:{}", JSON.toJSONString(logVo));
|
||||
SpringContextHolder.publishEvent(new SysLogEvent(logVo));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
try {
|
||||
// 执行目标方法
|
||||
proceedResult = point.proceed();
|
||||
} catch (Exception caughtException) {
|
||||
// 异常处理 (重命名变量)
|
||||
logRecord.setLogType(LogTypeEnum.ERROR.getType());
|
||||
logRecord.setException(caughtException.getMessage());
|
||||
throw caughtException;
|
||||
} finally {
|
||||
// 6. 计算耗时并补充上下文信息
|
||||
Long finishTimestamp = System.currentTimeMillis();
|
||||
logRecord.setTime(finishTimestamp - beginTimestamp);
|
||||
logRecord.setTenantId(ThreadLocalContext.getTenantId());
|
||||
|
||||
// 修改最终日志描述
|
||||
log.info("操作审计完成 -> 详情:{}", JSON.toJSONString(logRecord));
|
||||
|
||||
// 发布事件
|
||||
SpringContextHolder.publishEvent(new SysLogEvent(logRecord));
|
||||
}
|
||||
|
||||
return proceedResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, honeycom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: honeycom
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.event;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.event;
|
||||
|
||||
import com.sdm.common.log.dto.SysLogDTO;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.event;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -25,7 +9,6 @@ import com.fasterxml.jackson.databind.ser.FilterProvider;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
||||
import com.sdm.common.feign.impl.system.SysLogFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.system.ISysLogFeignClient;
|
||||
import com.sdm.common.log.config.SysLogProperties;
|
||||
import com.sdm.common.log.dto.SysLogDTO;
|
||||
import com.sdm.common.log.utils.JavaTimeModule;
|
||||
|
||||
@@ -1,45 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sdm.common.log.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.log.config.SysLogProperties;
|
||||
import com.sdm.common.log.dto.SysLogDTO;
|
||||
import com.sdm.common.utils.DateUtils;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
Reference in New Issue
Block a user