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

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.casic.missiles.modular.system.dao.DeviceWellMapper;
import com.casic.missiles.modular.system.service.IDeviceWellService;
import com.casic.missiles.modular.system.model.DeviceWell;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 设备闸井关联表 服务实现类
 * </p>
 *
 * @author lwh123
 * @since 2019-05-29
 */
@Service
public class DeviceWellServiceImpl extends ServiceImpl<DeviceWellMapper, DeviceWell> implements IDeviceWellService {

    @Override
    public DeviceWell getDeviceWellByDevId(Long devId) {
        DeviceWell deviceWell = new DeviceWell();
        deviceWell.setDeviceId(devId);
        deviceWell.setValid("1");
        return this.baseMapper.selectOne(deviceWell);
    }

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

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