lab 3 done
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type Chat struct {
|
||||
ID string
|
||||
Title string
|
||||
MemberIDs []string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type Message struct {
|
||||
IdempotencyKey string
|
||||
ID string
|
||||
ChatID string
|
||||
SenderID string
|
||||
Text string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
Username string
|
||||
DisplayName string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user