Files
mtusi2026lab6/internal/repository/attachment.go

37 lines
1.1 KiB
Go

package repository
import (
"context"
"highload/internal/model"
"time"
)
type AttachmentRepository interface {
CreateAttachment(ctx context.Context, params CreateAttachmentParams) (*model.Attachment, error)
GetAttachmentForUser(ctx context.Context, userID, attachmentID string) (*model.Attachment, error)
ExistsByObjectKey(ctx context.Context, key string) (bool, error)
WithObjectKeyLock(ctx context.Context, key string, fn func(context.Context, AttachmentTx) error) (bool, error)
}
type AttachmentKey struct {
ID string
ObjectKey string
CreatedAt time.Time
}
type AttachmentReconcileRepository interface {
ListAttachmentKeys(ctx context.Context, afterKey string, pageSize int32) ([]AttachmentKey, error)
GetAttachmentByID(ctx context.Context, id string) (*model.Attachment, error)
WithObjectKeyLock(ctx context.Context, key string, fn func(context.Context, AttachmentTx) error) (bool, error)
}
type CreateAttachmentParams struct {
ChatID string
OwnerID string
Filename string
ObjectKey string
ContentType string
Sha256 string
SizeBytes int64
}