| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | 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); |
| | | } |
| | | } |