xiejun
2023-10-11 c784a40346a05f893c59589e92dee60ba431f991
Source/UBCS/ubcs-service-api/ubcs-system-api/src/main/java/com/vci/ubcs/system/cache/NacosConfigCache.java
@@ -1,19 +1,15 @@
package com.vci.ubcs.system.cache;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
 * redis中存储的nacos上配置的超管配置信息
@@ -38,10 +34,11 @@
   public BladeUser getAdminUserInfo() {
      try {
         BladeUser user = CacheUtil.getCache(NACOS_CONFIG_CACHE).get(ADMIN_INFO_CODE,BladeUser.class);
         //从缓存中未获取到超级管理员配置信息,从nacos上重新获取并存入缓存。
         if(Func.isEmpty(user)){
         String tenantId = environment.getProperty("user-info.tenant-id", "000000");
         //从缓存中未获取到超级管理员配置信息或者和nacos上配置的租户不一致,从nacos上重新获取并存入缓存。
         if(Func.isEmpty(user) || !user.getTenantId().equals(tenantId)){
            BladeUser adminUser = new BladeUser();
            adminUser.setTenantId(environment.getProperty("user-info.tenant-id", "000000"));
            adminUser.setTenantId(tenantId);
            adminUser.setUserName(environment.getProperty("user-info.user-name","admin"));
            adminUser.setUserId(Func.toLong(environment.getProperty("user-info.id","0")));
            CacheUtil.getCache(NACOS_CONFIG_CACHE).put(ADMIN_INFO_CODE,adminUser);