package com.ruoyi.ss.abnormal.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.abnormal.domain.Abnormal;
import com.ruoyi.ss.abnormal.domain.AbnormalQuery;
import com.ruoyi.ss.abnormal.domain.AbnormalVO;
import com.ruoyi.ss.abnormal.mapper.AbnormalMapper;
import com.ruoyi.ss.abnormal.service.AbnormalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备故障Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-30
 */
@Service
public class AbnormalServiceImpl implements AbnormalService
{
    @Autowired
    private AbnormalMapper abnormalMapper;

    /**
     * 查询设备故障
     *
     * @param abnormalId 设备故障主键
     * @return 设备故障
     */
    @Override
    public AbnormalVO selectAbnormalByAbnormalId(Long abnormalId)
    {
        return abnormalMapper.selectAbnormalByAbnormalId(abnormalId);
    }

    /**
     * 查询设备故障列表
     *
     * @param abnormal 设备故障
     * @return 设备故障
     */
    @Override
    public List<AbnormalVO> selectAbnormalList(AbnormalQuery abnormal)
    {
        return abnormalMapper.selectAbnormalList(abnormal);
    }

    /**
     * 新增设备故障
     *
     * @param abnormal 设备故障
     * @return 结果
     */
    @Override
    public int insertAbnormal(Abnormal abnormal)
    {
        abnormal.setCreateTime(DateUtils.getNowDate());
        return abnormalMapper.insertAbnormal(abnormal);
    }

    /**
     * 修改设备故障
     *
     * @param abnormal 设备故障
     * @return 结果
     */
    @Override
    public int updateAbnormal(Abnormal abnormal)
    {
        abnormal.setUpdateTime(DateUtils.getNowDate());
        return abnormalMapper.updateAbnormal(abnormal);
    }

    /**
     * 批量删除设备故障
     *
     * @param abnormalIds 需要删除的设备故障主键
     * @return 结果
     */
    @Override
    public int deleteAbnormalByAbnormalIds(Long[] abnormalIds)
    {
        return abnormalMapper.deleteAbnormalByAbnormalIds(abnormalIds);
    }

    /**
     * 删除设备故障信息
     *
     * @param abnormalId 设备故障主键
     * @return 结果
     */
    @Override
    public int deleteAbnormalByAbnormalId(Long abnormalId)
    {
        return abnormalMapper.deleteAbnormalByAbnormalId(abnormalId);
    }

    @Override
    public int selectCount(AbnormalQuery query) {
        return abnormalMapper.selectCount(query);
    }
}
