package com.ruoyi.baseinfo.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.baseinfo.mapper.BaseDeviceInfoMapper;
import com.ruoyi.baseinfo.domain.BaseDeviceInfo;
import com.ruoyi.baseinfo.service.IBaseDeviceInfoService;
import com.ruoyi.common.core.text.Convert;

/**
 * 设备基础信息Service业务层处理
 * 
 * @author CaesarBao
 * @date 2020-10-22
 */
@Service
public class BaseDeviceInfoServiceImpl implements IBaseDeviceInfoService 
{
    @Autowired
    private BaseDeviceInfoMapper baseDeviceInfoMapper;

    /**
     * 查询设备基础信息
     * 
     * @param objid 设备基础信息ID
     * @return 设备基础信息
     */
    @Override
    public BaseDeviceInfo selectBaseDeviceInfoById(Long objid)
    {
        return baseDeviceInfoMapper.selectBaseDeviceInfoById(objid);
    }

    /**
     * 查询设备基础信息列表
     * 
     * @param baseDeviceInfo 设备基础信息
     * @return 设备基础信息
     */
    @Override
    public List<BaseDeviceInfo> selectBaseDeviceInfoList(BaseDeviceInfo baseDeviceInfo)
    {
        return baseDeviceInfoMapper.selectBaseDeviceInfoList(baseDeviceInfo);
    }

    /**
     * 新增设备基础信息
     * 
     * @param baseDeviceInfo 设备基础信息
     * @return 结果
     */
    @Override
    public int insertBaseDeviceInfo(BaseDeviceInfo baseDeviceInfo)
    {
        baseDeviceInfo.setCreateTime(DateUtils.getNowDate());
        return baseDeviceInfoMapper.insertBaseDeviceInfo(baseDeviceInfo);
    }

    /**
     * 修改设备基础信息
     * 
     * @param baseDeviceInfo 设备基础信息
     * @return 结果
     */
    @Override
    public int updateBaseDeviceInfo(BaseDeviceInfo baseDeviceInfo)
    {
        baseDeviceInfo.setUpdateTime(DateUtils.getNowDate());
        return baseDeviceInfoMapper.updateBaseDeviceInfo(baseDeviceInfo);
    }

    /**
     * 删除设备基础信息对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBaseDeviceInfoByIds(String ids)
    {
        return baseDeviceInfoMapper.deleteBaseDeviceInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除设备基础信息信息
     * 
     * @param objid 设备基础信息ID
     * @return 结果
     */
    @Override
    public int deleteBaseDeviceInfoById(Long objid)
    {
        return baseDeviceInfoMapper.deleteBaseDeviceInfoById(objid);
    }

    @Override
    public List<BaseDeviceInfo> selectEditBaseDeviceInfoList(String deviceId)
    {
        BaseDeviceInfo baseDeviceInfos = new BaseDeviceInfo();
        List<BaseDeviceInfo> baseDeviceInfoList = baseDeviceInfoMapper.selectBaseDeviceInfoList(baseDeviceInfos);
        for (BaseDeviceInfo baseDeviceInfo:baseDeviceInfoList
             ) {
            if(baseDeviceInfo.getDeviceId().equals(deviceId)){
                baseDeviceInfo.setFlag(true);
                break;
            }
        }
        return baseDeviceInfoList;
    }
}
