added qmqx gorm models for trackers

This commit is contained in:
tdv
2025-11-28 17:42:51 +02:00
parent 2ba75d0e87
commit 50acf14fe1
3 changed files with 36 additions and 1 deletions

View File

@@ -23,5 +23,7 @@ func AutoMigrate(db *gorm.DB) error {
&models.DeviceCertificate{}, &models.DeviceCertificate{},
&models.RevokedSerial{}, &models.RevokedSerial{},
&models.DeviceConfig{}, &models.DeviceConfig{},
&models.MQTTMsg{},
&models.EmqxClientEvent{},
) )
} }

View File

@@ -20,6 +20,8 @@ type DeviceCertDto struct {
type DeviceCertListDto struct { type DeviceCertListDto struct {
Certs []DeviceCertDto `json:"certs"` Certs []DeviceCertDto `json:"certs"`
Offset int `json:"offset"`
Limit int `json:"limit"`
} }
func MapDeviceCert(c models.DeviceCertificate) DeviceCertDto { func MapDeviceCert(c models.DeviceCertificate) DeviceCertDto {

View File

@@ -0,0 +1,31 @@
package models
import "time"
// MQTTMsg maps to table t_mqtt_msg in emqx_data
type MQTTMsg struct {
ID uint `gorm:"primaryKey;column:id"`
MsgID string `gorm:"column:msgid;type:varchar(64)"`
Sender string `gorm:"column:sender;type:varchar(64)"`
Topic string `gorm:"column:topic;type:varchar(255)"`
QoS int `gorm:"column:qos"`
Retain int `gorm:"column:retain"`
Payload string `gorm:"column:payload;type:text"`
Arrived time.Time `gorm:"column:arrived"`
}
func (MQTTMsg) TableName() string {
return "t_mqtt_msg"
}
// EmqxClientEvent maps to table emqx_client_events in emqx_data
type EmqxClientEvent struct {
ID uint `gorm:"primaryKey;column:id"`
ClientID string `gorm:"column:clientid;type:varchar(255)"`
Event string `gorm:"column:event;type:varchar(255)"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
}
func (EmqxClientEvent) TableName() string {
return "emqx_client_events"
}