move card issuence server side
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.android.trisolarisserver.models.room
|
||||
|
||||
import com.android.trisolarisserver.models.property.AppUser
|
||||
import com.android.trisolarisserver.models.property.Property
|
||||
import jakarta.persistence.*
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.UUID
|
||||
|
||||
@Entity
|
||||
@Table(
|
||||
name = "issued_card",
|
||||
uniqueConstraints = [
|
||||
UniqueConstraint(columnNames = ["property_id", "card_index"])
|
||||
],
|
||||
indexes = [
|
||||
Index(name = "idx_issued_card_room_stay", columnList = "room_stay_id"),
|
||||
Index(name = "idx_issued_card_card_id", columnList = "card_id")
|
||||
]
|
||||
)
|
||||
class IssuedCard(
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(columnDefinition = "uuid")
|
||||
val id: UUID? = null,
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "property_id", nullable = false)
|
||||
var property: Property,
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "room_id", nullable = false)
|
||||
var room: Room,
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "room_stay_id", nullable = false)
|
||||
var roomStay: RoomStay,
|
||||
|
||||
@Column(name = "card_id", nullable = false)
|
||||
var cardId: String,
|
||||
|
||||
@Column(name = "card_index", nullable = false)
|
||||
var cardIndex: Int,
|
||||
|
||||
@Column(name = "issued_at", nullable = false, columnDefinition = "timestamptz")
|
||||
var issuedAt: OffsetDateTime,
|
||||
|
||||
@Column(name = "expires_at", nullable = false, columnDefinition = "timestamptz")
|
||||
var expiresAt: OffsetDateTime,
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "issued_by")
|
||||
var issuedBy: AppUser? = null,
|
||||
|
||||
@Column(name = "revoked_at", columnDefinition = "timestamptz")
|
||||
var revokedAt: OffsetDateTime? = null
|
||||
)
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.android.trisolarisserver.models.room
|
||||
|
||||
import com.android.trisolarisserver.models.property.Property
|
||||
import jakarta.persistence.*
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.UUID
|
||||
|
||||
@Entity
|
||||
@Table(
|
||||
name = "property_card_counter",
|
||||
uniqueConstraints = [UniqueConstraint(columnNames = ["property_id"])]
|
||||
)
|
||||
class PropertyCardCounter(
|
||||
@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(name = "next_index", nullable = false)
|
||||
var nextIndex: Int = 1,
|
||||
|
||||
@Column(name = "updated_at", nullable = false, columnDefinition = "timestamptz")
|
||||
var updatedAt: OffsetDateTime = OffsetDateTime.now()
|
||||
)
|
||||
Reference in New Issue
Block a user