added qmqx gorm models for trackers
This commit is contained in:
@@ -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{},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
31
server/internal/models/emqx.go
Normal file
31
server/internal/models/emqx.go
Normal 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"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user