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 }