From 815c6be8d063ca1ec89079722d265585f7d3602c Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期五, 13 十月 2023 11:05:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/TenantServiceImpl.java |   43 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/TenantServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/TenantServiceImpl.java
index b4b22d4..3d041a6 100644
--- a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/TenantServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/TenantServiceImpl.java
@@ -16,10 +16,12 @@
  */
 package com.vci.ubcs.system.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.vci.ubcs.system.cache.NacosConfigCache;
 import com.vci.ubcs.system.entity.*;
 import com.vci.ubcs.system.mapper.TenantMapper;
 import com.vci.ubcs.system.service.*;
@@ -57,6 +59,11 @@
 @Service
 @RequiredArgsConstructor
 public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> implements ITenantService {
+
+	/**
+	 * nacos涓婇厤缃殑瓒呯绉熸埛
+	 */
+	private final NacosConfigCache nacosConfigCache;
 
 	private final TenantId tenantId;
 	private final IRoleService roleService;
@@ -187,7 +194,7 @@
 		List<String> tenantIds = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids))
 			.stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList());
 		CacheUtil.clear(SYS_CACHE, tenantIds);
-		if (tenantIds.contains(BladeConstant.ADMIN_TENANT_ID)) {
+		if (tenantIds.contains(nacosConfigCache.getAdminUserInfo().getTenantId())) {
 			throw new ServiceException("涓嶅彲鍒犻櫎绠$悊绉熸埛!");
 		}
 		boolean tenantTemp = this.deleteLogic(ids);
@@ -198,12 +205,42 @@
 		return tenantTemp;
 	}
 
+	/**
+	 * 鑾峰彇绉熸埛淇℃伅锛岄敭鍊煎褰㈠紡锛岀櫥褰曠晫闈㈣皟鐢�
+	 * @return
+	 */
 	@Override
 	public List<Map<String,Object>> selectMaps(){
-		List<Map<String, Object>> maps = listMaps(new QueryWrapper<Tenant>().select("TENANT_ID", "TENANT_NAME"));
-		return maps;
+		List<Map<String, Object>> mapList = listMaps(new QueryWrapper<Tenant>().select("TENANT_ID", "TENANT_NAME"));
+		if(Func.isNotEmpty(NacosConfigCache.getAdminUserInfo().getTenantId()) && !this.containsSameKeys(mapList,nacosConfigCache.getAdminUserInfo().getTenantId())){
+			Map<String, Object> map = new HashMap<>();
+			map.put("TENANT_ID",NacosConfigCache.getAdminUserInfo().getTenantId());
+			map.put("TENANT_NAME","绠$悊缁�");
+			mapList.add(0,map);
+		}
+		return mapList;
 	}
 
+	/**
+	 * 鍒ゆ柇鏁版嵁搴撲腑鏄惁瀛樺湪浜庨厤缃枃浠朵腑涓�鑷寸殑瓒呯淇℃伅
+	 * @param collection
+	 * @param value
+	 * @return
+	 */
+	private boolean containsSameKeys(List<Map<String, Object>> collection, String value) {
+		for (Map<String, Object> map : collection) {
+			Collection<Object> values = map.values();
+			if (values.contains(value)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * 涓夊憳鐩稿叧閰嶇疆
+	 * @return
+	 */
 	@Override
 	public boolean findIsOpen() {
 		return this.ssaEnable;

--
Gitblit v1.9.3