returned lab1
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,31 @@
|
||||
package domain
|
||||
|
||||
import "errors"
|
||||
|
||||
type ErrorCode string
|
||||
|
||||
const (
|
||||
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,11 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type Message struct {
|
||||
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,10 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
Username string
|
||||
DisplayName string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user