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 {
|
private fun resolveRoomType(propertyId: UUID, request: RoomUpsertRequest): com.android.trisolarisserver.models.room.RoomType {
|
||||||
request.roomTypeId?.let { id ->
|
val code = request.roomTypeCode.trim()
|
||||||
roomTypeRepo.findByIdAndPropertyId(id, propertyId)?.let { return it }
|
if (code.isBlank()) {
|
||||||
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "roomTypeCode required")
|
||||||
}
|
}
|
||||||
val code = request.roomTypeCode?.trim()
|
return roomTypeRepo.findByPropertyIdAndCodeIgnoreCase(propertyId, code)
|
||||||
if (!code.isNullOrBlank()) {
|
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Room type not found")
|
||||||
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")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ enum class RoomBoardStatus {
|
|||||||
data class RoomUpsertRequest(
|
data class RoomUpsertRequest(
|
||||||
val roomNumber: Int,
|
val roomNumber: Int,
|
||||||
val floor: Int?,
|
val floor: Int?,
|
||||||
val roomTypeId: UUID? = null,
|
val roomTypeCode: String,
|
||||||
val roomTypeCode: String? = null,
|
|
||||||
val hasNfc: Boolean,
|
val hasNfc: Boolean,
|
||||||
val active: Boolean,
|
val active: Boolean,
|
||||||
val maintenance: Boolean,
|
val maintenance: Boolean,
|
||||||
|
|||||||
Reference in New Issue
Block a user