package com.fs.live.service.impl;


import com.fs.live.domain.LiveSensitiveWords;
import com.fs.live.mapper.LiveSensitiveWordsMapper;
import com.fs.live.service.ILiveSensitiveWordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 直播间敏感词过滤Service业务层处理
 *
 * @author fs
 * @date 2025-07-08
 */
@Service
public class LiveSensitiveWordsServiceImpl implements ILiveSensitiveWordsService {
    @Resource
    private LiveSensitiveWordsMapper baseMapper;

    /**
     * 查询直播间敏感词过滤
     *
     * @param wordId 直播间敏感词过滤主键
     * @return 直播间敏感词过滤
     */
    @Override
    public LiveSensitiveWords selectLiveSensitiveWordsByWordId(Long wordId)
    {
        return baseMapper.selectLiveSensitiveWordsByWordId(wordId);
    }

    /**
     * 查询直播间敏感词过滤列表
     *
     * @param liveSensitiveWords 直播间敏感词过滤
     * @return 直播间敏感词过滤
     */
    @Override
    public List<LiveSensitiveWords> selectLiveSensitiveWordsList(LiveSensitiveWords liveSensitiveWords)
    {
        return baseMapper.selectLiveSensitiveWordsList(liveSensitiveWords);
    }

    /**
     * 新增直播间敏感词过滤
     *
     * @param liveSensitiveWords 直播间敏感词过滤
     * @return 结果
     */
    @Override
    public int insertLiveSensitiveWords(LiveSensitiveWords liveSensitiveWords)
    {
        int count = baseMapper.selectWordsByName(liveSensitiveWords.getWord());
        if(count > 0) return -1;
        liveSensitiveWords.setCreateTime(new Date());
        return baseMapper.insertLiveSensitiveWords(liveSensitiveWords);
    }

    /**
     * 修改直播间敏感词过滤
     *
     * @param liveSensitiveWords 直播间敏感词过滤
     * @return 结果
     */
    @Override
    public int updateLiveSensitiveWords(LiveSensitiveWords liveSensitiveWords)
    {
        liveSensitiveWords.setCreateTime(new Date());
        return baseMapper.updateLiveSensitiveWords(liveSensitiveWords);
    }

    /**
     * 批量删除直播间敏感词过滤
     *
     * @param wordIds 需要删除的直播间敏感词过滤主键
     * @return 结果
     */
    @Override
    public int deleteLiveSensitiveWordsByWordIds(Long[] wordIds)
    {
        return baseMapper.deleteLiveSensitiveWordsByWordIds(wordIds);
    }

    /**
     * 删除直播间敏感词过滤信息
     *
     * @param wordId 直播间敏感词过滤主键
     * @return 结果
     */
    @Override
    public int deleteLiveSensitiveWordsByWordId(Long wordId)
    {
        return baseMapper.deleteLiveSensitiveWordsByWordId(wordId);
    }

    @Override
    public List<String> selectAllWords() {
        return baseMapper.selectAllWords();
    }
}
