/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2021 . All rights reserved.
 *
 */
package net.northking.cctp.saas.config;

import net.northking.cctp.common.saas.cache.SaaSAppDataSourceClusterCache;
import net.northking.cctp.common.saas.cache.SaaSAppDataSourceClusterRedisRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * SaaS配置
 *
 * @author : xiusong.xie
 * @version : 1.0
 */
@Configuration
public class SaaSConfiguration
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(SaaSConfiguration.class);

  /**
   * SaaS应用数据源集群缓存
   *
   * @return SaaS应用数据源集群缓存
   */
  @Bean
  public SaaSAppDataSourceClusterCache tenantAppDataSourceClusterCache(RedisTemplate<String, Object> redisTemplate)
  {
    logger.info("注册公共组件提示： SaaS模式 => SaaS应用数据源集群缓存(SaaSAppDataSourceClusterCache) 已完成。");
    return new SaaSAppDataSourceClusterRedisRepository(redisTemplate);
  }
}
