Files
mtusi2026lab3/internal/transport/http/dto/chat.go
T

39 lines
914 B
Go

package dto
import (
"time"
"mtusi2026lab3/internal/domain"
)
type CreateChatRequest struct {
Title string `json:"title"`
MemberIDs []string `json:"member_ids"`
}
type ChatResponse struct {
ID string `json:"id"`
Title string `json:"title"`
MemberIDs []string `json:"member_ids"`
CreatedAt time.Time `json:"created_at"`
}
type ChatPageResponse struct {
Items []ChatResponse `json:"items"`
NextCursor *string `json:"next_cursor"`
}
func ChatFromDomain(chat domain.Chat) ChatResponse {
return ChatResponse{
ID: chat.ID, Title: chat.Title, MemberIDs: chat.MemberIDs, CreatedAt: chat.CreatedAt,
}
}
func ChatPageFromDomain(page domain.ChatPage) ChatPageResponse {
items := make([]ChatResponse, len(page.Items))
for index, chat := range page.Items {
items[index] = ChatFromDomain(chat)
}
return ChatPageResponse{Items: items, NextCursor: page.NextCursor}
}