package com.ruoyi.cai.manager;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

public class IdManager {

    private static final Snowflake SNOWFLAKE;

    static {
        int dataId = 1;
        String id = System.getProperty("DATA_ID");
        if(id != null){
            dataId = Integer.parseInt(id);
        }
        SNOWFLAKE = IdUtil.getSnowflake(1, dataId);
    }

    public static Long nextId(){
        return SNOWFLAKE.nextId();
    }

    public static String nextIdStr(){
        return SNOWFLAKE.nextIdStr();
    }
}
