Expose property code and reduce retry count
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s

This commit is contained in:
androidlover5842
2026-02-01 23:04:07 +05:30
parent 0a11e765ad
commit 36b2d04de4
2 changed files with 20 additions and 1 deletions

View File

@@ -38,6 +38,11 @@ data class PropertyResponse(
val allowedTransportModes: Set<String> val allowedTransportModes: Set<String>
) )
data class PropertyCodeResponse(
val propertyId: UUID,
val code: String
)
data class GuestResponse( data class GuestResponse(
val id: UUID, val id: UUID,
val name: String?, val name: String?,

View File

@@ -4,6 +4,7 @@ import com.android.trisolarisserver.controller.common.requirePrincipal
import com.android.trisolarisserver.controller.common.requireUser import com.android.trisolarisserver.controller.common.requireUser
import com.android.trisolarisserver.component.auth.PropertyAccess import com.android.trisolarisserver.component.auth.PropertyAccess
import com.android.trisolarisserver.controller.dto.property.PropertyCodeResponse
import com.android.trisolarisserver.controller.dto.property.PropertyCreateRequest import com.android.trisolarisserver.controller.dto.property.PropertyCreateRequest
import com.android.trisolarisserver.controller.dto.property.PropertyResponse import com.android.trisolarisserver.controller.dto.property.PropertyResponse
import com.android.trisolarisserver.controller.dto.property.PropertyUserDisableRequest import com.android.trisolarisserver.controller.dto.property.PropertyUserDisableRequest
@@ -93,6 +94,19 @@ class Properties(
} }
} }
@GetMapping("/properties/{propertyId}/code")
fun getPropertyCode(
@PathVariable propertyId: UUID,
@AuthenticationPrincipal principal: MyPrincipal?
): PropertyCodeResponse {
requirePrincipal(principal)
propertyAccess.requireMember(propertyId, principal!!.userId)
val property = propertyRepo.findById(propertyId).orElseThrow {
ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
}
return PropertyCodeResponse(propertyId = property.id!!, code = property.code)
}
@GetMapping("/properties/{propertyId}/users") @GetMapping("/properties/{propertyId}/users")
fun listPropertyUsers( fun listPropertyUsers(
@PathVariable propertyId: UUID, @PathVariable propertyId: UUID,
@@ -279,7 +293,7 @@ class Properties(
} }
private fun generatePropertyCode(): String { private fun generatePropertyCode(): String {
repeat(200) { repeat(10) {
val code = buildString(7) { val code = buildString(7) {
repeat(7) { repeat(7) {
append(codeAlphabet[codeRandom.nextInt(codeAlphabet.length)]) append(codeAlphabet[codeRandom.nextInt(codeAlphabet.length)])