From d5ba003e486e7b5239b3df7dc4c9e4918d859874 Mon Sep 17 00:00:00 2001 From: mayuanfei Date: Tue, 7 Mar 2023 14:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug:=E5=BD=93=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=9A=84=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA=E6=97=B6?= =?UTF-8?q?,=E8=A7=A3=E5=AF=86=E6=96=B9=E6=B3=95=E6=8A=A5=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E8=B6=8A=E7=95=8C=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/framework/encrypt/MybatisDecryptInterceptor.java | 7 ++++++- .../ruoyi/framework/encrypt/MybatisEncryptInterceptor.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java index abd02c3bc..e316c759f 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java @@ -12,6 +12,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.executor.resultset.ResultSetHandler; import org.apache.ibatis.plugin.*; +import org.springframework.util.CollectionUtils; import java.lang.reflect.Field; import java.sql.Statement; @@ -60,8 +61,12 @@ public class MybatisDecryptInterceptor implements Interceptor { return; } if (sourceObject instanceof List) { + List sourceList = (List) sourceObject; + if(CollectionUtils.isEmpty(sourceList)) { + return; + } // 判断第一个元素是否含有注解。如果没有直接返回,提高效率 - Object firstItem = ((List) sourceObject).get(0); + Object firstItem = sourceList.get(0); if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) { return; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java index 0907e089e..cd8a7d928 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java @@ -16,6 +16,7 @@ import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.plugin.Intercepts; import org.apache.ibatis.plugin.Invocation; import org.apache.ibatis.plugin.Signature; +import org.springframework.util.CollectionUtils; import java.lang.reflect.Field; import java.sql.PreparedStatement; @@ -71,8 +72,12 @@ public class MybatisEncryptInterceptor implements Interceptor { return; } if (sourceObject instanceof List) { + List sourceList = (List) sourceObject; + if(CollectionUtils.isEmpty(sourceList)) { + return; + } // 判断第一个元素是否含有注解。如果没有直接返回,提高效率 - Object firstItem = ((List) sourceObject).get(0); + Object firstItem = sourceList.get(0); if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) { return; }