mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-03 11:05:58 +00:00
fix 修复 加解密拦截器null问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.common.encrypt.interceptor;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.encrypt.annotation.EncryptField;
|
||||
import com.ruoyi.common.encrypt.core.EncryptContext;
|
||||
@@ -55,13 +56,20 @@ public class MybatisDecryptInterceptor implements Interceptor {
|
||||
* @param sourceObject 待加密对象
|
||||
*/
|
||||
private void decryptHandler(Object sourceObject) {
|
||||
if (ObjectUtil.isNull(sourceObject)) {
|
||||
return;
|
||||
}
|
||||
if (sourceObject instanceof Map<?, ?>) {
|
||||
((Map<?, ?>) sourceObject).values().forEach(this::decryptHandler);
|
||||
return;
|
||||
}
|
||||
if (sourceObject instanceof List<?>) {
|
||||
List<?> sourceList = (List<?>) sourceObject;
|
||||
if(CollectionUtil.isEmpty(sourceList)) {
|
||||
return;
|
||||
}
|
||||
// 判断第一个元素是否含有注解。如果没有直接返回,提高效率
|
||||
Object firstItem = ((List<?>) sourceObject).get(0);
|
||||
Object firstItem = sourceList.get(0);
|
||||
if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {
|
||||
return;
|
||||
}
|
||||
|
@@ -66,13 +66,20 @@ public class MybatisEncryptInterceptor implements Interceptor {
|
||||
* @param sourceObject 待加密对象
|
||||
*/
|
||||
private void encryptHandler(Object sourceObject) {
|
||||
if (ObjectUtil.isNull(sourceObject)) {
|
||||
return;
|
||||
}
|
||||
if (sourceObject instanceof Map<?, ?>) {
|
||||
((Map<?, ?>) sourceObject).values().forEach(this::encryptHandler);
|
||||
return;
|
||||
}
|
||||
if (sourceObject instanceof List<?>) {
|
||||
List<?> sourceList = (List<?>) sourceObject;
|
||||
if(CollectionUtil.isEmpty(sourceList)) {
|
||||
return;
|
||||
}
|
||||
// 判断第一个元素是否含有注解。如果没有直接返回,提高效率
|
||||
Object firstItem = ((List<?>) sourceObject).get(0);
|
||||
Object firstItem = sourceList.get(0);
|
||||
if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user