fix: 修复网关启动找不到服务的问题,修复jwt问题,修复自动导入失败问题。

This commit is contained in:
2025-12-14 15:02:24 +08:00
parent 4912e48922
commit 63d0528af4
33 changed files with 792 additions and 421 deletions

View File

@@ -20,6 +20,7 @@ import org.springframework.expression.EvaluationContext;
@Slf4j
@RequiredArgsConstructor
public class SysLogAspect {
/**
* 环绕通知方法,用于处理系统日志记录
* @param point 连接点对象
@@ -29,7 +30,7 @@ public class SysLogAspect {
*/
@Around("@annotation(sysLog)")
@SneakyThrows
public Object around(ProceedingJoinPoint point,SysLog sysLog) {
public Object around(ProceedingJoinPoint point, SysLog sysLog) {
String strClassName = point.getTarget().getClass().getName();
String strMethodName = point.getSignature().getName();
log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName);
@@ -76,4 +77,5 @@ public class SysLogAspect {
return obj;
}
}

View File

@@ -24,11 +24,10 @@ public class AIOJLogPropertiesConfiguration {
*/
private Integer maxLength = 20000;
/**
* 放行字段password,mobile,idcard,phone
*/
@Value("${log.exclude-fields:password,mobile,idcard,phone}")
private List<String> excludeFields;
/**
* 放行字段password,mobile,idcard,phone
*/
@Value("${log.exclude-fields:password,mobile,idcard,phone}")
private List<String> excludeFields;
}

View File

@@ -1,6 +1,5 @@
package cn.meowrain.aioj.backend.framework.log.event;
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
import org.springframework.context.ApplicationEvent;

View File

@@ -38,38 +38,40 @@ public class SysLogListener implements InitializingBean {
SysLog sysLog = new SysLog();
BeanUtils.copyProperties(source, sysLog);
// json 格式刷参数放在异步中处理,提升性能
if (Objects.nonNull(source.getBody())) {
String params = objectMapper.writeValueAsString(source.getBody());
sysLog.setParams(StrUtil.subPre(params, logProperties.getMaxLength()));
}
// json 格式刷参数放在异步中处理,提升性能
if (Objects.nonNull(source.getBody())) {
String params = objectMapper.writeValueAsString(source.getBody());
sysLog.setParams(StrUtil.subPre(params, logProperties.getMaxLength()));
}
remoteLogService.saveLog(sysLog);
remoteLogService.saveLog(sysLog);
}
/**
* 在 Bean 初始化后执行,用于初始化 ObjectMapper
* @throws Exception
*/
/**
* 在 Bean 初始化后执行,用于初始化 ObjectMapper
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
//给 ObjectMapper 添加 MixIn用于过滤字段
objectMapper.addMixIn(Object.class, PropertyFilterMixIn.class);
String[] ignorableFieldNames = logProperties.getExcludeFields().toArray(new String[0]);
// 给 ObjectMapper 添加 MixIn用于过滤字段
objectMapper.addMixIn(Object.class, PropertyFilterMixIn.class);
String[] ignorableFieldNames = logProperties.getExcludeFields().toArray(new String[0]);
FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name",
SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
objectMapper.setFilterProvider(filters);
objectMapper.registerModule(new JavaTimeModule());
}
/**
* 属性过滤混合类:用于通过名称过滤属性
*
* @author lengleng
* @date 2025/05/31
*/
@JsonFilter("filter properties by name")
class PropertyFilterMixIn {
FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name",
SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
objectMapper.setFilterProvider(filters);
objectMapper.registerModule(new JavaTimeModule());
}
/**
* 属性过滤混合类:用于通过名称过滤属性
*
* @author lengleng
* @date 2025/05/31
*/
@JsonFilter("filter properties by name")
class PropertyFilterMixIn {
}
}

View File

@@ -29,14 +29,13 @@ import java.util.Objects;
public final class SysLogUtils {
/**
* 获取系统日志事件源
* @return 系统日志事件源对象
*/
public static SysLogEventSource getSysLog() {
public static SysLogEventSource getSysLog() {
HttpServletRequest request = ((ServletRequestAttributes) Objects
.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
SysLogEventSource sysLog = new SysLogEventSource();
sysLog.setLogType(LogTypeEnum.NORMAL.getType());
sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI()));
@@ -47,7 +46,8 @@ public final class SysLogUtils {
sysLog.setServiceId(SpringUtil.getProperty("spring.application.name"));
// get 参数脱敏
AIOJLogPropertiesConfiguration logProperties = SpringContextHolder.getBean(AIOJLogPropertiesConfiguration.class);
AIOJLogPropertiesConfiguration logProperties = SpringContextHolder
.getBean(AIOJLogPropertiesConfiguration.class);
Map<String, String[]> paramsMap = MapUtil.removeAny(new HashMap<>(request.getParameterMap()),
ArrayUtil.toArray(logProperties.getExcludeFields(), String.class));
sysLog.setParams(HttpUtil.toParams(paramsMap));
@@ -74,7 +74,7 @@ public final class SysLogUtils {
* @param <T> 返回泛型
* @return 参数值
*/
public static <T> T getValue(EvaluationContext context, String key, Class<T> clazz) {
public static <T> T getValue(EvaluationContext context, String key, Class<T> clazz) {
SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
Expression expression = spelExpressionParser.parseExpression(key);
return expression.getValue(context, clazz);