com.app.common.utils.IdUtil Maven / Gradle / Ivy
The newest version!
package com.app.common.utils;
import com.app.common.utils.SnowflakeIdWorker;
public class IdUtil {
public static String Prefix="";
public static void setWorkerId(int workerId)
{
idWorker = new SnowflakeIdWorker(workerId, 0);
}
private static SnowflakeIdWorker idWorker =null;
public static String getId() {
if(idWorker==null)
{
idWorker = new SnowflakeIdWorker(0, 0);
}
return Prefix+idWorker.nextId();
}
}