From a48c7e5e108a35148a15c7c44dd7f0efc34caf9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Thu, 13 Jul 2023 19:13:46 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/MybatisDecryptInterceptor.java | 2 +- .../interceptor/MybatisEncryptInterceptor.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisDecryptInterceptor.java b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisDecryptInterceptor.java index b85af964..8bce25c8 100644 --- a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisDecryptInterceptor.java +++ b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisDecryptInterceptor.java @@ -75,7 +75,7 @@ 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)); + field.set(sourceObject, this.decryptField(Convert.toStr(field.get(sourceObject)), field)); } } catch (Exception e) { log.error("处理解密字段时出错", e); diff --git a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisEncryptInterceptor.java b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisEncryptInterceptor.java index 49bd08bc..152f7db4 100644 --- a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisEncryptInterceptor.java +++ b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/interceptor/MybatisEncryptInterceptor.java @@ -1,14 +1,8 @@ package org.dromara.common.encrypt.interceptor; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; -import org.dromara.common.core.utils.StringUtils; -import org.dromara.common.encrypt.annotation.EncryptField; -import org.dromara.common.encrypt.core.EncryptContext; -import org.dromara.common.encrypt.core.EncryptorManager; -import org.dromara.common.encrypt.enumd.AlgorithmType; -import org.dromara.common.encrypt.enumd.EncodeType; -import org.dromara.common.encrypt.properties.EncryptorProperties; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.executor.parameter.ParameterHandler; @@ -16,6 +10,13 @@ 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.dromara.common.core.utils.StringUtils; +import org.dromara.common.encrypt.annotation.EncryptField; +import org.dromara.common.encrypt.core.EncryptContext; +import org.dromara.common.encrypt.core.EncryptorManager; +import org.dromara.common.encrypt.enumd.AlgorithmType; +import org.dromara.common.encrypt.enumd.EncodeType; +import org.dromara.common.encrypt.properties.EncryptorProperties; import java.lang.reflect.Field; import java.sql.PreparedStatement; @@ -84,7 +85,7 @@ 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)); + field.set(sourceObject, this.encryptField(Convert.toStr(field.get(sourceObject)), field)); } } catch (Exception e) { log.error("处理加密字段时出错", e);