package com.sqx.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SnowFlakeConfig {
    /**
     * 数据中心
     */
    @Value("${snowflake.datacenterId}")
    private String datacenterId;
    /**
     * 机器标识
     */
    @Value("${snowflake.machineId}")
    private String machineId;

    @Bean(name = "snowFlake")
    public SnowFlake snowFlake() {
        return new SnowFlake(Long.parseLong(datacenterId), Long.parseLong(machineId));
    }
} 