ЛР 6 — БПИ2302 — Нурлыгаянова — на 3

This commit is contained in:
Nurlygayanova Ekaterina
2026-11-13 11:32:45 +03:00
parent 470d9d6f1e
commit 69a190be0e
164 changed files with 25947 additions and 29 deletions
+50
View File
@@ -0,0 +1,50 @@
package service
import (
"context"
"io"
"gitflic.ru/project/relationskatie/mtusi2026lab1-ashchkl/internal/domain"
)
type UsersService interface {
Register(ctx context.Context, username, displayName, password string) (domain.User, error)
Me(ctx context.Context, callerID string) (domain.User, error)
}
type ChatsService interface {
Create(ctx context.Context, callerID, title string, memberIDs []string) (domain.Chat, error)
Get(ctx context.Context, callerID, chatID string) (domain.Chat, error)
List(ctx context.Context, callerID, cursor string, limit int) (domain.Page[domain.Chat], error)
}
type MessagesService interface {
Send(ctx context.Context, callerID, chatID, idempotencyKey, text string, attachmentIDs []string) (domain.Message, error)
List(ctx context.Context, callerID, chatID, cursor string, limit int) (domain.Page[domain.Message], error)
}
// VariantOriginal — вариант содержимого по умолчанию.
const VariantOriginal = "original"
// UploadInput — параметры загрузки файла. Body читается не дальше лимита размера.
type UploadInput struct {
CallerID string
ChatID string
Filename string
ContentType string
ContentLength int64
Body io.Reader
}
type AttachmentsService interface {
Upload(ctx context.Context, in UploadInput) (domain.Attachment, error)
Get(ctx context.Context, callerID, attachmentID string) (domain.Attachment, error)
// Content возвращает метаданные и поток байтов. Поток обязательно закрыть.
Content(ctx context.Context, callerID, attachmentID, variant string) (domain.Attachment, io.ReadCloser, error)
}
type AuthService interface {
Login(ctx context.Context, username, password string) (domain.Session, error)
Authenticate(ctx context.Context, token string) (userID string, err error)
Logout(ctx context.Context, token string) error
}