From d35545d88b9123b92b50aaf1b0fa4e3f20fd2209 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 20 五月 2022 11:23:50 +0800
Subject: [PATCH] 摄像头
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java | 78 ++++++++++++++++++++++++++++++++++----
1 files changed, 69 insertions(+), 9 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 104453e..8555241 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
@@ -6,21 +6,25 @@
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.param.AddClientPrarm;
import com.sandu.ximon.admin.param.PwdParam;
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.Client;
import com.sandu.ximon.dao.domain.ClientRoleRelation;
import com.sandu.ximon.dao.domain.Role;
+import com.sandu.ximon.dao.domain.RoleMenuRelation;
import com.sandu.ximon.dao.mapper.ClientMapper;
import lombok.AllArgsConstructor;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
@Service
@AllArgsConstructor
@@ -37,17 +41,17 @@
if (getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, addClientPrarm.getClientName().trim())) != null) {
throw new BusinessException("璇ョ敤鎴峰悕宸插瓨鍦紒");
}
-// Long userId = SecurityUtils.getUserId();
+ Long userId = SecurityUtils.getUserId();
boolean clientId = findClientId();
- //鍒ゆ柇鏄惁涓轰簩绾у鎴� 濡傛灉鏄簩绾у鎴峰垯涓嶈兘缁х画娣诲姞
- if (SecurityUtils.getClientId() != null && !clientId) {
+ //鍒ゆ柇鏄惁涓轰簩绾у鎴� 濡傛灉鏄簩绾у鎴峰垯涓嶈兘缁х画娣诲姞 涓�绾у鎴蜂负FALSE
+ if (SecurityUtils.getClientId() != null && clientId) {
throw new BusinessException("鏉冮檺涓嶈冻,浜岀骇瀹㈡埛涓嶈兘鏂板鐢ㄦ埛锛�");
}
Client client = new Client();
- if (SecurityUtils.getClientId() != null && clientId) {
+ if (SecurityUtils.getClientId() != null && !clientId) {
//涓�绾у鎴锋柊澧炵敤鎴锋椂 榛樿涓鸿嚜宸卞悕涓嬬殑浜岀骇瀹㈡埛
client.setSuperiorId(SecurityUtils.getUserId());
client.setClientSuperior(addClientPrarm.getClientSuperior());
@@ -92,6 +96,15 @@
throw new BusinessException("娣诲姞绠$悊鍛樿鑹插け璐�");
}
+ /**
+ * 娣诲姞鏅�氱敤鎴� 鏃ュ織璁板綍寮�濮�
+ */
+ String content = "鏂版敞鍐岀敤鎴凤細" + addClientPrarm.getClientName();
+ StoreOperationRecordsUtils.storeOperationData(null, null, "娣诲姞鏅�氱敤鎴�", content);
+ /**
+ * 娣诲姞鏅�氱敤鎴� 鏃ュ織璁板綍缁撴潫
+ */
+
return flag;
}
@@ -108,17 +121,19 @@
if (client1 != null && !client1.getId().equals(one.getId())) {
throw new BusinessException("璇ョ敤鎴峰悕宸插瓨鍦紒");
}
+
//鍒ゆ柇涓婄骇鐢ㄦ埛鏄惁瀛樺湪
boolean clientId = findClientId();
-
+ Long userId = SecurityUtils.getUserId();
//鍒ゆ柇鏇存敼鐨勭敤鎴锋槸鍚︽槸灞炰簬鑷繁鍚嶄笅鐨勪簩绾у鎴�
- if(SecurityUtils.getClientId() != null && clientId){
- if(!Objects.equals(one.getSuperiorId(), SecurityUtils.getUserId())){
+ if (SecurityUtils.getClientId() != null && !clientId) {
+ if (SecurityUtils.getUserId() != one.getSuperiorId()) {
throw new BusinessException("鏉冮檺涓嶈冻锛屼笉鑳芥洿鏀瑰叾浠栧鎴风殑鎵�灞炲鎴蜂俊鎭紒");
}
}
Client client = new Client();
+ client.setClientName(updateClientPrarm.getClientName());
if (SecurityUtils.getClientId() != null && clientId) {
//涓�绾у鎴锋柊澧炵敤鎴锋椂 榛樿涓鸿嚜宸卞悕涓嬬殑浜岀骇瀹㈡埛
client.setSuperiorId(SecurityUtils.getUserId());
@@ -142,7 +157,14 @@
client.setLinkMan(updateClientPrarm.getLinkMan());
client.setMobile(updateClientPrarm.getMobile());
- // update(client);
+ /**
+ * 缂栬緫鏅�氱敤鎴� 鏃ュ織璁板綍寮�濮�
+ */
+ String content = "缂栬緫鏅�氱敤鎴凤細" + client.getClientName() + "鐢ㄦ埛id锛�" + id;
+ StoreOperationRecordsUtils.storeOperationData(null, null, "缂栬緫鏅�氱敤鎴�", content);
+ /**
+ * 缂栬緫鏅�氱敤鎴� 鏃ュ織璁板綍缁撴潫
+ */
return updateById(client);
}
@@ -201,6 +223,14 @@
if (list != null && list.size() != 0) {
throw new BusinessException("鍒犻櫎鐨勭敤鎴蜂笅鏈変笅绾х敤鎴凤紝涓嶅厑璁稿垹闄�");
}
+ /**
+ * 鍒犻櫎鏅�氱敤鎴� 鏃ュ織璁板綍寮�濮�
+ */
+ String content = "鍒犻櫎鏅�氱敤鎴凤細" + one.getClientName() + "鐢ㄦ埛id锛�" + id;
+ StoreOperationRecordsUtils.storeOperationData(null, null, "鍒犻櫎鏅�氱敤鎴�", content);
+ /**
+ * 鍒犻櫎鏅�氱敤鎴� 鏃ュ織璁板綍缁撴潫
+ */
return removeById(id);
}
@@ -293,4 +323,34 @@
one.setIcon(IconUrl);
return updateById(one);
}
+
+ /**
+ * 鑾峰彇鐢ㄦ埛鏉冮檺鍒楄〃鍦�
+ */
+ public List<MenuNode> getUserPermissionList() {
+ //閫氳繃鐢ㄦ埛UserID鑾峰彇鐢ㄦ埛瑙掕壊
+ ClientRoleRelation one = SpringContextHolder.getBean(ClientRoleRelationService.class).
+ getOne(Wrappers.lambdaQuery(ClientRoleRelation.class).eq(ClientRoleRelation::getClientId, SecurityUtils.getUserId()));
+ //鍒ょ┖
+ if (one == null) {
+ throw new BusinessException("璇ョ敤鎴锋湭缁戝畾瑙掕壊");
+ }
+
+ //閫氳繃RoleID鑾峰彇MeunId鍒楄〃
+ List<RoleMenuRelation> menuIdList = SpringContextHolder.getBean(RoleMenuRelationService.class)
+ .list(Wrappers.lambdaQuery(RoleMenuRelation.class).eq(RoleMenuRelation::getRoleId, one.getRoleId()));
+
+ //鍒ょ┖
+ if (menuIdList.isEmpty()) {
+ return new ArrayList<>();
+ }
+
+ List<Long> menuIds = new ArrayList<>(menuIdList.size());
+ for (RoleMenuRelation bean : menuIdList) {
+ menuIds.add(bean.getMenuId());
+ }
+
+ List<MenuNode> resultList = SpringContextHolder.getBean(MenuService.class).getUserPermissionListById(menuIds);
+ return resultList;
+ }
}
--
Gitblit v1.9.3