From d9a9d8a2dad1d1e57b184bf8f972a03d654d883a Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 22 七月 2022 15:07:01 +0800
Subject: [PATCH] 优化
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostSubService.java | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 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 3ba03ba..2700e4d 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
@@ -1,8 +1,12 @@
package com.sandu.ximon.admin.service;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.mapper.InterphoneHostSubPoleMapper;
import lombok.AllArgsConstructor;
@@ -20,12 +24,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);
+ 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();
pole.setHostId(hostId);
pole.setSubId(subId);
return save(pole);
@@ -38,10 +50,14 @@
if (subId == null) {
throw new BusinessException("瀛愯澶噄d涓嶈兘涓虹┖");
}
- InterphoneHostSubPole one = getOne(Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getSubId, subId));
+ 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) {
throw new BusinessException("缁戝畾鍏崇郴涓嶅瓨鍦�");
}
- return removeById(one);
+ return remove(eq);
}
}
--
Gitblit v1.9.3