IdGen工具新增,随机生成指定范围的Integer值
This commit is contained in:
@@ -43,6 +43,13 @@ public class IdGenerate {
|
||||
return EncodeUtils.encodeBase62(randomBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用SecureRandom随机生成指定范围的Integer.
|
||||
*/
|
||||
public static int randomInt(int min, int max) {
|
||||
return random.nextInt(max) % (max - min + 1) + min;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新唯一编号(18为数值)
|
||||
* 来自于twitter项目snowflake的id产生方案,全局唯一,时间有序。
|
||||
|
||||
Reference in New Issue
Block a user