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

import com.baomidou.mybatisplus.mapper.EntityWrapper;
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.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) {
        DeviceConcentrator deviceConcentrator = new DeviceConcentrator();
        deviceConcentrator.setDeviceId(devId);
        deviceConcentrator.setActive(1);
        return this.baseMapper.selectOne(deviceConcentrator);
    }

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