mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
新增 简单获取Snowflake 的 nextId方法
This commit is contained in:
parent
6c120dd568
commit
15aaf59cb3
@ -242,6 +242,7 @@ public class IdUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------- NanoId
|
// ------------------------------------------------------------------- NanoId
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取随机NanoId
|
* 获取随机NanoId
|
||||||
*
|
*
|
||||||
@ -262,4 +263,25 @@ public class IdUtil {
|
|||||||
public static String nanoId(int size) {
|
public static String nanoId(int size) {
|
||||||
return NanoId.randomNanoId(size);
|
return NanoId.randomNanoId(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单获取Snowflake 的 nextId
|
||||||
|
* 终端ID 数据中心ID 默认为1
|
||||||
|
*
|
||||||
|
* @return nextId
|
||||||
|
*/
|
||||||
|
public static long getSnowflakeNextId() {
|
||||||
|
return getSnowflake(1, 1).nextId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单获取Snowflake 的 nextId
|
||||||
|
* 终端ID 数据中心ID 默认为1
|
||||||
|
*
|
||||||
|
* @return nextIdStr
|
||||||
|
*/
|
||||||
|
public static String getSnowflakeNextIdStr() {
|
||||||
|
return getSnowflake(1, 1).nextIdStr();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user