|
|
|
@ -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<Field> 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);
|
|
|
|
|