From 177249c76aeea0b4bf8d8816d4994e3b445b45ce Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 02 九月 2021 10:39:34 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/zzj' into zzj --- springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/helper/encrypt/ResultInterceptor.java | 41 ++++++++++++++++++++--------------------- 1 files changed, 20 insertions(+), 21 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/helper/encrypt/ResultInterceptor.java b/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/helper/encrypt/ResultInterceptor.java index bc4370a..ab7a0fd 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/helper/encrypt/ResultInterceptor.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/helper/encrypt/ResultInterceptor.java @@ -1,8 +1,10 @@ package com.panzhihua.service_grid.model.helper.encrypt; -import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; -import com.panzhihua.common.model.helper.encrypt.IEncryptDecrypt; -import lombok.extern.slf4j.Slf4j; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Objects; +import java.util.Properties; + import org.apache.ibatis.executor.resultset.ResultSetHandler; import org.apache.ibatis.plugin.*; import org.springframework.beans.factory.annotation.Autowired; @@ -11,10 +13,10 @@ import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Objects; -import java.util.Properties; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.IEncryptDecrypt; + +import lombok.extern.slf4j.Slf4j; /** * 解密拦截器 @@ -22,9 +24,7 @@ * @author cedoo * @since 2021-4-1 10:40:52 */ -@Intercepts({ - @Signature(type = ResultSetHandler.class, method = "handleResultSets", args={Statement.class}) -}) +@Intercepts({@Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})}) @ConditionalOnProperty(value = "domain.decrypt", havingValue = "true") @Component @Slf4j @@ -37,32 +37,31 @@ @Override public Object intercept(Invocation invocation) throws Throwable { Object result = invocation.proceed(); - if (Objects.isNull(result)){ + if (Objects.isNull(result)) { return null; } if (result instanceof ArrayList) { - ArrayList resultList = (ArrayList) result; - if (resultList!=null && resultList.size()>0 && needToDecrypt(resultList.get(0))){ + ArrayList resultList = (ArrayList)result; + if (resultList != null && resultList.size() > 0 && needToDecrypt(resultList.get(0))) { for (int i = 0; i < resultList.size(); i++) { encryptDecrypt.decrypt(resultList.get(i)); } } - }else { - if (needToDecrypt(result)){ + } else { + if (needToDecrypt(result)) { encryptDecrypt.decrypt(result); } } return result; } - public boolean needToDecrypt(Object object){ - if(object!=null) { + public boolean needToDecrypt(Object object) { + if (object != null) { Class<?> objectClass = object.getClass(); - EncryptDecryptClass encryptDecryptClass = AnnotationUtils.findAnnotation(objectClass, EncryptDecryptClass.class); - if (Objects.nonNull(encryptDecryptClass)) { - return true; - } + EncryptDecryptClass encryptDecryptClass = + AnnotationUtils.findAnnotation(objectClass, EncryptDecryptClass.class); + return Objects.nonNull(encryptDecryptClass); } return false; } -- Gitblit v1.7.1