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/InterphoneHostService.java | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
index c564bcc..b0fc52b 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
@@ -17,6 +17,7 @@
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@@ -34,6 +35,10 @@
* 娣诲姞涓绘満
*/
public boolean addHost(InterphoneHostParam interphoneHostParam) {
+ List<InterphoneHost> list = list(Wrappers.lambdaQuery(InterphoneHost.class).eq(InterphoneHost::getHostMac, interphoneHostParam.getHostMac()));
+ if (list.size() > 0) {
+ throw new BusinessException("璇ヨ澶囧凡瀛樺湪");
+ }
InterphoneHost interphoneHost = new InterphoneHost();
BeanUtils.copyProperties(interphoneHostParam, interphoneHost);
boolean save = save(interphoneHost);
@@ -56,15 +61,18 @@
/**
* 淇敼涓绘満
*/
+ @Transactional(rollbackFor = Exception.class)
public boolean updateHost(Integer id, InterphoneHostParam interphoneHostParam) {
InterphoneHost byId = getById(id);
if (byId == null) {
return false;
}
- boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getHostMac(), PoleBindingEnums.FOR_HELP);
- if (!belong) {
- throw new BusinessException("璇ヨ澶囦笉灞炰簬鎮�,涓嶈兘淇敼璁惧淇℃伅");
+ if (SecurityUtils.getClientId() != null) {
+ boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getHostMac(), PoleBindingEnums.FOR_HELP);
+ if (!belong) {
+ throw new BusinessException("璇ヨ澶囦笉灞炰簬鎮�,涓嶈兘淇敼璁惧淇℃伅");
+ }
}
InterphoneHost interphoneHost = new InterphoneHost();
interphoneHost.setHostId(id);
@@ -82,7 +90,12 @@
/**
* 缂栬緫涓�閿眰鍔╀富鏈� 鏃ュ織璁板綍缁撴潫
*/
- return updateById(interphoneHost);
+ boolean b = updateById(interphoneHost);
+ List<InterphoneHost> list = list(Wrappers.lambdaQuery(InterphoneHost.class).eq(InterphoneHost::getHostMac, interphoneHostParam.getHostMac()));
+ if (list.size() > 1) {
+ throw new BusinessException("璇锋鏌ヨ澶噈ac鏄惁閲嶅");
+ }
+ return b;
}
/**
@@ -94,12 +107,13 @@
public boolean deleteHost(Integer id) {
InterphoneHost byId = getById(id);
+ if (byId == null) {
+ throw new BusinessException("涓绘満涓嶅瓨鍦紒");
+ }
+
InterphoneHostSubPole one = interphoneHostSubService.getOne(Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getHostId, id));
if (one != null) {
throw new BusinessException("璇ヤ富鏈哄瓨鍦ㄧ粦瀹氬叧绯伙紝涓嶈兘鍒犻櫎");
- }
- if (byId == null) {
- return false;
}
/**
--
Gitblit v1.9.3