[O] Separate randExtId

This commit is contained in:
Azalea
2024-02-19 21:48:42 -05:00
parent ab075c0554
commit aa3b831a68
2 changed files with 12 additions and 2 deletions

View File

@@ -52,4 +52,12 @@ class CardService(val cardRepo: CardRepository) {
accessTime = registerTime
})
}
fun randExtID(lower: Long = 0, upper: Long = 99999999): Long {
var eid = ThreadLocalRandom.current().nextLong(lower, upper)
while (cardRepo.findByExtId(eid).isPresent) {
eid = ThreadLocalRandom.current().nextLong(lower, upper)
}
return eid
}
}