forked from mtusi2026/mtusi2026lab2
init(app) moved app code from Lab1
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package messages
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitflic.ru/project/bulla-max/mtusi2026lab1/internal/common"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
ChatID uuid.UUID `json:"chat_id"`
|
||||
SenderID uuid.UUID `json:"sender_id"`
|
||||
Text string `json:"text"`
|
||||
CreatedAt common.RFCFormTime `json:"created_at"`
|
||||
}
|
||||
|
||||
type CreateMessageRequest struct {
|
||||
Text string `json:"text" validate:"required"`
|
||||
}
|
||||
|
||||
func NewMessage(chatID, senderID uuid.UUID, text string) Message {
|
||||
return Message{
|
||||
ID: uuid.New(),
|
||||
ChatID: chatID,
|
||||
SenderID: senderID,
|
||||
Text: text,
|
||||
CreatedAt: common.NowUTC(),
|
||||
}
|
||||
}
|
||||
|
||||
func (m Message) GetID() uuid.UUID {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
func (m Message) GetCreatedAt() time.Time {
|
||||
return time.Time(m.CreatedAt)
|
||||
}
|
||||
|
||||
func (m Message) GetChatID() uuid.UUID {
|
||||
return m.ChatID
|
||||
}
|
||||
Reference in New Issue
Block a user