forked from mtusi2026/mtusi2026lab2
26 lines
520 B
Go
26 lines
520 B
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Message struct {
|
|
ID string `json:"id"`
|
|
ChatID string `json:"chat_id"`
|
|
SenderID string `json:"sender_id"`
|
|
Text string `json:"text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (m Message) MarshalJSON() ([]byte, error) {
|
|
type Alias Message
|
|
return json.Marshal(&struct {
|
|
Alias
|
|
CreatedAt string `json:"created_at"`
|
|
}{
|
|
Alias: Alias(m),
|
|
CreatedAt: m.CreatedAt.UTC().Truncate(time.Second).Format(time.RFC3339),
|
|
})
|
|
}
|