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

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import java.time.OffsetDateTime

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

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "beacon_id", nullable = false)
    var beacon: BeaconEntity = BeaconEntity(),

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "machine_id", nullable = true)
    var machine: MachineEntity? = null,

    @Column(nullable = false)
    var mac: String = "",

    @Column(nullable = false)
    var vibration: Double = 0.0,

    @Column(nullable = false)
    var duration: Int = 0,

    @Column(nullable = false)
    var timeMillis: Long = 0,

    @Column(nullable = false)
    var receivedAt: OffsetDateTime = OffsetDateTime.now(),
)
