敏感词加载继续优化一下,初始化放在consumer中执行

This commit is contained in:
Chopper
2021-11-29 11:47:54 +08:00
parent d16df738d3
commit 61aa3ca3d2
2 changed files with 43 additions and 2 deletions

View File

@@ -0,0 +1,39 @@
package cn.lili.init;
import cn.lili.cache.Cache;
import cn.lili.cache.CachePrefix;
import cn.lili.common.sensitive.SensitiveWordsFilter;
import cn.lili.modules.system.service.SensitiveWordsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* SensitiveWordsInit
*
* @author Chopper
* @version v1.0
* 2021-11-29 11:38
*/
@Slf4j
@Component
public class SensitiveWordsInit implements ApplicationRunner {
@Autowired
private SensitiveWordsService sensitiveWordsService;
/**
* consumer 启动时,实时更新一下过滤词
*
* @param args 启动参数
*/
@Override
public void run(ApplicationArguments args) {
sensitiveWordsService.resetCache();
}
}