From 13df4af0cb954740fd23c4bc0553f731161d15fc Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期四, 07 七月 2022 16:17:49 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java | 31 +++++++++++++++++++++++--------
1 files changed, 23 insertions(+), 8 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..2b2d128 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
@@ -12,11 +12,13 @@
import com.sandu.ximon.dao.bo.InterphoneHostBo;
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.enums.PoleBindingEnums;
import com.sandu.ximon.dao.mapper.InterphoneHostMapper;
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 +36,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,16 +62,19 @@
/**
* 淇敼涓绘満
*/
+ @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);
BeanUtils.copyProperties(interphoneHostParam, interphoneHost);
@@ -82,7 +91,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 +108,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