package com.casic.missiles.modular.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.casic.missiles.modular.system.model.DeviceConcentrator;
import com.casic.missiles.modular.system.dao.DeviceConcentratorMapper;
import com.casic.missiles.modular.system.service.IDeviceConcentratorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 设备集中器关联表 服务实现类
 * </p>
 *
 * @author lwh123
 * @since 2019-05-29
 */
@Service
public class DeviceConcentratorServiceImpl extends ServiceImpl<DeviceConcentratorMapper, DeviceConcentrator> implements IDeviceConcentratorService {


    @Override
    public void updateByDeviceId(Long deviceId, Long concId) {
        this.baseMapper.updateByDeviceId(deviceId, concId);
    }

    @Override
    public DeviceConcentrator getDeviceConcentratorBydevId(Long devId) {
        QueryWrapper<DeviceConcentrator> query = new QueryWrapper<DeviceConcentrator>();
        query.eq("DEVICE_ID", devId);
        query.eq("ACTIVE", 1);
        return this.baseMapper.selectOne(query);
    }

    @Override
    public void deleteByDeviceId(Long id) {
        QueryWrapper<DeviceConcentrator> del = new QueryWrapper<>();
        del.eq("DEVICE_ID", id);
        this.remove(del);
    }
}
