|
@@ -2,14 +2,20 @@ package com.fdkankan.common.validation;
|
|
|
|
|
|
import com.fdkankan.common.constant.ConstantFileName;
|
|
import com.fdkankan.common.constant.ConstantFileName;
|
|
|
|
|
|
|
|
+import com.fdkankan.common.constant.ServerCode;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import net.sf.jsqlparser.schema.Server;
|
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 敏感词过滤
|
|
* 敏感词过滤
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
public class SensitiveWord {
|
|
public class SensitiveWord {
|
|
@SuppressWarnings("rawtypes")
|
|
@SuppressWarnings("rawtypes")
|
|
public Map sensitiveWordMap = null;
|
|
public Map sensitiveWordMap = null;
|
|
@@ -21,11 +27,16 @@ public class SensitiveWord {
|
|
*/
|
|
*/
|
|
public SensitiveWord(){
|
|
public SensitiveWord(){
|
|
if (sensitiveWordMap == null){
|
|
if (sensitiveWordMap == null){
|
|
- String txtPath = this.getClass().getResource("/static/txt/"+ ConstantFileName.BBS_SENSITIVE).getPath();
|
|
|
|
- sensitiveWordMap = new SensitiveWordConfig().initKeyWord(txtPath);
|
|
|
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("static/txt/" + ConstantFileName.BBS_SENSITIVE);
|
|
|
|
+ try {
|
|
|
|
+ sensitiveWordMap = new SensitiveWordConfig().initKeyWord(classPathResource.getFile());
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("初始化敏感词失败!", e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 判断文字是否包含敏感字符
|
|
* 判断文字是否包含敏感字符
|
|
* @author chenming
|
|
* @author chenming
|