mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
!485 新增 简单获取Snowflake 的 nextId方法
Merge pull request !485 from handy/hs-dev
This commit is contained in:
commit
b31b8d6626
@ -242,6 +242,7 @@ public class IdUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------- NanoId
|
// ------------------------------------------------------------------- NanoId
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取随机NanoId
|
* 获取随机NanoId
|
||||||
*
|
*
|
||||||
@ -259,7 +260,28 @@ public class IdUtil {
|
|||||||
* @return 随机NanoId
|
* @return 随机NanoId
|
||||||
* @since 5.7.5
|
* @since 5.7.5
|
||||||
*/
|
*/
|
||||||
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().nextId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单获取Snowflake 的 nextId
|
||||||
|
* 终端ID 数据中心ID 默认为1
|
||||||
|
*
|
||||||
|
* @return nextIdStr
|
||||||
|
*/
|
||||||
|
public static String getSnowflakeNextIdStr() {
|
||||||
|
return getSnowflake().nextIdStr();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user