| | |
| | | if (hostId == null || subId == null) { |
| | | throw new BusinessException("主设备id或子设备id不能为空"); |
| | | } |
| | | 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("主设备或子设备不存在"); |
| | | } |
| | | InterphoneHostSubPole one = getOne(Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getSubId, subId)); |
| | | if (one != null) { |
| | | throw new BusinessException("子设备已绑定"); |
| | | } |
| | | |
| | | 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); |