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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.casic.missiles.modular.system.dao.DeviceWellMapper;
import com.casic.missiles.modular.system.model.DeviceWell;
import com.casic.missiles.modular.system.service.IDeviceWellService;
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) {
        QueryWrapper<DeviceWell> query = new QueryWrapper();
        query.eq("VALID", "1");
        query.eq("DEVICE_ID", devId);
        return this.baseMapper.selectOne(query);
    }

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

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