package com.shzg.project.worn.service.impl;

import java.util.List;
import com.shzg.common.utils.DateUtils;
import com.shzg.common.utils.DeptScopeUtils;
import com.shzg.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shzg.project.worn.mapper.MqttSensorDataMapper;
import com.shzg.project.worn.domain.MqttSensorData;
import com.shzg.project.worn.service.IMqttSensorDataService;

/**
 * 设备数据Service业务层处理
 * 
 * @author shzg
 * @date 2026-04-01
 */
@Service
public class MqttSensorDataServiceImpl implements IMqttSensorDataService 
{
    @Autowired
    private MqttSensorDataMapper mqttSensorDataMapper;

    /**
     * 查询设备数据
     * 
     * @param id 设备数据主键
     * @return 设备数据
     */
    @Override
    public MqttSensorData selectMqttSensorDataById(Long id)
    {
        return mqttSensorDataMapper.selectMqttSensorDataById(id);
    }

    /**
     * 查询设备数据列表
     * 
     * @param mqttSensorData 设备数据
     * @return 设备数据
     */
    @Override
    public List<MqttSensorData> selectMqttSensorDataList(MqttSensorData mqttSensorData)
    {
        if (!SecurityUtils.isAdmin())
        {
            mqttSensorData.setDeptIds(DeptScopeUtils.getDeptScope());
        }
        return mqttSensorDataMapper.selectMqttSensorDataList(mqttSensorData);
    }

    /**
     * 新增设备数据
     * 
     * @param mqttSensorData 设备数据
     * @return 结果
     */
    @Override
    public int insertMqttSensorData(MqttSensorData mqttSensorData)
    {
        mqttSensorData.setCreateTime(DateUtils.getNowDate());
        return mqttSensorDataMapper.insertMqttSensorData(mqttSensorData);
    }

    /**
     * 修改设备数据
     * 
     * @param mqttSensorData 设备数据
     * @return 结果
     */
    @Override
    public int updateMqttSensorData(MqttSensorData mqttSensorData)
    {
        mqttSensorData.setUpdateTime(DateUtils.getNowDate());
        return mqttSensorDataMapper.updateMqttSensorData(mqttSensorData);
    }

    /**
     * 批量删除设备数据
     * 
     * @param ids 需要删除的设备数据主键
     * @return 结果
     */
    @Override
    public int deleteMqttSensorDataByIds(Long[] ids)
    {
        return mqttSensorDataMapper.deleteMqttSensorDataByIds(ids);
    }

    /**
     * 删除设备数据信息
     * 
     * @param id 设备数据主键
     * @return 结果
     */
    @Override
    public int deleteMqttSensorDataById(Long id)
    {
        return mqttSensorDataMapper.deleteMqttSensorDataById(id);
    }
}
