package com.ruoyi.frequency.sensitiveword.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.frequency.sensitiveword.mapper.SensitiveWordMapper;
import com.ruoyi.frequency.sensitiveword.entity.SensitiveWord;
import com.ruoyi.frequency.sensitiveword.service.SensitiveWordService;

/**
 * 敏感词Service业务层处理
 *
 * @author liwenlong
 * @date 2024-05-07
 */
@Service
public class SensitiveWordServiceImpl extends ServiceImpl<SensitiveWordMapper, SensitiveWord>  implements SensitiveWordService
{
    @Autowired
    private SensitiveWordMapper sensitiveWordMapper;

    /**
     * 查询敏感词
     *
     * @param id 敏感词主键
     * @return 敏感词
     */
    @Override
    public SensitiveWord selectSensitiveWordById(Long id)
    {
        return sensitiveWordMapper.selectSensitiveWordById(id);
    }

    /**
     * 查询敏感词列表
     *
     * @param sensitiveWord 敏感词
     * @return 敏感词
     */
    @Override
    public List<SensitiveWord> selectSensitiveWordList(SensitiveWord sensitiveWord)
    {
        return sensitiveWordMapper.selectSensitiveWordList(sensitiveWord);
    }

    /**
     * 新增敏感词
     *
     * @param sensitiveWord 敏感词
     * @return 结果
     */
    @Override
    public int insertSensitiveWord(SensitiveWord sensitiveWord)
    {
        sensitiveWord.setCreateData();
        return sensitiveWordMapper.insert(sensitiveWord);
    }

    /**
     * 修改敏感词
     *
     * @param sensitiveWord 敏感词
     * @return 结果
     */
    @Override
    public int updateSensitiveWord(SensitiveWord sensitiveWord)
    {
        sensitiveWord.setUpdateData();
        return sensitiveWordMapper.updateSensitiveWord(sensitiveWord);
    }

    /**
     * 批量删除敏感词
     *
     * @param ids 需要删除的敏感词主键
     * @return 结果
     */
    @Override
    public int deleteSensitiveWordByIds(Long[] ids,Integer delFlag)
    {
        this.lambdaUpdate().set(SensitiveWord::getDelFlag,delFlag).in(SensitiveWord::getId,ids).update();
        return ids.length;
    }

}
