на оценку 4

This commit is contained in:
2026-11-22 23:33:11 +03:00
parent 20afc2c790
commit cc41f601e3
207 changed files with 22098 additions and 120 deletions
+46
View File
@@ -0,0 +1,46 @@
package dto
import (
"time"
"mtusi2026lab7/internal/domain"
)
type CreateMessageRequest struct {
Text string `json:"text"`
AttachmentIDs []string `json:"attachment_ids"`
}
type MessageResponse struct {
ID string `json:"id"`
ChatID string `json:"chat_id"`
SenderID string `json:"sender_id"`
Text string `json:"text"`
AttachmentIDs []string `json:"attachment_ids"`
CreatedAt time.Time `json:"created_at"`
}
type MessagePageResponse struct {
Items []MessageResponse `json:"items"`
NextCursor *string `json:"next_cursor"`
}
func MessageFromDomain(message domain.Message) MessageResponse {
attachmentIDs := append([]string(nil), message.AttachmentIDs...)
if attachmentIDs == nil {
attachmentIDs = make([]string, 0)
}
return MessageResponse{
ID: message.ID, ChatID: message.ChatID, SenderID: message.SenderID,
Text: message.Text, AttachmentIDs: attachmentIDs, CreatedAt: message.CreatedAt,
}
}
func MessagePageFromDomain(page domain.MessagePage) MessagePageResponse {
items := make([]MessageResponse, len(page.Items))
for index, message := range page.Items {
items[index] = MessageFromDomain(message)
}
return MessagePageResponse{Items: items, NextCursor: page.NextCursor}
}