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) {