Add amenities and size fields to room types
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:
@@ -0,0 +1,36 @@
|
||||
package com.android.trisolarisserver.models.room
|
||||
|
||||
import com.android.trisolarisserver.models.property.Property
|
||||
import jakarta.persistence.Column
|
||||
import jakarta.persistence.Entity
|
||||
import jakarta.persistence.FetchType
|
||||
import jakarta.persistence.GeneratedValue
|
||||
import jakarta.persistence.Id
|
||||
import jakarta.persistence.JoinColumn
|
||||
import jakarta.persistence.ManyToOne
|
||||
import jakarta.persistence.Table
|
||||
import jakarta.persistence.UniqueConstraint
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.UUID
|
||||
|
||||
@Entity
|
||||
@Table(
|
||||
name = "room_amenity",
|
||||
uniqueConstraints = [UniqueConstraint(columnNames = ["property_id", "name"])]
|
||||
)
|
||||
class RoomAmenity(
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(columnDefinition = "uuid")
|
||||
val id: UUID? = null,
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "property_id", nullable = false)
|
||||
var property: Property,
|
||||
|
||||
@Column(nullable = false)
|
||||
var name: String,
|
||||
|
||||
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
||||
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
||||
)
|
||||
@@ -32,6 +32,12 @@ class RoomType(
|
||||
@Column(name = "max_occupancy", nullable = false)
|
||||
var maxOccupancy: Int = 3,
|
||||
|
||||
@Column(name = "sq_feet")
|
||||
var sqFeet: Int? = null,
|
||||
|
||||
@Column(name = "bathroom_sq_feet")
|
||||
var bathroomSqFeet: Int? = null,
|
||||
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@CollectionTable(
|
||||
name = "room_type_alias",
|
||||
@@ -40,6 +46,14 @@ class RoomType(
|
||||
@Column(name = "alias", nullable = false)
|
||||
var otaAliases: MutableSet<String> = mutableSetOf(),
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "room_type_amenity_link",
|
||||
joinColumns = [JoinColumn(name = "room_type_id")],
|
||||
inverseJoinColumns = [JoinColumn(name = "amenity_id")]
|
||||
)
|
||||
var amenities: MutableSet<RoomAmenity> = mutableSetOf(),
|
||||
|
||||
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
|
||||
val createdAt: OffsetDateTime = OffsetDateTime.now()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user