From eb9e4b5eef423eea29a233ac8aeb6b3fd1ef6709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Tue, 12 Sep 2023 10:32:07 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=E6=A8=A1=E5=9D=97=20=E6=94=AF=E6=8C=81=E7=88=B6?= =?UTF-8?q?=E7=B1=BB=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3(=E6=84=9F=E8=B0=A2=20Tyler=20Ge)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/encrypt/core/EncryptorManager.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java index 07c5675a..498b4b85 100644 --- a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java +++ b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java @@ -1,11 +1,12 @@ package org.dromara.common.encrypt.core; import cn.hutool.core.util.ReflectUtil; -import org.dromara.common.encrypt.annotation.EncryptField; import lombok.extern.slf4j.Slf4j; +import org.dromara.common.encrypt.annotation.EncryptField; import java.lang.reflect.Field; import java.util.Arrays; +import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -35,8 +36,13 @@ public class EncryptorManager { */ public Set getFieldCache(Class sourceClazz) { return fieldCache.computeIfAbsent(sourceClazz, clazz -> { - Field[] declaredFields = clazz.getDeclaredFields(); - Set fieldSet = Arrays.stream(declaredFields).filter(field -> + Set fieldSet = new HashSet<>(); + while (clazz != null) { + Field[] fields = clazz.getDeclaredFields(); + fieldSet.addAll(Arrays.asList(fields)); + clazz = clazz.getSuperclass(); + } + fieldSet = fieldSet.stream().filter(field -> field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class) .collect(Collectors.toSet()); for (Field field : fieldSet) {