refactor: split iot models by entity
This commit is contained in:
22
backend/api/internal/models/iot_device_message.go
Normal file
22
backend/api/internal/models/iot_device_message.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// IotDeviceMessage 保存原始上行/回执和服务端接收时间,原始事实不可由前端修改。
|
||||
type IotDeviceMessage struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:数据库自增主键" json:"-"` // 数据库主键
|
||||
Identity string `gorm:"column:identity;type:varchar(36);not null;uniqueIndex;comment:上行消息业务标识" json:"identity"` // 上行消息标识
|
||||
DeviceID string `gorm:"column:device_id;type:varchar(16);not null;index;comment:厂商设备标识" json:"device_id"` // 厂商设备标识
|
||||
Topic string `gorm:"column:topic;type:varchar(255);not null;comment:接收消息主题" json:"topic"` // MQTT主题
|
||||
MessageType string `gorm:"column:message_type;type:varchar(32);not null;index;comment:上行或回执消息类型" json:"message_type"` // 消息类型
|
||||
PayloadHex string `gorm:"column:payload_hex;type:text;not null;comment:原始报文十六进制" json:"payload_hex"` // 原始报文
|
||||
DecodedFrame string `gorm:"column:decoded_frame;type:text;not null;comment:协议解析结果快照" json:"decoded_frame"` // 解析快照
|
||||
DeviceOccurredAt *time.Time `gorm:"column:device_occurred_at;type:timestamptz;comment:设备原始采集时间" json:"device_occurred_at"` // 设备采集时间
|
||||
ReceivedAt time.Time `gorm:"column:received_at;type:timestamptz;not null;index;comment:服务端接收时间" json:"received_at"` // 服务端接收时间
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamptz;not null;index;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamptz;not null;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
func (*IotDeviceMessage) TableName() string { return "iot_device_message" }
|
||||
Reference in New Issue
Block a user