From 6af3a9c58565a5616105d8c76b1cf91bae36d38a Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期三, 16 六月 2021 21:25:41 +0800
Subject: [PATCH] 修改bug
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/sensitive/SensitiveInterceptor.java | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/sensitive/SensitiveInterceptor.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/sensitive/SensitiveInterceptor.java
index bce244b..113e35e 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/sensitive/SensitiveInterceptor.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/helper/sensitive/SensitiveInterceptor.java
@@ -11,6 +11,7 @@
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
@@ -29,11 +30,12 @@
@Slf4j
@ConditionalOnProperty(value = "domain.sensitive", havingValue = "true")
@Component
+@Order(120)
public class SensitiveInterceptor implements Interceptor {
@SuppressWarnings("unchecked")
@Override
public Object intercept(Invocation invocation) throws Throwable {
- log.info("脱敏拦截器");
+ //log.debug("脱敏拦截器");
List<Object> records = (List<Object>) invocation.proceed();
// 对结果集脱敏
records.forEach(this::sensitive);
@@ -42,14 +44,16 @@
private void sensitive(Object source) {
- // 拿到返回值类型
- Class<?> sourceClass = source.getClass();
- // 初始化返回值类型的 MetaObject
- MetaObject metaObject = SystemMetaObject.forObject(source);
- // 捕捉到属性上的标记注解 @Sensitive 并进行对应的脱敏处理
- Stream.of(sourceClass.getDeclaredFields())
- .filter(field -> field.isAnnotationPresent(Sensitive.class))
- .forEach(field -> doSensitive(metaObject, field));
+ if(source!=null) {
+ // 拿到返回值类型
+ Class<?> sourceClass = source.getClass();
+ // 初始化返回值类型的 MetaObject
+ MetaObject metaObject = SystemMetaObject.forObject(source);
+ // 捕捉到属性上的标记注解 @Sensitive 并进行对应的脱敏处理
+ Stream.of(sourceClass.getDeclaredFields())
+ .filter(field -> field.isAnnotationPresent(Sensitive.class))
+ .forEach(field -> doSensitive(metaObject, field));
+ }
}
--
Gitblit v1.7.1