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

import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.ss.deviceSuit.domain.DeviceSuit;
import com.ruoyi.ss.deviceSuit.domain.DeviceSuitQuery;
import com.ruoyi.ss.deviceSuit.domain.DeviceSuitVO;
import com.ruoyi.ss.deviceSuit.mapper.DeviceSuitMapper;
import com.ruoyi.ss.deviceSuit.service.DeviceSuitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 设备套餐关联Service业务层处理
 *
 * @author ruoyi
 * @date 2024-07-31
 */
@Service
public class DeviceSuitServiceImpl implements DeviceSuitService
{
    @Autowired
    private DeviceSuitMapper deviceSuitMapper;

    /**
     * 查询设备套餐关联
     *
     * @param id 设备套餐关联主键
     * @return 设备套餐关联
     */
    @Override
    public DeviceSuitVO selectDeviceSuitById(Long id)
    {
        return deviceSuitMapper.selectDeviceSuitById(id);
    }

    /**
     * 查询设备套餐关联列表
     *
     * @param deviceSuit 设备套餐关联
     * @return 设备套餐关联
     */
    @Override
    public List<DeviceSuitVO> selectDeviceSuitList(DeviceSuitQuery deviceSuit)
    {
        return deviceSuitMapper.selectDeviceSuitList(deviceSuit);
    }

    /**
     * 新增设备套餐关联
     *
     * @param deviceSuit 设备套餐关联
     * @return 结果
     */
    @Override
    public int insertDeviceSuit(DeviceSuit deviceSuit)
    {
        return deviceSuitMapper.insertDeviceSuit(deviceSuit);
    }

    /**
     * 修改设备套餐关联
     *
     * @param deviceSuit 设备套餐关联
     * @return 结果
     */
    @Override
    public int updateDeviceSuit(DeviceSuit deviceSuit)
    {
        return deviceSuitMapper.updateDeviceSuit(deviceSuit);
    }

    /**
     * 批量删除设备套餐关联
     *
     * @param ids 需要删除的设备套餐关联主键
     * @return 结果
     */
    @Override
    public int deleteDeviceSuitByIds(Long[] ids)
    {
        return deviceSuitMapper.deleteDeviceSuitByIds(ids);
    }

    /**
     * 删除设备套餐关联信息
     *
     * @param id 设备套餐关联主键
     * @return 结果
     */
    @Override
    public int deleteDeviceSuitById(Long id)
    {
        return deviceSuitMapper.deleteDeviceSuitById(id);
    }

    @Override
    public int batchInsert(List<DeviceSuit> list) {
        if (CollectionUtils.isEmptyElement(list)) {
            return 0;
        }
        return deviceSuitMapper.batchInsert(list);
    }

    @Override
    public int deleteBySuitId(Long suitId) {
        if (suitId == null) {
            return 0;
        }
        return this.deleteBySuitIds(Collections.singletonList(suitId));
    }

    @Override
    public int deleteBySuitIds(List<Long> suitIds) {
        if (CollectionUtils.isEmptyElement(suitIds)) {
            return 0;
        }
        return deviceSuitMapper.deleteBySuitIds(suitIds);
    }

    @Override
    public int deleteByDeviceId(Long deviceId) {
        if (deviceId == null) {
            return 0;
        }
        return this.deleteByDeviceIds(Collections.singletonList(deviceId));
    }

    @Override
    public int deleteByDeviceIds(List<Long> deviceIds) {
        if (CollectionUtils.isEmptyElement(deviceIds)) {
            return 0;
        }
        return deviceSuitMapper.deleteByDeviceIds(deviceIds);
    }
}
