forked from mtusi2026/mtusi2026lab7
на оценку 4
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"mtusi2026lab7/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}
|
||||
}
|
||||
Reference in New Issue
Block a user