package models import ( "time" ) // DeviceCommandLog 记录下行任务的下发情况和设备确认状态 type DeviceCommandLog struct { // MessageID 是下行消息的唯一标识符。 // 可以是 ChirpStack 的 DeduplicationID 或其他系统生成的ID。 MessageID string `gorm:"primaryKey" json:"message_id"` // DeviceID 是接收此下行任务的设备的ID。 // 对于 LoRaWAN,这通常是区域主控设备的ID。 DeviceID uint `gorm:"not null;index" json:"device_id"` // SentAt 记录下行任务最初发送的时间。 SentAt time.Time `gorm:"not null" json:"sent_at"` // AcknowledgedAt 记录设备确认收到下行消息的时间。 // 如果设备未确认,则为零值或 NULL。使用指针类型 *time.Time 允许 NULL 值。 AcknowledgedAt *time.Time `json:"acknowledged_at"` // ReceivedSuccess 表示设备是否成功接收到下行消息。 // true 表示设备已确认收到,false 表示设备未确认收到或下发失败。 ReceivedSuccess bool `gorm:"not null" json:"received_success"` } // TableName 自定义 GORM 使用的数据库表名 func (DeviceCommandLog) TableName() string { return "device_command_log" }