package com.tourism.webadmin.utils;

import com.github.houbb.sensitive.word.api.IWordDeny;
import com.tourism.webadmin.back.model.TourImSensitiveWordDeny;
import com.tourism.webadmin.back.service.TourImSensitiveWordDenyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * MyWordAllowUtils 类。
 * <p>
 * 描述：自定义敏感词 白名单
 *
 * @author huangwenwen
 * @date 2024/12/20
 */


@Component
public class MyWordDeny implements IWordDeny {
    @Autowired
    private TourImSensitiveWordDenyService tourImSensitiveWordDenyService;

    @Override
    public List<String> deny() {
//        List<String> list = new ArrayList<>();
//        list.add("李忠畅");
//        list.add("你好");
//        list.add("大家好");

        List<TourImSensitiveWordDeny> allList = tourImSensitiveWordDenyService.getAllList();
        return allList.stream().map(TourImSensitiveWordDeny::getWord).collect(Collectors.toList());
//        return list;
    }
}
