From 72046386cf8a85ad7dae79d82485fa60c2c421e6 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期二, 05 七月 2022 18:25:12 +0800
Subject: [PATCH] fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java | 67 +++++++++++++++++++++++++++++----
1 files changed, 59 insertions(+), 8 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 7a4c25d..3e9aecd 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
@@ -12,18 +12,18 @@
import com.sandu.ximon.admin.param.UpdateClientPrarm;
import com.sandu.ximon.admin.param.UserPwsParm;
import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.dao.bo.MenuNode;
import com.sandu.ximon.dao.domain.*;
-import com.sandu.ximon.dao.mapper.AdminMapper;
+import com.sandu.ximon.dao.enums.AdministratorEnums;
import com.sandu.ximon.dao.mapper.ClientMapper;
import lombok.AllArgsConstructor;
-import org.springframework.beans.BeanUtils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Collectors;
@Service
@AllArgsConstructor
@@ -73,8 +73,8 @@
if (role == null) {
throw new BusinessException("瑙掕壊涓嶅瓨鍦�");
}
- if (!RoleLevelStatus.NORMAL.getCode().equals(role.getLevel())) {
- throw new BusinessException("鏃犳硶娣诲姞瓒呯骇绠$悊鍛樻垨鐢ㄦ埛绠$悊鍛�");
+ if (RoleLevelStatus.SUPER.getCode().equals(role.getLevel())) {
+ throw new BusinessException("鏃犳硶娣诲姞瓒呯骇绠$悊鍛�");
}
@@ -94,6 +94,15 @@
if (!clientRoleRelationService.save(clientRoleRelation)) {
throw new BusinessException("娣诲姞绠$悊鍛樿鑹插け璐�");
}
+
+ /**
+ * 娣诲姞鏅�氱敤鎴� 鏃ュ織璁板綍寮�濮�
+ */
+ String content = "鏂版敞鍐岀敤鎴凤細" + addClientPrarm.getClientName();
+ StoreOperationRecordsUtils.storeOperationData(null, null, "娣诲姞鏅�氱敤鎴�", content);
+ /**
+ * 娣诲姞鏅�氱敤鎴� 鏃ュ織璁板綍缁撴潫
+ */
return flag;
}
@@ -147,6 +156,14 @@
client.setLinkMan(updateClientPrarm.getLinkMan());
client.setMobile(updateClientPrarm.getMobile());
+ /**
+ * 缂栬緫鏅�氱敤鎴� 鏃ュ織璁板綍寮�濮�
+ */
+ String content = "缂栬緫鏅�氱敤鎴凤細" + client.getClientName() + "鐢ㄦ埛id锛�" + id;
+ StoreOperationRecordsUtils.storeOperationData(null, null, "缂栬緫鏅�氱敤鎴�", content);
+ /**
+ * 缂栬緫鏅�氱敤鎴� 鏃ュ織璁板綍缁撴潫
+ */
return updateById(client);
}
@@ -192,11 +209,21 @@
return updateById(client);
}
+ @Transactional(rollbackFor = Exception.class)
public boolean deleteClient(Long id) {
+ boolean flag = false;
//鍒ゆ柇鍒犻櫎鐢ㄦ埛鏄惁瀛樺湪
- Client one = getById(id);
- if (one == null) {
+ Client client = getById(id);
+ if (client == null) {
throw new BusinessException("璇ュ鎴蜂笉瀛樺湪");
+ }
+
+ //鍙湁瓒呯鑳藉垹闄� 鎴� 涓婄骇瀹㈡埛鍒犻櫎鑷繁鐨勪笅绾х敤鎴�
+ if (!AdministratorEnums.ADMIN.getCode().equals(SecurityUtils.getUserDetails().getAdministratorType())) {
+ Client temp = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getSuperiorId, SecurityUtils.getUserId()).eq(Client::getId, id));
+ if (temp == null) {
+ throw new BusinessException("鍒犻櫎鐨勭敤鎴蜂笉瀛樺湪鎴栬鐢ㄦ埛涓嶆槸浣犵殑涓嬬骇鐢ㄦ埛");
+ }
}
//鍒ゆ柇鍒犻櫎鐨勭敤鎴锋湁鏃犱笅绾х敤鎴�
@@ -206,7 +233,31 @@
throw new BusinessException("鍒犻櫎鐨勭敤鎴蜂笅鏈変笅绾х敤鎴凤紝涓嶅厑璁稿垹闄�");
}
- return removeById(id);
+ //绠$悊鍛樿鑹插叧绯昏〃
+ ClientRoleRelationService clientRoleRelationService = SpringContextHolder.getBean(ClientRoleRelationService.class);
+ //鏈夌敤鎴峰繀瀹氭湁鐢ㄦ埛涓庤鑹茬殑鍏崇郴鏁版嵁
+ ClientRoleRelation one = clientRoleRelationService.getOne(Wrappers.lambdaQuery(ClientRoleRelation.class).eq(ClientRoleRelation::getClientId, client.getId()));
+
+ //鍒犵敤鎴�
+ if (removeById(id)) {
+ //鍒犺鑹插叧绯昏〃淇℃伅
+ flag = clientRoleRelationService.removeById(one);
+ //鍒犻櫎澶辫触鍥炴粴鏁版嵁
+ if (!flag) {
+ throw new BusinessException("鍒犻櫎鐢ㄦ埛澶辫触锛�");
+ }
+ }
+
+ /**
+ * 鍒犻櫎鏅�氱敤鎴� 鏃ュ織璁板綍寮�濮�
+ */
+ String content = "鍒犻櫎鏅�氱敤鎴凤細" + client.getClientName() + "鐢ㄦ埛id锛�" + id;
+ StoreOperationRecordsUtils.storeOperationData(null, null, "鍒犻櫎鏅�氱敤鎴�", content);
+ /**
+ * 鍒犻櫎鏅�氱敤鎴� 鏃ュ織璁板綍缁撴潫
+ */
+
+ return flag;
}
public List<Client> clientList(Long userId, BaseConditionVO baseConditionVO) {
--
Gitblit v1.9.3