package com.ruoyi.zongzhi.service.impl;

import java.util.List;

import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zongzhi.mapper.TcYqFlMapper;
import com.ruoyi.zongzhi.domain.TcYqFl;
import com.ruoyi.zongzhi.service.ITcYqFlService;

/**
 * 舆情分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-28
 */
@Service
public class TcYqFlServiceImpl implements ITcYqFlService 
{
    @Autowired
    private TcYqFlMapper tcYqFlMapper;

    /**
     * 查询舆情分类
     * 
     * @param id 舆情分类主键
     * @return 舆情分类
     */
    @Override
    public TcYqFl selectTcYqFlById(Long id)
    {
        return tcYqFlMapper.selectTcYqFlById(id);
    }

    /**
     * 查询舆情分类列表
     * 
     * @param tcYqFl 舆情分类
     * @return 舆情分类
     */
    @Override
    public List<TcYqFl> selectTcYqFlList(TcYqFl tcYqFl)
    {
        return tcYqFlMapper.selectTcYqFlList(tcYqFl);
    }

    /**
     * 新增舆情分类
     * 
     * @param tcYqFl 舆情分类
     * @return 结果
     */
    @Override
    public int insertTcYqFl(TcYqFl tcYqFl)
    {
        List<TcYqFl> list =tcYqFlMapper.selectTcYqFlList(tcYqFl);
       if (list.contains(tcYqFl.getMediaType())){
           throw new ServiceException("此媒体类型已存在");
       }else if(list.contains(tcYqFl.getEventType())){
           throw new ServiceException("此涉事类型已存在");
       }
        return tcYqFlMapper.insertTcYqFl(tcYqFl);
    }

    /**
     * 修改舆情分类
     * 
     * @param tcYqFl 舆情分类
     * @return 结果
     */
    @Override
    public int updateTcYqFl(TcYqFl tcYqFl)
    {
        return tcYqFlMapper.updateTcYqFl(tcYqFl);
    }

    /**
     * 批量删除舆情分类
     * 
     * @param ids 需要删除的舆情分类主键
     * @return 结果
     */
    @Override
    public int deleteTcYqFlByIds(Long[] ids)
    {
        return tcYqFlMapper.deleteTcYqFlByIds(ids);
    }

    /**
     * 删除舆情分类信息
     * 
     * @param id 舆情分类主键
     * @return 结果
     */
    @Override
    public int deleteTcYqFlById(Long id)
    {
        return tcYqFlMapper.deleteTcYqFlById(id);
    }
}
