1 Star 0 Fork 462

誓言/bullshit-codes

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
NewId.java 639 Bytes
一键复制 编辑 原始数据 按行查看 历史
debuglife 提交于 2019-05-27 10:43 +08:00 . 令人发指的新建ID操作
import Java.util.Random;
class SomeBizOperation {
/*疯狂到令人发指*/
public String getNewId() {
while (true) {
String id = newId(10);
var obj = SomeTableQuery.getById(id);
if (obj == null) {
return obj;
}
}
}
private String newId(int length) {
String str = "0123456789";
var random = new Random();
StringBuffer sb = new StringBuffer();
for (int i =0; i<length; i++){
int number = random.next(62);
sb.append(str.charAt(number));
}
return sb.toString();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/java521/bullshit-codes.git
git@gitee.com:java521/bullshit-codes.git
java521
bullshit-codes
bullshit-codes
master

搜索帮助