diff --git a/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisDecryptInterceptor.java b/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisDecryptInterceptor.java index 1bdd1c7c..a3de1341 100644 --- a/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisDecryptInterceptor.java +++ b/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisDecryptInterceptor.java @@ -76,7 +76,12 @@ public class MybatisDecryptInterceptor implements Interceptor { Set fields = encryptorManager.getFieldCache(sourceObject.getClass()); try { for (Field field : fields) { - field.set(sourceObject, this.decryptField(String.valueOf(field.get(sourceObject)), field)); + // 防止对象不是null 属性内容是null + Object obj = field.get(sourceObject); + if (ObjectUtil.isNull(obj)) { + continue; + } + field.set(sourceObject, this.decryptField(String.valueOf(field.get(obj)), field)); } } catch (Exception e) { log.error("处理解密字段时出错", e); diff --git a/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisEncryptInterceptor.java b/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisEncryptInterceptor.java index 3b3f1419..f11ffe3c 100644 --- a/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisEncryptInterceptor.java +++ b/ruoyi-common/ruoyi-common-encrypt/src/main/java/com/ruoyi/common/encrypt/interceptor/MybatisEncryptInterceptor.java @@ -86,7 +86,12 @@ public class MybatisEncryptInterceptor implements Interceptor { Set fields = encryptorManager.getFieldCache(sourceObject.getClass()); try { for (Field field : fields) { - field.set(sourceObject, this.encryptField(String.valueOf(field.get(sourceObject)), field)); + // 防止对象不是null 属性内容是null + Object obj = field.get(sourceObject); + if (ObjectUtil.isNull(obj)) { + continue; + } + field.set(sourceObject, this.encryptField(String.valueOf(field.get(obj)), field)); } } catch (Exception e) { log.error("处理加密字段时出错", e);