From dda268997ca8f8a364f7c19b45d7a43a50a98efe Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 25 十月 2022 18:00:11 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java
index 5b490f8..7069834 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java
@@ -5,8 +5,10 @@
 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;
@@ -23,17 +25,20 @@
         if (hostId == null || subId == null) {
             throw new BusinessException("涓昏澶噄d鎴栧瓙璁惧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);
@@ -46,6 +51,9 @@
         if (subId == null) {
             throw new BusinessException("瀛愯澶噄d涓嶈兘涓虹┖");
         }
+        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) {

--
Gitblit v1.9.3