forked from mtusi2026/mtusi2026lab7
на оценку 4
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"mtusi2026lab7/internal/domain"
|
||||
)
|
||||
|
||||
type UserRepository interface {
|
||||
CreateUser(ctx context.Context, username, displayName, passwordHash string) (domain.User, error)
|
||||
GetUserByUsername(ctx context.Context, username string) (domain.User, string, error)
|
||||
UpdatePasswordHash(ctx context.Context, userID, previousHash, newHash string) error
|
||||
}
|
||||
|
||||
type SessionRepository interface {
|
||||
CreateSession(ctx context.Context, tokenHash []byte, userID string, expiresAt time.Time) error
|
||||
GetUserBySession(ctx context.Context, tokenHash []byte) (domain.User, error)
|
||||
DeleteSession(ctx context.Context, tokenHash []byte) error
|
||||
}
|
||||
|
||||
type ChatRepository interface {
|
||||
CreateChat(ctx context.Context, title string, memberIDs []string) (domain.Chat, error)
|
||||
GetChatByID(ctx context.Context, chatID, callerID string) (domain.Chat, error)
|
||||
GetChatsForUser(ctx context.Context, userID string, limit int, cursor *domain.ChatCursor) ([]domain.Chat, bool, error)
|
||||
}
|
||||
|
||||
type IdempotentMessageWrite struct {
|
||||
ActorID string
|
||||
ChatID string
|
||||
Text string
|
||||
AttachmentIDs []string
|
||||
Method string
|
||||
CanonicalPath string
|
||||
Key string
|
||||
RequestHash [32]byte
|
||||
TTL time.Duration
|
||||
}
|
||||
|
||||
type MessageRepository interface {
|
||||
CreateMessageIdempotently(ctx context.Context, write IdempotentMessageWrite) (domain.Message, error)
|
||||
GetMessages(ctx context.Context, chatID, callerID string, limit int, cursor *domain.MessageCursor) ([]domain.Message, bool, error)
|
||||
}
|
||||
|
||||
type AttachmentRepository interface {
|
||||
CreateAttachment(ctx context.Context, attachment domain.Attachment) (domain.Attachment, error)
|
||||
MarkAttachmentReady(ctx context.Context, attachmentID string, updatedAt time.Time) (domain.Attachment, error)
|
||||
MarkAttachmentFailed(ctx context.Context, attachmentID, errorCode string, updatedAt time.Time) error
|
||||
GetAttachment(ctx context.Context, attachmentID, callerID string) (domain.Attachment, error)
|
||||
}
|
||||
|
||||
type AttachmentQueueRepository interface {
|
||||
CreateQueuedAttachment(ctx context.Context, attachment domain.Attachment, job domain.AttachmentJob) (domain.Attachment, error)
|
||||
}
|
||||
|
||||
type Repository interface {
|
||||
UserRepository
|
||||
SessionRepository
|
||||
ChatRepository
|
||||
MessageRepository
|
||||
AttachmentRepository
|
||||
}
|
||||
|
||||
type ObjectPut struct {
|
||||
Key string
|
||||
ContentType string
|
||||
SizeBytes int64
|
||||
Body io.Reader
|
||||
}
|
||||
|
||||
type ObjectContent struct {
|
||||
Body io.ReadCloser
|
||||
SizeBytes int64
|
||||
}
|
||||
|
||||
type ObjectStore interface {
|
||||
Put(ctx context.Context, object ObjectPut) error
|
||||
Get(ctx context.Context, key string) (ObjectContent, error)
|
||||
Delete(ctx context.Context, key string) error
|
||||
}
|
||||
Reference in New Issue
Block a user