package com.cpop.core.config;

import com.cpop.core.service.ConfigService;
import com.cpop.core.strategy.dataSourceSharding.CpopDataSourceShardingStrategy;
import com.cpop.core.utils.SpringUtils;
import com.mybatisflex.core.datasource.DataSourceManager;
import jakarta.annotation.PostConstruct;
import org.springframework.context.annotation.Configuration;

/**
 * 核心初始化文件
 * @author DB
 * @version 1.0.0
 * @since 2024-02-05 9:39
 */
@Configuration
public class CoreInitConfig {

    /**
     * 初始化
     */
    @PostConstruct
    public void init() {
        //设置数据源分片策略
        DataSourceManager.setDataSourceShardingStrategy(new CpopDataSourceShardingStrategy());
        //初始化系统配置信息
        SpringUtils.getBean(ConfigService.class).loadingConfigCache();
    }
}
