package com.ltgk.common.config.sensitiveWord;


import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.support.allow.WordAllows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 敏感词自定义数据源
 *
 * @author Qi ChengBin
 * @date 2025/02/11
 */
@Slf4j
@Configuration
public class SpringSensitiveWordConfig {

    @Resource
    private MyDbWordAllow myDbWordAllow;

    @Bean
    public SensitiveWordBs sensitiveWordBs() {
        SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
                // 允许的敏感词
                .wordAllow(WordAllows.chains(WordAllows.defaults(), myDbWordAllow))
                .init();
        log.info(">>>>>>敏感词初始化成功！");
        return sensitiveWordBs;
    }
}
