forked from mtusi2026/mtusi2026lab5
ЛР 5: асинхронная обработка изображений, уровень 5
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitflic.ru/project/relationskatie/mtusi2026lab1-ashchkl/internal/domain"
|
||||
)
|
||||
|
||||
type UserStore interface {
|
||||
CreateUser(ctx context.Context, username, displayName, passwordHash string) (domain.User, error)
|
||||
UserByID(ctx context.Context, id string) (domain.User, error)
|
||||
CredentialsByUsername(ctx context.Context, username string) (domain.User, string, error)
|
||||
UsernameExists(ctx context.Context, username string) bool
|
||||
}
|
||||
|
||||
type ChatStore interface {
|
||||
CreateChat(ctx context.Context, callerID, title string, memberIDs []string) (domain.Chat, error)
|
||||
ChatByID(ctx context.Context, callerID, chatID string) (domain.Chat, error)
|
||||
ListChats(ctx context.Context, callerID, cursor string, limit int) (domain.Page[domain.Chat], error)
|
||||
}
|
||||
|
||||
type MessageStore interface {
|
||||
// AddMessage идемпотентен по (callerID, chatID, idempotencyKey): повтор с тем же
|
||||
// text и attachmentIDs возвращает исходное сообщение, с другими — domain.ErrIdempotencyConflict.
|
||||
// Вложение не из этого чата или неизвестное — domain.ErrNotFound.
|
||||
AddMessage(ctx context.Context, callerID, chatID, idempotencyKey, text string, attachmentIDs []string) (domain.Message, error)
|
||||
ListMessages(ctx context.Context, callerID, chatID, cursor string, limit int) (domain.Page[domain.Message], error)
|
||||
}
|
||||
|
||||
type AttachmentStore interface {
|
||||
CreateAttachment(ctx context.Context, att domain.Attachment) (domain.Attachment, error)
|
||||
// AttachmentForMember для постороннего возвращает domain.ErrNotFound.
|
||||
AttachmentForMember(ctx context.Context, callerID, attachmentID string) (domain.Attachment, error)
|
||||
// AttachmentExists нужен компенсации: ошибка INSERT не доказывает, что строки нет.
|
||||
AttachmentExists(ctx context.Context, attachmentID string) (bool, error)
|
||||
}
|
||||
|
||||
type Store interface {
|
||||
UserStore
|
||||
ChatStore
|
||||
MessageStore
|
||||
AttachmentStore
|
||||
}
|
||||
Reference in New Issue
Block a user