提交 27fea82b authored 作者: liyinqiao's avatar liyinqiao

增加公共方法

上级 546e3d3a
package cn.gtmap.bdcdj.core.encrypt; package cn.gtmap.bdcdj.core.encrypt;
import cn.gtmap.bdcdj.core.encrypt.annotation.Encrypt;
import cn.gtmap.bdcdj.core.encrypt.executor.CryptType; import cn.gtmap.bdcdj.core.encrypt.executor.CryptType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.executor.Executor; import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.mapping.MappedStatement;
...@@ -13,20 +13,15 @@ import org.apache.ibatis.plugin.Plugin; ...@@ -13,20 +13,15 @@ import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature; import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import org.reflections.scanners.FieldAnnotationsScanner;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.util.Collections;
import java.lang.reflect.Method; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Intercepts({@Signature( @Intercepts({@Signature(
...@@ -54,6 +49,49 @@ public class EncryptInterceptor implements Interceptor { ...@@ -54,6 +49,49 @@ public class EncryptInterceptor implements Interceptor {
} }
private static final Logger LOGGER = LoggerFactory.getLogger(EncryptInterceptor.class); private static final Logger LOGGER = LoggerFactory.getLogger(EncryptInterceptor.class);
/**
* @param
* @return
* @author <a href="mailto:liyinqiao@gtmap.cn">liyinqiao</a>
* @version 1.0, 2024/4/7
* @description 判断是否开启加解密
*/
public boolean isCryptEnable(){
return cryptEnable;
}
/**
* @param
* @return
* @author <a href="mailto:liyinqiao@gtmap.cn">liyinqiao</a>
* @version 1.0, 2024/4/7
* @description 判断是否某组是否开启加解密
*/
public boolean isCryptGroup(String groupName){
if(isCryptEnable() && StringUtils.isNotBlank(groupName)){
List<String> groups = getCryptGroups();
if(CollectionUtils.isNotEmpty(groups)){
return groups.contains(groupName);
}
}
return false;
}
/**
* @param
* @return
* @author <a href="mailto:liyinqiao@gtmap.cn">liyinqiao</a>
* @version 1.0, 2024/4/7
* @description 获取全部加解密组
*/
public List<String> getCryptGroups(){
if(isCryptEnable()&& CollectionUtils.isNotEmpty(dbEncryptXmlConfig.getAnnoGroupNames())){
return dbEncryptXmlConfig.getAnnoGroupNames();
}
return Collections.EMPTY_LIST;
}
@Override @Override
public Object intercept(Invocation invocation) throws Throwable { public Object intercept(Invocation invocation) throws Throwable {
if (this.cryptEnable) { if (this.cryptEnable) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论