diff --git a/go.mod b/go.mod index b65b9f2..fe5c569 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module smpp-transmitter go 1.23rc1 require ( - github.com/joho/godotenv v1.5.1 github.com/streadway/amqp v1.1.0 gorm.io/driver/mysql v1.5.7 - gorm.io/gorm v1.25.11 ) require ( github.com/go-sql-driver/mysql v1.7.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/joho/godotenv v1.5.1 golang.org/x/text v0.14.0 // indirect + gorm.io/gorm v1.25.11 // indirect ) diff --git a/pkg/data/message.go b/pkg/data/message.go index 0d316f4..95a40da 100644 --- a/pkg/data/message.go +++ b/pkg/data/message.go @@ -3,14 +3,17 @@ package data import ( "context" "encoding/json" + "time" "gorm.io/gorm" ) type Message struct { + ID uint `gorm:"primarykey"` Src string `json:"src"` Dst string `json:"dst"` Msg string `json:"msg"` + Ts int `json:"ts"` } func (m *Message) Convert(msgBody []byte) error { @@ -21,8 +24,13 @@ func (m *Message) Convert(msgBody []byte) error { } func (m *Message) Insert(ctx context.Context, db *gorm.DB) error { + m.Ts = int(time.Now().Unix()) if err := db.WithContext(ctx).Create(&m).Error; err != nil { return err } return nil } + +func (m *Message) TableName() string { + return "outbox" +}