forked from mtusi2026/mtusi2026lab2
30 lines
803 B
Go
30 lines
803 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
"uuid"
|
|
|
|
"messenger/internal/domain"
|
|
)
|
|
|
|
type UserRepository interface {
|
|
CreateUser(ctx context.Context, u domain.User) error
|
|
GetUser(ctx context.Context, id uuid.UUID) (domain.User, error)
|
|
}
|
|
|
|
type ChatRepository interface {
|
|
CreateChat(ctx context.Context, c domain.Chat) error
|
|
GetChat(ctx context.Context, id uuid.UUID) (domain.Chat, error)
|
|
ListUserChats(ctx context.Context, userID uuid.UUID, after *domain.Cursor, limit int) ([]domain.Chat, bool, error)
|
|
}
|
|
|
|
type MessageRepository interface {
|
|
CreateMessage(ctx context.Context, m domain.Message) error
|
|
ListMessages(ctx context.Context, chatID uuid.UUID, after *domain.Cursor, limit int) ([]domain.Message, bool, error)
|
|
}
|
|
|
|
func now() time.Time {
|
|
return time.Now().UTC().Truncate(time.Microsecond)
|
|
}
|