From 0a11e765ad9de5731c3a0c27c884576004062713 Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Sun, 1 Feb 2026 23:00:03 +0530 Subject: [PATCH] Randomize property codes with 7-char alphabet --- .../trisolarisserver/controller/property/Properties.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/property/Properties.kt b/src/main/kotlin/com/android/trisolarisserver/controller/property/Properties.kt index 4705799..e7233d6 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/property/Properties.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/property/Properties.kt @@ -39,6 +39,8 @@ class Properties( private val propertyUserRepo: PropertyUserRepo, private val appUserRepo: AppUserRepo ) { + private val codeRandom = java.security.SecureRandom() + private val codeAlphabet = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789" @PostMapping("/properties") @ResponseStatus(HttpStatus.CREATED) @@ -277,8 +279,12 @@ class Properties( } private fun generatePropertyCode(): String { - repeat(10) { - val code = "HOTE" + (100..999).random() + repeat(200) { + val code = buildString(7) { + repeat(7) { + append(codeAlphabet[codeRandom.nextInt(codeAlphabet.length)]) + } + } if (!propertyRepo.existsByCode(code)) { return code }