package com.mx.cneeds.server.device.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mx.cneeds.server.dao.DeviceInfoChannelDao;
import com.mx.cneeds.server.device.service.DeviceInfoChannelService;
import com.mx.cneeds.server.entity.DeviceInfoChannelEntity;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("deviceInfoChannelService")
public class DeviceInfoChannelServiceImpl extends ServiceImpl<DeviceInfoChannelDao, DeviceInfoChannelEntity> implements DeviceInfoChannelService {


    @Override
    public List<DeviceInfoChannelEntity> queryDeviceInfoChannelByDeviceId(Long deviceId){
        List<DeviceInfoChannelEntity> entities = getBaseMapper().
                selectList(new QueryWrapper<DeviceInfoChannelEntity>().
                        eq("device_id", deviceId));
        return entities;
    }

    @Override
    public List<DeviceInfoChannelEntity> queryDeviceInfoChannelByChannelId(Long channelId){
        List<DeviceInfoChannelEntity> entities = getBaseMapper().
                selectList(new QueryWrapper<DeviceInfoChannelEntity>().
                        eq("channel_id", channelId));
        return entities;
    }


    @Override
    public void removeDeivceInfoChannelByChannelId(List<Long> channelIds){
        getBaseMapper().delete(
                new QueryWrapper<DeviceInfoChannelEntity>()
                .in("channel_id",channelIds));
    }

    @Override
    public void removeDeivceInfoChannelByDeviceIdAndChannelId(Long channelId, List<Long> deviceIds){
        getBaseMapper().delete(
                new QueryWrapper<DeviceInfoChannelEntity>()
                        .eq("channel_id",channelId)
                        .in("device_id",deviceIds));
    }

    @Override
    public void removeDeivceInfoChannelByDeviceIds(List<Long> deviceIds){
        getBaseMapper().delete(
                new QueryWrapper<DeviceInfoChannelEntity>()
                        .in("device_id",deviceIds));
    }

    @Override
    public List<DeviceInfoChannelEntity> queryDeviceInfoChannelByChannelIds(List<Long> channelIds){
        List<DeviceInfoChannelEntity> deviceInfoChannelEntities = getBaseMapper().selectList(new QueryWrapper<DeviceInfoChannelEntity>()
                .in("channel_id", channelIds));
        return deviceInfoChannelEntities;
    }

    @Override
    public List<DeviceInfoChannelEntity> queryDeviceInfoChannelByDeviceIds(List<Long> deviceIds){
        List<DeviceInfoChannelEntity> deviceInfoChannelEntities = getBaseMapper().selectList(new QueryWrapper<DeviceInfoChannelEntity>()
                .in("device_id", deviceIds));
        return deviceInfoChannelEntities;
    }

}
