Source/UBCS-WEB/src/views/authority/role.vue
@@ -27,10 +27,10 @@ plain @click="handleDelete">删 除 </el-button> <!-- v-if="userInfo.role_name.includes('admin')" --> <el-button size="small" icon="el-icon-setting" @click="handleRole" v-if="userInfo.role_name.includes('admin')" plain>权限设置 </el-button> </template> Source/UBCS/ubcs-auth/src/main/java/com/vci/ubcs/auth/utils/TokenUtil.java
@@ -87,8 +87,6 @@ public final static String REFRESH_TOKEN_KEY = "refresh_token"; private static BladeTenantProperties tenantProperties; @Autowired private static NacosConfigCache nacosConfigCache; /** * 获取租户配置 @@ -172,7 +170,7 @@ if (tenant == null || tenant.getId() == null) { throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT); } if (StringUtil.equalsIgnoreCase(tenant.getTenantId(), nacosConfigCache.getAdminUserInfo().getTenantId())) { if (StringUtil.equalsIgnoreCase(tenant.getTenantId(), NacosConfigCache.getAdminUserInfo().getTenantId())) { return false; } if (getTenantProperties().getLicense()) { Source/UBCS/ubcs-service-api/ubcs-system-api/src/main/java/com/vci/ubcs/system/cache/NacosConfigCache.java
@@ -1,5 +1,8 @@ package com.vci.ubcs.system.cache; import com.alibaba.nacos.api.config.ConfigFactory; import com.alibaba.nacos.api.config.ConfigService; import com.alibaba.nacos.api.exception.NacosException; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.cache.utils.CacheUtil; import org.springblade.core.secure.BladeUser; @@ -10,6 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; import java.util.Map; /** * redis中存储的nacos上配置的超管配置信息 @@ -26,21 +32,51 @@ @Autowired private Environment environment; private static ConfigService configService; private static final String SERVER_ADDR = "localhost:8848"; private static final String GROUP_ID = "DEFAULT_GROUP"; private static final String DATA_ID = "ubcs.yaml"; static { try { configService = ConfigFactory.createConfigService(SERVER_ADDR); } catch (NacosException e) { e.printStackTrace(); } } /** * 静态方法中获取配置 * @return */ public static Map<String, Map<String,String>> getConfig() { try { String config = configService.getConfig(DATA_ID, GROUP_ID, 5000); Yaml yaml = new Yaml(); return yaml.load(config); } catch (NacosException e) { e.printStackTrace(); return null; } } /** * 获取存入redis中 * nacos上配置的超管信息 * @return */ public BladeUser getAdminUserInfo() { public static BladeUser getAdminUserInfo() { try { BladeUser user = CacheUtil.getCache(NACOS_CONFIG_CACHE).get(ADMIN_INFO_CODE,BladeUser.class); String tenantId = environment.getProperty("user-info.tenant-id", "000000"); Map<String, Map<String,String>> configMap = getConfig(); String tenantId = configMap.get("user-info").get("tenant-id"); //从缓存中未获取到超级管理员配置信息或者和nacos上配置的租户不一致,从nacos上重新获取并存入缓存。 if(Func.isEmpty(user) || !user.getTenantId().equals(tenantId)){ BladeUser adminUser = new BladeUser(); adminUser.setTenantId(tenantId); adminUser.setUserName(environment.getProperty("user-info.user-name","admin")); adminUser.setUserId(Func.toLong(environment.getProperty("user-info.id","0"))); adminUser.setUserName(configMap.get("user-info").get("user-name")); adminUser.setUserId(Func.toLong(configMap.get("user-info").get("id"))); CacheUtil.getCache(NACOS_CONFIG_CACHE).put(ADMIN_INFO_CODE,adminUser); return adminUser; } Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
@@ -85,9 +85,6 @@ @Resource private IBtmTypeClient btmTypeClient; @Resource private NacosConfigCache nacosConfigCache; /** * 日志 */ @@ -129,7 +126,7 @@ public IPage<CodeClassifyVO> selectPlCodeClassifyPage(IPage<CodeClassifyVO> page, CodeClassifyVO plCodeClassify) { return page.setRecords(codeClassifyMapper.selectPlCodeClassifyPage(page, plCodeClassify,AuthUtil.getTenantId() .equals( nacosConfigCache NacosConfigCache .getAdminUserInfo() .getTenantId() ) ? null:AuthUtil.getTenantId())); @@ -526,14 +523,14 @@ doList = codeClassifyMapper .selectCodeClassifyDOByTree(treeQueryObject.getConditionMap().get("id"),treeQueryObject.getConditionMap().get("lcStatus"),treeQueryObject.getParentOid(), AuthUtil.getTenantId() .equals( nacosConfigCache NacosConfigCache .getAdminUserInfo() .getTenantId() ) ? null:AuthUtil.getTenantId()); }else{ doList =codeClassifyMapper.selectCodeClassifyVOByTree(treeQueryObject.getParentOid(), AuthUtil.getTenantId() .equals( nacosConfigCache NacosConfigCache .getAdminUserInfo() .getTenantId() ) ? null:AuthUtil.getTenantId()); @@ -597,7 +594,7 @@ } List<CodeClassify> doList =codeClassifyMapper.getRMLibByName(libNameList,"Enabled",AuthUtil.getTenantId() .equals( nacosConfigCache NacosConfigCache .getAdminUserInfo() .getTenantId() ) ? null:AuthUtil.getTenantId()); Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeReferConfigServiceImpl.java
@@ -56,9 +56,6 @@ @Resource private ICodeSrchCondConfigService ICodeSrchCondConfigService; @Resource private NacosConfigCache nacosConfigCache; /** * 通过ID查询单条数据 * @@ -83,7 +80,7 @@ // 根据租户进行区分对应的参照配置 Map<String, Object> conditionMap = bladeQueryObject.getConditionMap(); // 查询所属租户下的和开启全局的参照配置信息 if(!nacosConfigCache.getAdminUserInfo().getTenantId().equals(AuthUtil.getTenantId())){ if(!NacosConfigCache.getAdminUserInfo().getTenantId().equals(AuthUtil.getTenantId())){ conditionMap.put("tenantId",AuthUtil.getTenantId()); } conditionMap.put("isOpenGlobal","true"); Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java
@@ -114,9 +114,6 @@ private RevisionModelUtil revisionModelUtil; @Resource private NacosConfigCache nacosConfigCache; @Resource private ICodeFixedValueService codeFixedValueService; /** @@ -128,8 +125,8 @@ @Override public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) throws VciBaseException { //如果等于自己配置的管理组租户id和管理组超管账号,就不需要按照规则所有者来进行查询 if(!(AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) && AuthUtil.getUserId().toString().equals(nacosConfigCache.getAdminUserInfo().getUserId().toString())) if(!(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId()) && AuthUtil.getUserId().toString().equals(NacosConfigCache.getAdminUserInfo().getUserId().toString())) ){ // 按照规则所有者来查询 conidtionMap.put("owner",AuthUtil.getUserId()); @@ -170,7 +167,7 @@ public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO)throws VciBaseException { LambdaQueryWrapper<CodeRule> wrapper = Wrappers.<CodeRule>query() .lambda().eq(CodeRule::getId, codeRuleDTO.getId()); if(AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())){ if(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId())){ wrapper.eq(CodeRule::getTenantId,AuthUtil.getTenantId()); } // 根据规则id查询编号 Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/StrategyServiceImpl.java
@@ -43,12 +43,6 @@ private IUserClient userClient; /** * nacos上拉取的配置 */ @Resource private NacosConfigCache nacosConfigCache; /** * 通过ID查询单条数据 * * @param id 主键 @@ -67,7 +61,7 @@ public Strategy queryByIsDefault() { return this.strategyMapper.queryByIsDefault(AuthUtil.getTenantId() .equals( nacosConfigCache NacosConfigCache .getAdminUserInfo() .getTenantId() ) ? null:AuthUtil.getTenantId() @@ -88,7 +82,7 @@ strategyPage, AuthUtil.getTenantId() .equals( nacosConfigCache NacosConfigCache .getAdminUserInfo() .getTenantId() ) Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/TenantServiceImpl.java
@@ -212,9 +212,9 @@ @Override public List<Map<String,Object>> selectMaps(){ 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())){ 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_ID",NacosConfigCache.getAdminUserInfo().getTenantId()); map.put("TENANT_NAME","管理组"); mapList.add(0,map); }