|  | @@ -1,5 +1,6 @@
 | 
	
		
			
				|  |  |  package cn.newfeifan.mall.module.system.service.config;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import cn.newfeifan.mall.module.system.config.StartConfig;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.system.controller.admin.config.bo.SystemConfigBO;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import org.springframework.data.redis.core.StringRedisTemplate;
 | 
	
	
		
			
				|  | @@ -17,6 +18,7 @@ import cn.newfeifan.mall.module.system.dal.mysql.config.SystemConfigMapper;
 | 
	
		
			
				|  |  |  import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
	
		
			
				|  |  |  import static cn.newfeifan.mall.module.system.constant.SystemConstants.SYSTEM_CONFIG;
 | 
	
		
			
				|  |  |  import static cn.newfeifan.mall.module.system.enums.ErrorCodeConstants.*;
 | 
	
		
			
				|  |  | +import static cn.newfeifan.mall.module.system.enums.ErrorCodeConstants.CONFIG_REDIS_NOT_EXISTS;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 系统配置 Service 实现类
 | 
	
	
		
			
				|  | @@ -31,6 +33,9 @@ public class SystemConfigServiceImpl implements SystemConfigService {
 | 
	
		
			
				|  |  |      private SystemConfigMapper systemConfigMapper;
 | 
	
		
			
				|  |  |      @Resource
 | 
	
		
			
				|  |  |      private StringRedisTemplate stringRedisTemplate;
 | 
	
		
			
				|  |  | +    @Resource
 | 
	
		
			
				|  |  | +    private StartConfig startConfig;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Long createConfig(ConfigSaveReqVO createReqVO) {
 | 
	
	
		
			
				|  | @@ -77,16 +82,25 @@ public class SystemConfigServiceImpl implements SystemConfigService {
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public SystemConfigDO getRedisConfig() {
 | 
	
		
			
				|  |  |          String s = stringRedisTemplate.opsForValue().get(SYSTEM_CONFIG);
 | 
	
		
			
				|  |  | -        if (s != null) {
 | 
	
		
			
				|  |  | -            SystemConfigBO systemConfigBO = JSONObject.parseObject(s, SystemConfigBO.class);
 | 
	
		
			
				|  |  | -            return SystemConfigDO.builder()
 | 
	
		
			
				|  |  | -                    .id(systemConfigBO.getId())
 | 
	
		
			
				|  |  | -                    .mallDomain(systemConfigBO.getMallDomain())
 | 
	
		
			
				|  |  | -                    .merchantDomain(systemConfigBO.getMerchantDomain())
 | 
	
		
			
				|  |  | -                    .platformDomain(systemConfigBO.getPlatformDomain())
 | 
	
		
			
				|  |  | -                    .build();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 第一次判断是因为redis配置了自动删除
 | 
	
		
			
				|  |  | +        if (s == null) {
 | 
	
		
			
				|  |  | +            startConfig.initSystemConfig();
 | 
	
		
			
				|  |  | +            s = stringRedisTemplate.opsForValue().get(SYSTEM_CONFIG);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        return getConfig();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 第二次判断如果还是为空,那就缓存到redis的程序写错了
 | 
	
		
			
				|  |  | +        if(s == null){
 | 
	
		
			
				|  |  | +            throw exception(CONFIG_REDIS_NOT_EXISTS);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        SystemConfigBO systemConfigBO = JSONObject.parseObject(s, SystemConfigBO.class);
 | 
	
		
			
				|  |  | +        return SystemConfigDO.builder()
 | 
	
		
			
				|  |  | +                .id(systemConfigBO.getId())
 | 
	
		
			
				|  |  | +                .mallDomain(systemConfigBO.getMallDomain())
 | 
	
		
			
				|  |  | +                .merchantDomain(systemConfigBO.getMerchantDomain())
 | 
	
		
			
				|  |  | +                .platformDomain(systemConfigBO.getPlatformDomain())
 | 
	
		
			
				|  |  | +                .build();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 |