2021与蓝度共同重构项目,服务端
liuhaonan
2022-07-06 c61daa1070487b6adeff3438633c10f750ac45ab
ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java
@@ -1,8 +1,11 @@
package com.sandu.ximon.admin.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.dao.domain.InterphoneHost;
import com.sandu.ximon.dao.domain.InterphoneHostSubPole;
import com.sandu.ximon.dao.mapper.InterphoneHostSubPoleMapper;
import lombok.AllArgsConstructor;
@@ -26,6 +29,11 @@
        }
        InterphoneHostSubPole pole = new InterphoneHostSubPole();
        InterphoneHost host = SpringContextHolder.getBean(InterphoneHostService.class).getById(hostId);
        InterphoneHost sub = SpringContextHolder.getBean(InterphoneHostService.class).getById(subId);
        if (host == null && sub == null) {
            throw new BusinessException("主设备或子设备不存在");
        }
        pole.setHostId(hostId);
        pole.setSubId(subId);
        return save(pole);
@@ -38,10 +46,11 @@
        if (subId == null) {
            throw new BusinessException("子设备id不能为空");
        }
        InterphoneHostSubPole one = getOne(Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getSubId, subId));
        LambdaQueryWrapper<InterphoneHostSubPole> eq = Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getSubId, subId);
        InterphoneHostSubPole one = getOne(eq);
        if (one == null) {
            throw new BusinessException("绑定关系不存在");
        }
        return removeById(one);
        return remove(eq);
    }
}