feat: use db
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package internal
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ChannelMessage struct {
|
||||
ID int
|
||||
Message string
|
||||
Medias []ChannelMessageMedia
|
||||
ID int
|
||||
Message string
|
||||
Medias []ChannelMessageMedia
|
||||
PublishAt time.Time
|
||||
}
|
||||
|
||||
type ChannelMessageMedia struct {
|
||||
@@ -13,8 +18,8 @@ type ChannelMessageMedia struct {
|
||||
Video string
|
||||
}
|
||||
|
||||
func NewChannelMessage(id int) *ChannelMessage {
|
||||
return &ChannelMessage{ID: id}
|
||||
func NewChannelMessage(id, ts int) *ChannelMessage {
|
||||
return &ChannelMessage{ID: id, PublishAt: time.Unix(int64(ts), 0)}
|
||||
}
|
||||
|
||||
func (c *ChannelMessage) WithMessage(message string) *ChannelMessage {
|
||||
@@ -31,3 +36,8 @@ func (c *ChannelMessage) WithVideo(video string) *ChannelMessage {
|
||||
c.Medias = append(c.Medias, ChannelMessageMedia{Video: video})
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *ChannelMessage) GetMedia() string {
|
||||
b, _ := json.Marshal(c.Medias)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user