Pre Merge pull request !297 from _老马_/dev

This commit is contained in:
_老马_ 2023-03-07 06:20:38 +00:00 committed by Gitee
commit 6b61160dc3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 12 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.resultset.ResultSetHandler; import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.plugin.*; import org.apache.ibatis.plugin.*;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.sql.Statement; import java.sql.Statement;
@ -60,8 +61,12 @@ public class MybatisDecryptInterceptor implements Interceptor {
return; return;
} }
if (sourceObject instanceof List<?>) { 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()))) { if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {
return; return;
} }

View File

@ -16,6 +16,7 @@ import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts; import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation; import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature; import org.apache.ibatis.plugin.Signature;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -71,8 +72,12 @@ public class MybatisEncryptInterceptor implements Interceptor {
return; return;
} }
if (sourceObject instanceof List<?>) { 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()))) { if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {
return; return;
} }