Avoid lazy roomType access in room create/update responses
All checks were successful
build-and-deploy / build-deploy (push) Successful in 32s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 32s
This commit is contained in:
@@ -189,9 +189,19 @@ class Rooms(
|
||||
notes = request.notes
|
||||
)
|
||||
|
||||
val saved = roomRepo.save(room).toRoomResponse()
|
||||
val saved = roomRepo.save(room)
|
||||
val response = RoomResponse(
|
||||
id = saved.id ?: throw IllegalStateException("Room id is null"),
|
||||
roomNumber = saved.roomNumber,
|
||||
floor = saved.floor,
|
||||
roomTypeName = roomType.name,
|
||||
hasNfc = saved.hasNfc,
|
||||
active = saved.active,
|
||||
maintenance = saved.maintenance,
|
||||
notes = saved.notes
|
||||
)
|
||||
roomBoardEvents.emit(propertyId)
|
||||
return saved
|
||||
return response
|
||||
}
|
||||
|
||||
@PutMapping("/{roomId}")
|
||||
@@ -221,9 +231,19 @@ class Rooms(
|
||||
room.maintenance = request.maintenance
|
||||
room.notes = request.notes
|
||||
|
||||
val saved = roomRepo.save(room).toRoomResponse()
|
||||
val saved = roomRepo.save(room)
|
||||
val response = RoomResponse(
|
||||
id = saved.id ?: throw IllegalStateException("Room id is null"),
|
||||
roomNumber = saved.roomNumber,
|
||||
floor = saved.floor,
|
||||
roomTypeName = roomType.name,
|
||||
hasNfc = saved.hasNfc,
|
||||
active = saved.active,
|
||||
maintenance = saved.maintenance,
|
||||
notes = saved.notes
|
||||
)
|
||||
roomBoardEvents.emit(propertyId)
|
||||
return saved
|
||||
return response
|
||||
}
|
||||
|
||||
private fun requirePrincipal(principal: MyPrincipal?) {
|
||||
|
||||
Reference in New Issue
Block a user