From 93c7226d536d312fc083a57619629192ba076413 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期五, 01 十二月 2023 12:36:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/RoleController.java |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/RoleController.java b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/RoleController.java
index 1a40eb8..508ea8d 100644
--- a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/RoleController.java
+++ b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/RoleController.java
@@ -20,6 +20,7 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.vci.ubcs.system.cache.NacosConfigCache;
 import com.vci.ubcs.system.cache.SysCache;
 import com.vci.ubcs.system.entity.Role;
 import com.vci.ubcs.system.service.IRoleService;
@@ -45,6 +46,9 @@
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
 
 import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
 
@@ -62,6 +66,7 @@
 public class RoleController extends BladeController {
 
 	private final IRoleService roleService;
+	private final NacosConfigCache nacosConfigCache;
 
 	/**
 	 * 璇︽儏
@@ -87,7 +92,7 @@
 	public R<IPage<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser, Query query) {
 		QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class);
 		IPage<Role> page = roleService.page(Condition.getPage(query),
-			(!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper);
+			(!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper);
 		return R.data(RoleWrapper.build().pageNodeVO(page));
 	}
 
@@ -126,7 +131,6 @@
 		return R.status(roleService.submit(role));
 	}
 
-
 	/**
 	 * 鍒犻櫎
 	 */
@@ -148,7 +152,16 @@
 	public R grant(@RequestBody GrantVO grantVO) {
 		CacheUtil.clear(SYS_CACHE);
 		CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
-		boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
+		boolean temp = false;
+		try {
+			temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
+			// 鎻掑叆鎺堟潈鏃ュ織
+			roleService.grantLog(roleService.getGrantRoleResString(grantVO.getRoleIds()),false);
+		}catch (Exception e){
+			// 澶辫触鏃舵彃鍏ュ紓甯镐俊鎭埌鏃ュ織涓�
+			roleService.grantLog(e.getMessage(),true);
+			throw e;
+		}
 		return R.status(temp);
 	}
 

--
Gitblit v1.9.3