Files
mtusi2026lab3/app/internal/store/store.go
T
2026-11-05 17:56:30 +03:00

35 lines
1.3 KiB
Go

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 возвращает исходное сообщение, с другим — domain.ErrIdempotencyConflict.
AddMessage(ctx context.Context, callerID, chatID, idempotencyKey, text string) (domain.Message, error)
ListMessages(ctx context.Context, callerID, chatID, cursor string, limit int) (domain.Page[domain.Message], error)
}
type Store interface {
UserStore
ChatStore
MessageStore
}