Files
mtusi2026lab2/internal/store/repository.go
T

81 lines
1.3 KiB
Go

package store
import (
"context"
"time"
"mtusi2026lab2/internal/domain"
)
type Repository interface {
CreateUser(
ctx context.Context,
username string,
displayName string,
passwordHash string,
) (domain.User, error)
GetUserByID(
ctx context.Context,
userID string,
) (domain.User, error)
GetUserByUsername(
ctx context.Context,
username string,
) (domain.User, string, error)
CreateChat(
ctx context.Context,
title string,
memberIDs []string,
) (domain.Chat, error)
GetChatByID(
ctx context.Context,
chatID string,
callerID string,
) (domain.Chat, error)
GetChatsForUser(
ctx context.Context,
userID string,
limit int,
cursor string,
) (domain.ChatPage, error)
CreateMessage(
ctx context.Context,
chatID string,
senderID string,
text string,
) (domain.Message, error)
GetMessages(
ctx context.Context,
chatID string,
callerID string,
limit int,
cursor string,
) (domain.MessagePage, error)
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
}
var _ Repository = (*PostgreSQLStore)(nil)