Require roomTypeCode for room upsert
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
This commit is contained in:
@@ -247,17 +247,12 @@ class Rooms(
|
||||
}
|
||||
|
||||
private fun resolveRoomType(propertyId: UUID, request: RoomUpsertRequest): com.android.trisolarisserver.models.room.RoomType {
|
||||
request.roomTypeId?.let { id ->
|
||||
roomTypeRepo.findByIdAndPropertyId(id, propertyId)?.let { return it }
|
||||
val code = request.roomTypeCode.trim()
|
||||
if (code.isBlank()) {
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "roomTypeCode required")
|
||||
}
|
||||
val code = request.roomTypeCode?.trim()
|
||||
if (!code.isNullOrBlank()) {
|
||||
roomTypeRepo.findByPropertyIdAndCodeIgnoreCase(propertyId, code)?.let { return it }
|
||||
}
|
||||
if (request.roomTypeId == null && code.isNullOrBlank()) {
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "roomTypeId or roomTypeCode required")
|
||||
}
|
||||
throw ResponseStatusException(HttpStatus.NOT_FOUND, "Room type not found")
|
||||
return roomTypeRepo.findByPropertyIdAndCodeIgnoreCase(propertyId, code)
|
||||
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Room type not found")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ enum class RoomBoardStatus {
|
||||
data class RoomUpsertRequest(
|
||||
val roomNumber: Int,
|
||||
val floor: Int?,
|
||||
val roomTypeId: UUID? = null,
|
||||
val roomTypeCode: String? = null,
|
||||
val roomTypeCode: String,
|
||||
val hasNfc: Boolean,
|
||||
val active: Boolean,
|
||||
val maintenance: Boolean,
|
||||
|
||||
Reference in New Issue
Block a user