package llc.arma.fleet.monitor.data.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.OneToOne
import jakarta.persistence.Table
import java.time.OffsetDateTime

@Entity
@Table(name = "beacons")
class BeaconEntity(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    @Column(nullable = false, unique = true)
    var identifier: String = "",

    @Column(nullable = false, unique = true)
    var macAddress: String = "",

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    var status: BeaconStatus = BeaconStatus.FREE,

    @OneToOne(mappedBy = "beacon", fetch = FetchType.LAZY)
    var boundMachine: MachineEntity? = null,

    @Column(nullable = true)
    var lastSeenAt: OffsetDateTime? = null,
) : BaseEntity()
