package com.fs.watch.service.impl;

import java.util.Date;
import java.util.List;

import com.fs.watch.service.WatchSendMsgLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.watch.mapper.WatchSendMsgLogMapper;
import com.fs.watch.domain.WatchSendMsgLog;

/**
 * 发送消息日志记录Service业务层处理
 *
 * @author fs
 * @date 2024-12-02
 */
@Service
public class WatchSendMsgLogServiceImpl implements WatchSendMsgLogService
{
    @Autowired
    private WatchSendMsgLogMapper watchSendMsgLogMapper;

    /**
     * 查询发送消息日志记录
     *
     * @param logId 发送消息日志记录主键
     * @return 发送消息日志记录
     */
    @Override
    public WatchSendMsgLog selectWatchSendMsgLogByLogId(Integer logId)
    {
        return watchSendMsgLogMapper.selectWatchSendMsgLogByLogId(logId);
    }

    /**
     * 查询发送消息日志记录列表
     *
     * @param watchSendMsgLog 发送消息日志记录
     * @return 发送消息日志记录
     */
    @Override
    public List<WatchSendMsgLog> selectWatchSendMsgLogList(WatchSendMsgLog watchSendMsgLog)
    {
        return watchSendMsgLogMapper.selectWatchSendMsgLogList(watchSendMsgLog);
    }

    /**
     * 新增发送消息日志记录
     *
     * @param watchSendMsgLog 发送消息日志记录
     * @return 结果
     */
    @Override
    public int insertWatchSendMsgLog(WatchSendMsgLog watchSendMsgLog)
    {
        watchSendMsgLog.setOperTime(new Date());
        return watchSendMsgLogMapper.insertWatchSendMsgLog(watchSendMsgLog);
    }

    /**
     * 修改发送消息日志记录
     *
     * @param watchSendMsgLog 发送消息日志记录
     * @return 结果
     */
    @Override
    public int updateWatchSendMsgLog(WatchSendMsgLog watchSendMsgLog)
    {
        return watchSendMsgLogMapper.updateWatchSendMsgLog(watchSendMsgLog);
    }

    /**
     * 批量删除发送消息日志记录
     *
     * @param logIds 需要删除的发送消息日志记录主键
     * @return 结果
     */
    @Override
    public int deleteWatchSendMsgLogByLogIds(Integer[] logIds)
    {
        return watchSendMsgLogMapper.deleteWatchSendMsgLogByLogIds(logIds);
    }

    /**
     * 删除发送消息日志记录信息
     *
     * @param logId 发送消息日志记录主键
     * @return 结果
     */
    @Override
    public int deleteWatchSendMsgLogByLogId(Integer logId)
    {
        return watchSendMsgLogMapper.deleteWatchSendMsgLogByLogId(logId);
    }

    /**
     * 根据消息类型和设备id查询最新一条发送成功的日志
     * @param msgType
     * @param deviceId
     * @return
     */
    @Override
    public WatchSendMsgLog selectLastByMsgTypeAndDeviceIdAndDetailsType(Integer msgType, String deviceId,String detailsType) {
        return watchSendMsgLogMapper.selectLastByMsgTypeAndDeviceIdAndDetailsType(msgType,deviceId,detailsType);
    }
}
