Files
mtusi2026lab2/internal/domain/domain.go
T
mydan 196e118ede
Skeleton contracts / contracts (pull_request) Canceled after 0s
chore(solution): pull lab1 solution
2026-10-29 10:47:47 +03:00

56 lines
835 B
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
CreatedAt time.Time
}
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
}