Compare commits
No commits in common. 'b40a7651659400c5835705515e4e9cc1d60a15e2' and '9b1336f40828f1a5ab1b5e5fd4bfb057f3c59a1e' have entirely different histories.
b40a765165
...
9b1336f408
@ -1,51 +0,0 @@
|
|||||||
package com.mashibing.strategy.service.strategyfilter.impl;
|
|
||||||
|
|
||||||
import com.mashibing.common.constant.CacheConstant;
|
|
||||||
import com.mashibing.common.pojo.StandardSubmit;
|
|
||||||
import com.mashibing.strategy.feignclient.CacheClient;
|
|
||||||
import com.mashibing.strategy.service.strategyfilter.StrategyFilter;
|
|
||||||
import com.mashibing.strategy.utils.DirtyWordTree;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.wltea.analyzer.core.IKSegmenter;
|
|
||||||
import org.wltea.analyzer.core.Lexeme;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author heqijun
|
|
||||||
* @ClassName: DirtyWordStrategyFilter
|
|
||||||
* @Description: 敏感词校验
|
|
||||||
* @date 2025/6/7 20:26
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service(value = "dfaDirtyword")
|
|
||||||
public class DFADirtyWordStrategyFilter implements StrategyFilter {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
CacheClient cacheClient;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void strategy(StandardSubmit submit) {
|
|
||||||
log.info("【策略模块-敏感词校验】开始====================================");
|
|
||||||
String text = submit.getText();
|
|
||||||
Set<String> set = new HashSet<>();
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
log.info("【策略模块-敏感词校验】通过敏感词树校验敏感词");
|
|
||||||
Set<String> result = DirtyWordTree.getDirtyWord(text);
|
|
||||||
|
|
||||||
if (!result.isEmpty()) {
|
|
||||||
log.error("【策略模块-敏感词校验】短信内容包含敏感词:{}", result);
|
|
||||||
return;
|
|
||||||
// throw new RuntimeException("短信内容包含敏感词");
|
|
||||||
}
|
|
||||||
log.info("【策略模块-敏感词校验】敏感词校验通过");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.mashibing.strategy.utils;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.ApplicationContextAware;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author heqijun
|
|
||||||
* @ClassName: StringUtil
|
|
||||||
* @Description: 用于在非ioc管理的类中使用spring中的bean
|
|
||||||
* @date 2025/6/8 23:09
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class StringUtil implements ApplicationContextAware {
|
|
||||||
|
|
||||||
private static ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
||||||
StringUtil.applicationContext = applicationContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object getBeanByName(String beanName) {
|
|
||||||
return applicationContext.getBean(beanName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object getBeanByClass(Class<?> clazz) {
|
|
||||||
return applicationContext.getBean(clazz);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue