package com.xzzn.ems.service.impl;

import java.util.List;
import com.xzzn.common.utils.DateUtils;
import com.xzzn.ems.domain.EmsMqttMessage;
import com.xzzn.ems.mapper.EmsMqttMessageMapper;
import com.xzzn.ems.service.IEmsMqttMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author xzzn
 * @date 2025-06-27
 */
@Service
public class EmsMqttMessageServiceImpl implements IEmsMqttMessageService
{
    @Autowired
    private EmsMqttMessageMapper emsMqttMessageMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public EmsMqttMessage selectEmsMqttMessageById(Long id)
    {
        return emsMqttMessageMapper.selectEmsMqttMessageById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param emsMqttMessage 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<EmsMqttMessage> selectEmsMqttMessageList(EmsMqttMessage emsMqttMessage)
    {
        return emsMqttMessageMapper.selectEmsMqttMessageList(emsMqttMessage);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param emsMqttMessage 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertEmsMqttMessage(EmsMqttMessage emsMqttMessage)
    {
        emsMqttMessage.setCreateTime(DateUtils.getNowDate());
        return emsMqttMessageMapper.insertEmsMqttMessage(emsMqttMessage);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param emsMqttMessage 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateEmsMqttMessage(EmsMqttMessage emsMqttMessage)
    {
        emsMqttMessage.setUpdateTime(DateUtils.getNowDate());
        return emsMqttMessageMapper.updateEmsMqttMessage(emsMqttMessage);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteEmsMqttMessageByIds(Long[] ids)
    {
        return emsMqttMessageMapper.deleteEmsMqttMessageByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteEmsMqttMessageById(Long id)
    {
        return emsMqttMessageMapper.deleteEmsMqttMessageById(id);
    }

    @Override
    public int insertMqttOriginalMessage(String topic, String message) {
        EmsMqttMessage mqttMessage = new EmsMqttMessage();
        mqttMessage.setMqttTopic(topic);
        mqttMessage.setMqttMessage(message);
        mqttMessage.setCreateTime(new java.util.Date());
        mqttMessage.setUpdateTime(new java.util.Date());
        mqttMessage.setCreateBy("system");
        mqttMessage.setUpdateBy("system");
        mqttMessage.setUpdateTime(DateUtils.getNowDate());
        return emsMqttMessageMapper.insertEmsMqttMessage(mqttMessage);
    }
}
