| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.InterphoneHost; |
| | | import com.sandu.ximon.dao.domain.InterphoneHostSubPole; |
| | | import com.sandu.ximon.dao.domain.InterphoneSub; |
| | | import com.sandu.ximon.dao.mapper.InterphoneHostSubPoleMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | if (hostId == null || subId == null) { |
| | | throw new BusinessException("主设备id或子设备id不能为空"); |
| | | } |
| | | if (SecurityUtils.getClientId() != null) { |
| | | throw new BusinessException("只有管理员才能进行此操作"); |
| | | } |
| | | InterphoneHostSubPole pole = new InterphoneHostSubPole(); |
| | | InterphoneHost host = SpringContextHolder.getBean(InterphoneHostService.class).getById(hostId); |
| | | InterphoneSub sub = SpringContextHolder.getBean(InterphoneSubService.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); |
| | |
| | | if (subId == null) { |
| | | throw new BusinessException("子设备id不能为空"); |
| | | } |
| | | if (SecurityUtils.getClientId() != null) { |
| | | throw new BusinessException("只有管理员才能进行此操作"); |
| | | } |
| | | LambdaQueryWrapper<InterphoneHostSubPole> eq = Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getSubId, subId); |
| | | InterphoneHostSubPole one = getOne(eq); |
| | | if (one == null) { |