Add non-null vehicleNumbers to booking list response
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s

This commit is contained in:
androidlover5842
2026-02-04 15:30:40 +05:30
parent c549418c42
commit bc13816cbf
4 changed files with 28 additions and 0 deletions

View File

@@ -189,6 +189,7 @@ class BookingFlow(
}
@GetMapping
@Transactional(readOnly = true)
fun listBookings(
@PathVariable propertyId: UUID,
@AuthenticationPrincipal principal: MyPrincipal?,
@@ -238,6 +239,14 @@ class BookingFlow(
chargeRepo.sumAmountByBookingIds(bookingIds)
.associate { it.bookingId to it.total }
}
val guestIds = bookings.mapNotNull { it.primaryGuest?.id }.distinct()
val vehicleNumbersByGuest = if (guestIds.isEmpty()) {
emptyMap()
} else {
guestVehicleRepo.findRowsByGuestIds(guestIds)
.groupBy { it.guestId }
.mapValues { (_, rows) -> rows.map { it.vehicleNumber }.distinct().sorted() }
}
return bookings.map { booking ->
val guest = booking.primaryGuest
val stays = staysByBooking[booking.id].orEmpty()
@@ -261,6 +270,7 @@ class BookingFlow(
guestId = guest?.id,
guestName = guest?.name,
guestPhone = guest?.phoneE164,
vehicleNumbers = guest?.id?.let { vehicleNumbersByGuest[it] } ?: emptyList(),
roomNumbers = roomNumbersByBooking[booking.id] ?: emptyList(),
source = booking.source,
billingMode = booking.billingMode.name,