init(app) moved app code from Lab1

This commit is contained in:
imadev
2026-10-21 16:42:14 +03:00
parent 65003b6119
commit 1db3953226
22 changed files with 1297 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
package chats
import (
"time"
"gitflic.ru/project/bulla-max/mtusi2026lab1/internal/common"
"github.com/google/uuid"
)
type Chat struct {
ID uuid.UUID `json:"id"`
Title string `json:"title"`
MemberIDs []uuid.UUID `json:"member_ids"`
CreatedAt common.RFCFormTime `json:"created_at"`
}
type CreateChatRequest struct {
Title string `json:"title" validate:"required"`
MemberIDs []uuid.UUID `json:"member_ids" validate:"required"`
}
func NewChat(req CreateChatRequest) Chat {
return Chat{
ID: uuid.New(),
Title: req.Title,
MemberIDs: req.MemberIDs,
CreatedAt: common.NowUTC(),
}
}
func (c Chat) GetID() uuid.UUID {
return c.ID
}
func (c Chat) GetCreatedAt() time.Time {
return time.Time(c.CreatedAt)
}
func (c Chat) GetMemberIDs() []uuid.UUID {
return c.MemberIDs
}