modes of transport
This commit is contained in:
@@ -0,0 +1,113 @@
|
|||||||
|
package com.android.trisolarisserver.controller
|
||||||
|
|
||||||
|
import com.android.trisolarisserver.component.PropertyAccess
|
||||||
|
import com.android.trisolarisserver.controller.dto.GuestResponse
|
||||||
|
import com.android.trisolarisserver.controller.dto.GuestVehicleRequest
|
||||||
|
import com.android.trisolarisserver.models.booking.Guest
|
||||||
|
import com.android.trisolarisserver.models.booking.GuestVehicle
|
||||||
|
import com.android.trisolarisserver.repo.GuestRepo
|
||||||
|
import com.android.trisolarisserver.repo.GuestVehicleRepo
|
||||||
|
import com.android.trisolarisserver.repo.PropertyRepo
|
||||||
|
import com.android.trisolarisserver.security.MyPrincipal
|
||||||
|
import org.springframework.http.HttpStatus
|
||||||
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
|
import org.springframework.web.bind.annotation.*
|
||||||
|
import org.springframework.web.server.ResponseStatusException
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/properties/{propertyId}/guests")
|
||||||
|
class Guests(
|
||||||
|
private val propertyAccess: PropertyAccess,
|
||||||
|
private val propertyRepo: PropertyRepo,
|
||||||
|
private val guestRepo: GuestRepo,
|
||||||
|
private val guestVehicleRepo: GuestVehicleRepo
|
||||||
|
) {
|
||||||
|
|
||||||
|
@GetMapping("/search")
|
||||||
|
fun search(
|
||||||
|
@PathVariable propertyId: UUID,
|
||||||
|
@AuthenticationPrincipal principal: MyPrincipal?,
|
||||||
|
@RequestParam(required = false) phone: String?,
|
||||||
|
@RequestParam(required = false) vehicleNumber: String?
|
||||||
|
): List<GuestResponse> {
|
||||||
|
requirePrincipal(principal)
|
||||||
|
propertyAccess.requireMember(propertyId, principal!!.userId)
|
||||||
|
|
||||||
|
if (phone.isNullOrBlank() && vehicleNumber.isNullOrBlank()) {
|
||||||
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "phone or vehicleNumber required")
|
||||||
|
}
|
||||||
|
|
||||||
|
val property = propertyRepo.findById(propertyId).orElseThrow {
|
||||||
|
ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
|
||||||
|
}
|
||||||
|
val orgId = property.org.id ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Org missing")
|
||||||
|
|
||||||
|
val guests = mutableSetOf<Guest>()
|
||||||
|
if (!phone.isNullOrBlank()) {
|
||||||
|
val guest = guestRepo.findByOrgIdAndPhoneE164(orgId, phone)
|
||||||
|
if (guest != null) guests.add(guest)
|
||||||
|
}
|
||||||
|
if (!vehicleNumber.isNullOrBlank()) {
|
||||||
|
val vehicle = guestVehicleRepo.findByOrgIdAndVehicleNumberIgnoreCase(orgId, vehicleNumber)
|
||||||
|
if (vehicle != null) guests.add(vehicle.guest)
|
||||||
|
}
|
||||||
|
return guests.toResponse(guestVehicleRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{guestId}/vehicles")
|
||||||
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
|
fun addVehicle(
|
||||||
|
@PathVariable propertyId: UUID,
|
||||||
|
@PathVariable guestId: UUID,
|
||||||
|
@AuthenticationPrincipal principal: MyPrincipal?,
|
||||||
|
@RequestBody request: GuestVehicleRequest
|
||||||
|
): GuestResponse {
|
||||||
|
requirePrincipal(principal)
|
||||||
|
propertyAccess.requireMember(propertyId, principal!!.userId)
|
||||||
|
|
||||||
|
val property = propertyRepo.findById(propertyId).orElseThrow {
|
||||||
|
ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
|
||||||
|
}
|
||||||
|
val guest = guestRepo.findById(guestId).orElseThrow {
|
||||||
|
ResponseStatusException(HttpStatus.NOT_FOUND, "Guest not found")
|
||||||
|
}
|
||||||
|
if (guest.org.id != property.org.id) {
|
||||||
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Guest not in property org")
|
||||||
|
}
|
||||||
|
if (guestVehicleRepo.existsByOrgIdAndVehicleNumberIgnoreCase(property.org.id!!, request.vehicleNumber)) {
|
||||||
|
throw ResponseStatusException(HttpStatus.CONFLICT, "Vehicle number already exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
val vehicle = GuestVehicle(
|
||||||
|
org = property.org,
|
||||||
|
guest = guest,
|
||||||
|
vehicleNumber = request.vehicleNumber.trim()
|
||||||
|
)
|
||||||
|
guestVehicleRepo.save(vehicle)
|
||||||
|
return listOf(guest).toResponse(guestVehicleRepo).first()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requirePrincipal(principal: MyPrincipal?) {
|
||||||
|
if (principal == null) {
|
||||||
|
throw ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing principal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Set<Guest>.toResponse(guestVehicleRepo: GuestVehicleRepo): List<GuestResponse> {
|
||||||
|
val ids = this.mapNotNull { it.id }
|
||||||
|
val vehicles = if (ids.isEmpty()) emptyList() else guestVehicleRepo.findByGuestIdIn(ids)
|
||||||
|
val vehiclesByGuest = vehicles.groupBy { it.guest.id }
|
||||||
|
return this.map { guest ->
|
||||||
|
GuestResponse(
|
||||||
|
id = guest.id!!,
|
||||||
|
orgId = guest.org.id!!,
|
||||||
|
name = guest.name,
|
||||||
|
phoneE164 = guest.phoneE164,
|
||||||
|
nationality = guest.nationality,
|
||||||
|
addressText = guest.addressText,
|
||||||
|
vehicleNumbers = vehiclesByGuest[guest.id]?.map { it.vehicleNumber }?.toSet() ?: emptySet()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.android.trisolarisserver.controller.dto.OrgResponse
|
|||||||
import com.android.trisolarisserver.repo.AppUserRepo
|
import com.android.trisolarisserver.repo.AppUserRepo
|
||||||
import com.android.trisolarisserver.repo.OrganizationRepo
|
import com.android.trisolarisserver.repo.OrganizationRepo
|
||||||
import com.android.trisolarisserver.repo.PropertyUserRepo
|
import com.android.trisolarisserver.repo.PropertyUserRepo
|
||||||
|
import com.android.trisolarisserver.models.booking.TransportMode
|
||||||
import com.android.trisolarisserver.models.property.Organization
|
import com.android.trisolarisserver.models.property.Organization
|
||||||
import com.android.trisolarisserver.models.property.Role
|
import com.android.trisolarisserver.models.property.Role
|
||||||
import com.android.trisolarisserver.security.MyPrincipal
|
import com.android.trisolarisserver.security.MyPrincipal
|
||||||
@@ -42,12 +43,16 @@ class Orgs(
|
|||||||
val org = Organization().apply {
|
val org = Organization().apply {
|
||||||
name = request.name
|
name = request.name
|
||||||
emailAliases = request.emailAliases?.toMutableSet() ?: mutableSetOf()
|
emailAliases = request.emailAliases?.toMutableSet() ?: mutableSetOf()
|
||||||
|
if (request.allowedTransportModes != null) {
|
||||||
|
allowedTransportModes = parseTransportModes(request.allowedTransportModes)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val saved = orgRepo.save(org)
|
val saved = orgRepo.save(org)
|
||||||
return OrgResponse(
|
return OrgResponse(
|
||||||
id = saved.id ?: throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Org id missing"),
|
id = saved.id ?: throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Org id missing"),
|
||||||
name = saved.name ?: "",
|
name = saved.name ?: "",
|
||||||
emailAliases = saved.emailAliases.toSet()
|
emailAliases = saved.emailAliases.toSet(),
|
||||||
|
allowedTransportModes = saved.allowedTransportModes.map { it.name }.toSet()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +71,8 @@ class Orgs(
|
|||||||
return OrgResponse(
|
return OrgResponse(
|
||||||
id = org.id ?: throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Org id missing"),
|
id = org.id ?: throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Org id missing"),
|
||||||
name = org.name ?: "",
|
name = org.name ?: "",
|
||||||
emailAliases = org.emailAliases.toSet()
|
emailAliases = org.emailAliases.toSet(),
|
||||||
|
allowedTransportModes = org.allowedTransportModes.map { it.name }.toSet()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,4 +84,12 @@ class Orgs(
|
|||||||
ResponseStatusException(HttpStatus.UNAUTHORIZED, "User not found")
|
ResponseStatusException(HttpStatus.UNAUTHORIZED, "User not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun parseTransportModes(modes: Set<String>): MutableSet<TransportMode> {
|
||||||
|
return try {
|
||||||
|
modes.map { TransportMode.valueOf(it) }.toMutableSet()
|
||||||
|
} catch (_: IllegalArgumentException) {
|
||||||
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown transport mode")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.android.trisolarisserver.models.property.PropertyUser
|
|||||||
import com.android.trisolarisserver.models.property.PropertyUserId
|
import com.android.trisolarisserver.models.property.PropertyUserId
|
||||||
import com.android.trisolarisserver.models.property.Role
|
import com.android.trisolarisserver.models.property.Role
|
||||||
import com.android.trisolarisserver.security.MyPrincipal
|
import com.android.trisolarisserver.security.MyPrincipal
|
||||||
|
import com.android.trisolarisserver.models.booking.TransportMode
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping
|
import org.springframework.web.bind.annotation.DeleteMapping
|
||||||
@@ -67,7 +68,8 @@ class Properties(
|
|||||||
currency = request.currency ?: "INR",
|
currency = request.currency ?: "INR",
|
||||||
active = request.active ?: true,
|
active = request.active ?: true,
|
||||||
otaAliases = request.otaAliases?.toMutableSet() ?: mutableSetOf(),
|
otaAliases = request.otaAliases?.toMutableSet() ?: mutableSetOf(),
|
||||||
emailAddresses = request.emailAddresses?.toMutableSet() ?: mutableSetOf()
|
emailAddresses = request.emailAddresses?.toMutableSet() ?: mutableSetOf(),
|
||||||
|
allowedTransportModes = request.allowedTransportModes?.let { parseTransportModes(it) } ?: mutableSetOf()
|
||||||
)
|
)
|
||||||
val saved = propertyRepo.save(property)
|
val saved = propertyRepo.save(property)
|
||||||
return saved.toResponse()
|
return saved.toResponse()
|
||||||
@@ -215,6 +217,9 @@ class Properties(
|
|||||||
if (request.emailAddresses != null) {
|
if (request.emailAddresses != null) {
|
||||||
property.emailAddresses = request.emailAddresses.toMutableSet()
|
property.emailAddresses = request.emailAddresses.toMutableSet()
|
||||||
}
|
}
|
||||||
|
if (request.allowedTransportModes != null) {
|
||||||
|
property.allowedTransportModes = parseTransportModes(request.allowedTransportModes)
|
||||||
|
}
|
||||||
|
|
||||||
return propertyRepo.save(property).toResponse()
|
return propertyRepo.save(property).toResponse()
|
||||||
}
|
}
|
||||||
@@ -239,6 +244,14 @@ class Properties(
|
|||||||
throw ResponseStatusException(HttpStatus.FORBIDDEN, "Missing role")
|
throw ResponseStatusException(HttpStatus.FORBIDDEN, "Missing role")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun parseTransportModes(modes: Set<String>): MutableSet<TransportMode> {
|
||||||
|
return try {
|
||||||
|
modes.map { TransportMode.valueOf(it) }.toMutableSet()
|
||||||
|
} catch (_: IllegalArgumentException) {
|
||||||
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown transport mode")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Property.toResponse(): PropertyResponse {
|
private fun Property.toResponse(): PropertyResponse {
|
||||||
@@ -254,7 +267,8 @@ private fun Property.toResponse(): PropertyResponse {
|
|||||||
currency = currency,
|
currency = currency,
|
||||||
active = active,
|
active = active,
|
||||||
otaAliases = otaAliases.toSet(),
|
otaAliases = otaAliases.toSet(),
|
||||||
emailAddresses = emailAddresses.toSet()
|
emailAddresses = emailAddresses.toSet(),
|
||||||
|
allowedTransportModes = allowedTransportModes.map { it.name }.toSet()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.android.trisolarisserver.controller
|
||||||
|
|
||||||
|
import com.android.trisolarisserver.component.PropertyAccess
|
||||||
|
import com.android.trisolarisserver.controller.dto.TransportModeStatusResponse
|
||||||
|
import com.android.trisolarisserver.models.booking.TransportMode
|
||||||
|
import com.android.trisolarisserver.repo.PropertyRepo
|
||||||
|
import com.android.trisolarisserver.security.MyPrincipal
|
||||||
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
import org.springframework.web.server.ResponseStatusException
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/properties/{propertyId}/transport-modes")
|
||||||
|
class TransportModes(
|
||||||
|
private val propertyAccess: PropertyAccess,
|
||||||
|
private val propertyRepo: PropertyRepo
|
||||||
|
) {
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
fun list(
|
||||||
|
@PathVariable propertyId: UUID,
|
||||||
|
@AuthenticationPrincipal principal: MyPrincipal?
|
||||||
|
): List<TransportModeStatusResponse> {
|
||||||
|
requirePrincipal(principal)
|
||||||
|
propertyAccess.requireMember(propertyId, principal!!.userId)
|
||||||
|
|
||||||
|
val property = propertyRepo.findById(propertyId).orElseThrow {
|
||||||
|
ResponseStatusException(org.springframework.http.HttpStatus.NOT_FOUND, "Property not found")
|
||||||
|
}
|
||||||
|
val allowed = when {
|
||||||
|
property.allowedTransportModes.isNotEmpty() -> property.allowedTransportModes
|
||||||
|
property.org.allowedTransportModes.isNotEmpty() -> property.org.allowedTransportModes
|
||||||
|
else -> TransportMode.entries.toSet()
|
||||||
|
}
|
||||||
|
return TransportMode.entries.map { mode ->
|
||||||
|
TransportModeStatusResponse(
|
||||||
|
mode = mode.name,
|
||||||
|
enabled = allowed.contains(mode)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requirePrincipal(principal: MyPrincipal?) {
|
||||||
|
if (principal == null) {
|
||||||
|
throw ResponseStatusException(org.springframework.http.HttpStatus.UNAUTHORIZED, "Missing principal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,13 +4,15 @@ import java.util.UUID
|
|||||||
|
|
||||||
data class OrgCreateRequest(
|
data class OrgCreateRequest(
|
||||||
val name: String,
|
val name: String,
|
||||||
val emailAliases: Set<String>? = null
|
val emailAliases: Set<String>? = null,
|
||||||
|
val allowedTransportModes: Set<String>? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
data class OrgResponse(
|
data class OrgResponse(
|
||||||
val id: UUID,
|
val id: UUID,
|
||||||
val name: String,
|
val name: String,
|
||||||
val emailAliases: Set<String>
|
val emailAliases: Set<String>,
|
||||||
|
val allowedTransportModes: Set<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PropertyCreateRequest(
|
data class PropertyCreateRequest(
|
||||||
@@ -21,7 +23,8 @@ data class PropertyCreateRequest(
|
|||||||
val currency: String? = null,
|
val currency: String? = null,
|
||||||
val active: Boolean? = null,
|
val active: Boolean? = null,
|
||||||
val otaAliases: Set<String>? = null,
|
val otaAliases: Set<String>? = null,
|
||||||
val emailAddresses: Set<String>? = null
|
val emailAddresses: Set<String>? = null,
|
||||||
|
val allowedTransportModes: Set<String>? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PropertyUpdateRequest(
|
data class PropertyUpdateRequest(
|
||||||
@@ -32,7 +35,8 @@ data class PropertyUpdateRequest(
|
|||||||
val currency: String? = null,
|
val currency: String? = null,
|
||||||
val active: Boolean? = null,
|
val active: Boolean? = null,
|
||||||
val otaAliases: Set<String>? = null,
|
val otaAliases: Set<String>? = null,
|
||||||
val emailAddresses: Set<String>? = null
|
val emailAddresses: Set<String>? = null,
|
||||||
|
val allowedTransportModes: Set<String>? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PropertyResponse(
|
data class PropertyResponse(
|
||||||
@@ -45,7 +49,27 @@ data class PropertyResponse(
|
|||||||
val currency: String,
|
val currency: String,
|
||||||
val active: Boolean,
|
val active: Boolean,
|
||||||
val otaAliases: Set<String>,
|
val otaAliases: Set<String>,
|
||||||
val emailAddresses: Set<String>
|
val emailAddresses: Set<String>,
|
||||||
|
val allowedTransportModes: Set<String>
|
||||||
|
)
|
||||||
|
|
||||||
|
data class GuestResponse(
|
||||||
|
val id: UUID,
|
||||||
|
val orgId: UUID,
|
||||||
|
val name: String?,
|
||||||
|
val phoneE164: String?,
|
||||||
|
val nationality: String?,
|
||||||
|
val addressText: String?,
|
||||||
|
val vehicleNumbers: Set<String>
|
||||||
|
)
|
||||||
|
|
||||||
|
data class GuestVehicleRequest(
|
||||||
|
val vehicleNumber: String
|
||||||
|
)
|
||||||
|
|
||||||
|
data class TransportModeStatusResponse(
|
||||||
|
val mode: String,
|
||||||
|
val enabled: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
data class UserResponse(
|
data class UserResponse(
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ class Booking(
|
|||||||
@Column(name = "email_audit_pdf_url")
|
@Column(name = "email_audit_pdf_url")
|
||||||
var emailAuditPdfUrl: String? = null,
|
var emailAuditPdfUrl: String? = null,
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "transport_mode")
|
||||||
|
var transportMode: TransportMode? = null,
|
||||||
|
|
||||||
|
@Column(name = "transport_vehicle_number")
|
||||||
|
var transportVehicleNumber: String? = null,
|
||||||
|
|
||||||
var notes: String? = null,
|
var notes: String? = null,
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.android.trisolarisserver.models.booking
|
||||||
|
|
||||||
|
import com.android.trisolarisserver.models.property.Organization
|
||||||
|
import jakarta.persistence.*
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(
|
||||||
|
name = "guest_vehicle",
|
||||||
|
uniqueConstraints = [UniqueConstraint(columnNames = ["org_id", "vehicle_number"])]
|
||||||
|
)
|
||||||
|
class GuestVehicle(
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
@Column(columnDefinition = "uuid")
|
||||||
|
val id: UUID? = null,
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "org_id", nullable = false)
|
||||||
|
var org: Organization,
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "guest_id", nullable = false)
|
||||||
|
var guest: Guest,
|
||||||
|
|
||||||
|
@Column(name = "vehicle_number", nullable = false)
|
||||||
|
var vehicleNumber: String,
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
||||||
|
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.android.trisolarisserver.models.booking
|
||||||
|
|
||||||
|
enum class TransportMode {
|
||||||
|
CAR,
|
||||||
|
BIKE,
|
||||||
|
TRAIN,
|
||||||
|
PLANE,
|
||||||
|
BUS,
|
||||||
|
FOOT,
|
||||||
|
CYCLE,
|
||||||
|
OTHER
|
||||||
|
}
|
||||||
@@ -20,7 +20,17 @@ class Organization {
|
|||||||
joinColumns = [JoinColumn(name = "org_id")]
|
joinColumns = [JoinColumn(name = "org_id")]
|
||||||
)
|
)
|
||||||
@Column(name = "email", nullable = false)
|
@Column(name = "email", nullable = false)
|
||||||
var emailAliases: MutableSet<String> = mutableSetOf()
|
var emailAliases: MutableSet<String> = mutableSetOf(),
|
||||||
|
|
||||||
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
|
@CollectionTable(
|
||||||
|
name = "org_transport_mode",
|
||||||
|
joinColumns = [JoinColumn(name = "org_id")]
|
||||||
|
)
|
||||||
|
@Column(name = "mode", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
var allowedTransportModes: MutableSet<com.android.trisolarisserver.models.booking.TransportMode> =
|
||||||
|
mutableSetOf(),
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
||||||
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
||||||
|
|||||||
@@ -53,6 +53,16 @@ class Property(
|
|||||||
@Column(name = "alias", nullable = false)
|
@Column(name = "alias", nullable = false)
|
||||||
var otaAliases: MutableSet<String> = mutableSetOf(),
|
var otaAliases: MutableSet<String> = mutableSetOf(),
|
||||||
|
|
||||||
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
|
@CollectionTable(
|
||||||
|
name = "property_transport_mode",
|
||||||
|
joinColumns = [JoinColumn(name = "property_id")]
|
||||||
|
)
|
||||||
|
@Column(name = "mode", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
var allowedTransportModes: MutableSet<com.android.trisolarisserver.models.booking.TransportMode> =
|
||||||
|
mutableSetOf(),
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
||||||
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.android.trisolarisserver.repo
|
||||||
|
|
||||||
|
import com.android.trisolarisserver.models.booking.GuestVehicle
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
interface GuestVehicleRepo : JpaRepository<GuestVehicle, UUID> {
|
||||||
|
fun findByOrgIdAndVehicleNumberIgnoreCase(orgId: UUID, vehicleNumber: String): GuestVehicle?
|
||||||
|
fun findByGuestIdIn(guestIds: List<UUID>): List<GuestVehicle>
|
||||||
|
fun existsByOrgIdAndVehicleNumberIgnoreCase(orgId: UUID, vehicleNumber: String): Boolean
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user