From f214709cf1d896e7c9743f206b7a708f020e5322 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 21 十月 2022 17:54:03 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java
index 07c40e7..8d6d8b7 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java
@@ -3,10 +3,8 @@
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.PageHelper;
import com.sandu.common.enums.RoleLevelStatus;
import com.sandu.common.execption.BusinessException;
-import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.redis.RedisService;
import com.sandu.common.security.LoginUserInfo;
import com.sandu.common.security.token.TokenProvider;
@@ -32,7 +30,6 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.RequestParam;
import java.util.ArrayList;
import java.util.Collection;
@@ -52,7 +49,11 @@
public boolean addClient(AddClientPrarm addClientPrarm) {
if (getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, addClientPrarm.getClientName().trim())) != null) {
- throw new BusinessException("璇ョ敤鎴峰悕宸插瓨鍦紒");
+ throw new BusinessException("璇ョ敤鎴峰悕宸插湪瀹㈡埛涓瓨鍦紒");
+ }
+ Admin admin = SpringContextHolder.getBean(AdminService.class).findByUserName(addClientPrarm.getClientName());
+ if (admin != null) {
+ throw new BusinessException("褰撳墠璐﹀彿" + addClientPrarm.getClientName() + "宸茬粡鍦ㄧ鐞嗗憳涓瓨鍦�");
}
Long userId = SecurityUtils.getUserId();
boolean clientId = findClientId();
@@ -256,6 +257,27 @@
if (removeById(id)) {
//鍒犺鑹插叧绯昏〃淇℃伅
flag = clientRoleRelationService.removeById(one);
+ List<Pole> poles = SpringContextHolder.getBean(PoleService.class).list(Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, id));
+ poles.forEach(
+ pole -> {
+ pole.setClientId(-1L);
+ pole.setUserId(-1L);
+ }
+ );
+
+ //鍒犻櫎鐢ㄦ埛鍚庨渶瑕佽嚜鍔ㄨВ缁戣鐢ㄦ埛鐨勮澶�
+
+ //鐏潌id闆嗗悎
+ List<Long> collect = poles.stream().map(p -> p.getId()).collect(Collectors.toList());
+ List<Long> collect1 = poles.stream().map(Pole::getId).collect(Collectors.toList());
+ //鍒犻櫎缁戝畾鍏崇郴
+ SpringContextHolder.getBean(PoleBindingService.class)
+ .remove(Wrappers.lambdaQuery(PoleBinding.class)
+ .in(PoleBinding::getPoleId, collect));
+ //鏇存敼鐏潌褰掑睘
+ flag = SpringContextHolder.getBean(PoleService.class).updateBatchById(poles);
+
+
//鍒犻櫎澶辫触鍥炴粴鏁版嵁
if (!flag) {
throw new BusinessException("鍒犻櫎鐢ㄦ埛澶辫触锛�");
@@ -388,7 +410,7 @@
/**
* \
- * 鍏朵粬绫荤敤鏉ユ煡鎵惧鎴穒d浣跨敤 濡傛灉娌℃湁涓婄骇瀹㈡埛 杩欒繑鍥炵敤鎴稩D
+ * 鍏朵粬绫荤敤鏉ユ煡鎵惧鎴穒d浣跨敤 濡傛灉娌℃湁涓婄骇瀹㈡埛 杩斿洖-1
*
* @param
* @return
@@ -398,7 +420,7 @@
if (one != null && one.getSuperiorId() != null) {
return one.getSuperiorId();
} else {
- return userId;
+ return -1L;
}
}
--
Gitblit v1.9.3