public class SensitiveFilter {
private final TrieNode root = new TrieNode();
// 初始化敏感词字典树
public void loadKeywords(List<String> keywords) {
for (String word : keywords) {
TrieNode current = root;
for (char c : word.toCharArray()) {
current = current.getChildren().computeIfAbsent(c, k -> new TrieNode());
}
current.setEnd(true);
}
}
// 过滤文本
public String filter(String text) {
// 实现DFA遍历替换逻辑...
}
}
3. 数据看板接口(MyBatis Plus + ECharts)
@GetMapping("/dashboard/sales-rank")
public Result getSalesRank(@RequestParam String period) {
QueryWrapper<Evaluation> wrapper = new QueryWrapper<>();
wrapper.select("salesman_id, AVG(score) as avg_score")
.groupBy("salesman_id")
.orderByDesc("avg_score")
.apply("DATE_FORMAT(create_time,'%Y-%m') = {0}", period);
return Result.success(evaluationMapper.selectMaps(wrapper));
}