Add guest visit count by phone
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
This commit is contained in:
@@ -5,6 +5,7 @@ import com.android.trisolarisserver.component.GuestSignatureStorage
|
||||
import com.android.trisolarisserver.controller.dto.GuestResponse
|
||||
import com.android.trisolarisserver.controller.dto.GuestUpdateRequest
|
||||
import com.android.trisolarisserver.controller.dto.GuestVehicleRequest
|
||||
import com.android.trisolarisserver.controller.dto.GuestVisitCountResponse
|
||||
import com.android.trisolarisserver.models.booking.Guest
|
||||
import com.android.trisolarisserver.models.booking.GuestVehicle
|
||||
import com.android.trisolarisserver.db.repo.BookingRepo
|
||||
@@ -104,6 +105,22 @@ class Guests(
|
||||
return setOf(guest).toResponse(propertyId, guestVehicleRepo, guestRatingRepo).first()
|
||||
}
|
||||
|
||||
@GetMapping("/visit-count")
|
||||
fun getVisitCount(
|
||||
@PathVariable propertyId: UUID,
|
||||
@AuthenticationPrincipal principal: MyPrincipal?,
|
||||
@RequestParam phone: String
|
||||
): GuestVisitCountResponse {
|
||||
requireMember(propertyAccess, propertyId, principal)
|
||||
val phoneValue = phone.trim().ifBlank {
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "phone required")
|
||||
}
|
||||
requireProperty(propertyRepo, propertyId)
|
||||
val guest = guestRepo.findByPropertyIdAndPhoneE164(propertyId, phoneValue)
|
||||
val count = guest?.id?.let { bookingRepo.countByPrimaryGuestId(it) } ?: 0L
|
||||
return GuestVisitCountResponse(guestId = guest?.id, bookingCount = count)
|
||||
}
|
||||
|
||||
@PostMapping("/{guestId}/vehicles")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
fun addVehicle(
|
||||
|
||||
@@ -62,6 +62,11 @@ data class GuestVehicleRequest(
|
||||
val bookingId: UUID
|
||||
)
|
||||
|
||||
data class GuestVisitCountResponse(
|
||||
val guestId: UUID?,
|
||||
val bookingCount: Long
|
||||
)
|
||||
|
||||
data class TransportModeStatusResponse(
|
||||
val mode: String,
|
||||
val enabled: Boolean
|
||||
|
||||
Reference in New Issue
Block a user