package com.prolog.upcloud.base.wh.operate.config;

import com.prolog.framework.utils.SnowFlakeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 应用启动后执行
 *
 * @author wujunjie
 */
@Component
public class PrologApplicationRunner implements ApplicationRunner {

    private final static Logger log = LoggerFactory.getLogger(PrologApplicationRunner.class);

    @Value("${prolog.dao.keyGenerator.snowFlake.dataCenterId:1}")
    private long dataCenterId;

    @Value("${prolog.dao.keyGenerator.snowFlake.machineId:1}")
    private long machineId;

    @Override
    public void run(ApplicationArguments args) {
        SnowFlakeUtils.getId(dataCenterId, machineId);
        log.info("snowflake init! dataCenterId:{},machineId:{}", dataCenterId, machineId);
    }
}
