package com.bonus.canteen.device.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.device.mapper.DeviceInfoMapper;
import com.bonus.canteen.device.domain.DeviceInfo;
import com.bonus.canteen.device.service.IDeviceInfoService;

/**
 * 设备资料Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-03
 */
@Service
public class DeviceInfoServiceImpl implements IDeviceInfoService {
    @Autowired
    private DeviceInfoMapper deviceInfoMapper;

    /**
     * 查询设备资料
     * 
     * @param deviceId 设备资料主键
     * @return 设备资料
     */
    @Override
    public DeviceInfo selectDeviceInfoByDeviceId(Long deviceId) {
        return deviceInfoMapper.selectDeviceInfoByDeviceId(deviceId);
    }

    /**
     * 查询设备资料列表
     * 
     * @param deviceInfo 设备资料
     * @return 设备资料
     */
    @Override
    public List<DeviceInfo> selectDeviceInfoList(DeviceInfo deviceInfo) {
        return deviceInfoMapper.selectDeviceInfoList(deviceInfo);
    }

    /**
     * 新增设备资料
     * 
     * @param deviceInfo 设备资料
     * @return 结果
     */
    @Override
    public int insertDeviceInfo(DeviceInfo deviceInfo) {
        deviceInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return deviceInfoMapper.insertDeviceInfo(deviceInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改设备资料
     * 
     * @param deviceInfo 设备资料
     * @return 结果
     */
    @Override
    public int updateDeviceInfo(DeviceInfo deviceInfo) {
        deviceInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return deviceInfoMapper.updateDeviceInfo(deviceInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除设备资料
     * 
     * @param deviceIds 需要删除的设备资料主键
     * @return 结果
     */
    @Override
    public int deleteDeviceInfoByDeviceIds(Long[] deviceIds) {
        return deviceInfoMapper.deleteDeviceInfoByDeviceIds(deviceIds);
    }

    /**
     * 删除设备资料信息
     * 
     * @param deviceId 设备资料主键
     * @return 结果
     */
    @Override
    public int deleteDeviceInfoByDeviceId(Long deviceId) {
        return deviceInfoMapper.deleteDeviceInfoByDeviceId(deviceId);
    }
}
