lab 3 done

This commit is contained in:
Khakimov Dmitrij
2026-10-20 20:46:51 +03:00
parent 0ab3a341aa
commit f9015df5d1
113 changed files with 6763 additions and 49 deletions
+10
View File
@@ -0,0 +1,10 @@
package domain
import "time"
type Chat struct {
ID string
Title string
MemberIDs []string
CreatedAt time.Time
}
+32
View File
@@ -0,0 +1,32 @@
package domain
import "errors"
type ErrorCode string
const (
ErrorUnavailable ErrorCode = "unavailable"
ErrorInvalid ErrorCode = "invalid_request"
ErrorUnauthorized ErrorCode = "unauthorized"
ErrorNotFound ErrorCode = "not_found"
ErrorConflict ErrorCode = "conflict"
)
type ApplicationError struct {
Code ErrorCode
Message string
}
func (e *ApplicationError) Error() string {
return e.Message
}
func NewApplicationError(code ErrorCode, message string) error {
return &ApplicationError{Code: code, Message: message}
}
func AsApplicationError(err error) (*ApplicationError, bool) {
var applicationError *ApplicationError
ok := errors.As(err, &applicationError)
return applicationError, ok
}
+12
View File
@@ -0,0 +1,12 @@
package domain
import "time"
type Message struct {
IdempotencyKey string
ID string
ChatID string
SenderID string
Text string
CreatedAt time.Time
}
+23
View File
@@ -0,0 +1,23 @@
package domain
import "time"
type Position struct {
CreatedAt time.Time
ID string
}
type Pagination struct {
After *Position
Limit int
}
type ChatPage struct {
Items []Chat
HasMore bool
}
type MessagePage struct {
Items []Message
HasMore bool
}
+14
View File
@@ -0,0 +1,14 @@
package domain
import "time"
type Session struct {
UserID string `json:"user_id"`
ExpiresAt time.Time `json:"expires_at"`
}
type Login struct {
Token string
ExpiresAt time.Time
User User
}
+10
View File
@@ -0,0 +1,10 @@
package domain
import "time"
type User struct {
ID string
Username string
DisplayName string
CreatedAt time.Time
}