Files
mtusi2026lab4-implementation/internal/domain/domain.go
T

84 lines
1.3 KiB
Go

package domain
import (
"time"
"uuid"
)
type User struct {
ID uuid.UUID
Username string
DisplayName string
CreatedAt time.Time
}
type Chat struct {
ID uuid.UUID
Title string
MemberIDs []uuid.UUID
CreatedAt time.Time
}
func (c Chat) HasMember(userID uuid.UUID) bool {
for _, id := range c.MemberIDs {
if id == userID {
return true
}
}
return false
}
type Message struct {
ID uuid.UUID
ChatID uuid.UUID
SenderID uuid.UUID
Text string
AttachmentIDs []uuid.UUID
CreatedAt time.Time
}
const (
AttachmentReady = "ready"
ContentPNG = "image/png"
ContentJPEG = "image/jpeg"
)
type Attachment struct {
ID uuid.UUID
ChatID uuid.UUID
OwnerID uuid.UUID
Filename string
ContentType string
SizeBytes int64
SHA256 string
ObjectKey string
Status string
ErrorCode *string
CreatedAt time.Time
UpdatedAt time.Time
}
type Session struct {
Token string
ExpiresAt time.Time
User User
}
type Cursor struct {
Scope uuid.UUID
CreatedAt time.Time
ID uuid.UUID
}
func CompareKey(aTime time.Time, aID uuid.UUID, bTime time.Time, bID uuid.UUID) int {
if c := aTime.Compare(bTime); c != 0 {
return c
}
return aID.Compare(bID)
}
type Page[T any] struct {
Items []T
Next *Cursor
}