chore(solution): pull lab1 solution

This commit is contained in:
2026-10-29 10:47:47 +03:00
parent 65003b6119
commit 196e118ede
26 changed files with 1424 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
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
}
+10
View File
@@ -0,0 +1,10 @@
package domain
import "errors"
var (
ErrInvalidInput = errors.New("invalid input")
ErrUnauthorized = errors.New("unauthorized")
ErrNotFound = errors.New("not found")
ErrConflict = errors.New("conflict")
)