package com.fs.watch.service.impl;

import com.fs.common.utils.DateUtils;
import com.fs.watch.domain.DeviceMaterials;
import com.fs.watch.domain.vo.DeviceMaterialsVo;
import com.fs.watch.mapper.DeviceMaterialsMapper;
import com.fs.watch.service.DeviceMaterialsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceMaterialsServiceImpl implements DeviceMaterialsService {
    @Autowired
    private DeviceMaterialsMapper deviceMaterialsMapper;

    /**
     * 查询设备物料信息
     *
     * @param id 设备物料信息主键
     * @return 设备物料信息
     */
    @Override
    public DeviceMaterials selectDeviceMaterialsById(Long id) {
        return deviceMaterialsMapper.selectDeviceMaterialsById(id);
    }

    /**
     * 查询设备物料信息列表
     *
     * @param deviceMaterials 设备物料信息
     * @return 设备物料信息
     */
    @Override
    public List<DeviceMaterialsVo> selectDeviceMaterialsList(DeviceMaterials deviceMaterials) {
        return deviceMaterialsMapper.selectDeviceMaterialsList(deviceMaterials);
    }

    /**
     * 新增设备物料信息
     *
     * @param deviceMaterials 设备物料信息
     * @return 结果
     */
    @Override
    public int insertDeviceMaterials(DeviceMaterials deviceMaterials) {
        deviceMaterials.setCreateTime(DateUtils.getNowDate());
        return deviceMaterialsMapper.insertDeviceMaterials(deviceMaterials);
    }

    /**
     * 修改设备物料信息
     *
     * @param deviceMaterials 设备物料信息
     * @return 结果
     */
    @Override
    public int updateDeviceMaterials(DeviceMaterials deviceMaterials) {
        deviceMaterials.setUpdateTime(DateUtils.getNowDate());
        return deviceMaterialsMapper.updateDeviceMaterials(deviceMaterials);
    }

    /**
     * 批量删除设备物料信息
     *
     * @param ids 需要删除的设备物料信息主键
     * @return 结果
     */
    @Override
    public int deleteDeviceMaterialsByIds(Long[] ids) {
        return deviceMaterialsMapper.deleteDeviceMaterialsByIds(ids);
    }

    /**
     * 删除设备物料信息信息
     *
     * @param id 设备物料信息主键
     * @return 结果
     */
    @Override
    public int deleteDeviceMaterialsById(Long id) {
        return deviceMaterialsMapper.deleteDeviceMaterialsById(id);
    }

    @Override
    public Boolean updateCount(String deviceId, int type, String updateTime) {
        return deviceMaterialsMapper.updateCount(deviceId, type, updateTime);
    }
}
