package com.fs.qw.service.impl;

import com.fs.common.utils.DateUtils;
import com.fs.qw.domain.QwForbiddenMessage;
import com.fs.qw.domain.QwForbiddenMessageList;
import com.fs.qw.domain.QwForbiddenWords;
import com.fs.qw.mapper.QwForbiddenMessageMapper;
import com.fs.qw.mapper.QwForbiddenWordsMapper;
import com.fs.qw.param.QwForbiddenMessageParam;
import com.fs.qw.service.IQwForbiddenMessageService;
import com.fs.qw.service.IQwForbiddenWordsService;
import com.fs.qw.vo.QwForbiddenMessageListVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * 企微违禁消息Service业务层处理
 *
 * @author fs
 * @date 2023-11-22
 */
@Service
public class QwForbiddenMessageServiceImpl implements IQwForbiddenMessageService
{
    @Autowired
    private QwForbiddenMessageMapper qwForbiddenMessageMapper;

    /**
     * 查询企微违禁消息
     *
     * @param id 企微违禁消息ID
     * @return 企微违禁消息
     */
    @Override
    public QwForbiddenMessage selectQwForbiddenMessageById(Long id)
    {
        return qwForbiddenMessageMapper.selectQwForbiddenMessageById(id);
    }

    /**
     * 查询企微违禁消息列表
     *
     * @param qwForbiddenMessage 企微违禁消息
     * @return 企微违禁消息
     */
    @Override
    public List<QwForbiddenMessage> selectQwForbiddenMessageList(QwForbiddenMessage qwForbiddenMessage)
    {
        return qwForbiddenMessageMapper.selectQwForbiddenMessageList(qwForbiddenMessage);
    }

    /**
     * 新增企微违禁消息
     *
     * @param qwForbiddenMessage 企微违禁消息
     * @return 结果
     */
    @Override
    public void insertQwForbiddenMessage(QwForbiddenMessage qwForbiddenMessage)
    {
        qwForbiddenMessage.setCreateTime(DateUtils.getNowDate());
        qwForbiddenMessageMapper.insertQwForbiddenMessage(qwForbiddenMessage);
    }

    /**
     * 修改企微违禁消息
     *
     * @param qwForbiddenMessage 企微违禁消息
     * @return 结果
     */
    @Override
    public int updateQwForbiddenMessage(QwForbiddenMessage qwForbiddenMessage)
    {
        return qwForbiddenMessageMapper.updateQwForbiddenMessage(qwForbiddenMessage);
    }

    /**
     * 批量删除企微违禁消息
     *
     * @param ids 需要删除的企微违禁消息ID
     * @return 结果
     */
    @Override
    public int deleteQwForbiddenMessageByIds(Long[] ids)
    {
        return qwForbiddenMessageMapper.deleteQwForbiddenMessageByIds(ids);
    }

    /**
     * 删除企微违禁消息信息
     *
     * @param id 企微违禁消息ID
     * @return 结果
     */
    @Override
    public int deleteQwForbiddenMessageById(Long id)
    {
        return qwForbiddenMessageMapper.deleteQwForbiddenMessageById(id);
    }

    @Override
    public List<QwForbiddenMessageList> selectQwForbiddenMessageListVO(QwForbiddenMessageParam param) {
//        List<QwForbiddenMessageListVO> list = new ArrayList<>();
//        List<QwForbiddenMessageList> messageLists = qwForbiddenMessageMapper.selectQwForbiddenMessageListVO(param);
//        for (QwForbiddenMessageList messageList : messageLists){
//            QwForbiddenMessageListVO vo = new QwForbiddenMessageListVO();
//            BeanUtils.copyProperties(messageList,vo);
//            vo.setForbiddenMessage("员工在企微账号"+messageList.getAccount()+"聊天中存在违禁词"+",聊天内容为:  \'"+messageList.getContent()+"\' ,请及时查看处理");
//            list.add(vo);
//        }
//        return list;
        return qwForbiddenMessageMapper.selectQwForbiddenMessageListVO(param);
    }
}
