Expose property code and reduce retry count
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
This commit is contained in:
@@ -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?,
|
||||||
|
|||||||
@@ -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)])
|
||||||
|
|||||||
Reference in New Issue
Block a user