111 lines
1.8 KiB
Go
111 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
type Storage interface {
|
|
Upload(
|
|
file UploadFile,
|
|
filename string,
|
|
size int64,
|
|
collection string,
|
|
) (FileData, error)
|
|
Download(
|
|
FileID FileID,
|
|
) (DownloadFile, error)
|
|
Update(
|
|
file UploadFile,
|
|
fileID FileID,
|
|
filename string,
|
|
size int64,
|
|
collection string,
|
|
) error
|
|
}
|
|
|
|
type WidgetRepo interface {
|
|
CreateWidget(
|
|
ctx context.Context,
|
|
streamerID StreamerID,
|
|
templateId TemplateID,
|
|
) (WidgetID, error)
|
|
|
|
DeleteWidget(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
) error
|
|
|
|
GetWidget(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
) (*Widget, error)
|
|
|
|
UpdateWidgetDuration(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
duration Duration,
|
|
) error
|
|
}
|
|
|
|
type DonatRepo interface {
|
|
SetDonat(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
text string,
|
|
amount DonatAmount,
|
|
donatUser string,
|
|
) error
|
|
GetDonat(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
) ([]*Donat, error)
|
|
DeleteDonat(
|
|
ctx context.Context,
|
|
donatID DonatID,
|
|
) error
|
|
}
|
|
|
|
type MediaRepo interface {
|
|
SetMediaFile(
|
|
file UploadFile,
|
|
filename string,
|
|
size int64,
|
|
collection string,
|
|
) (FileID, error)
|
|
GetMediaFile(
|
|
fileID FileID,
|
|
) (DownloadFile, error)
|
|
GetMediaUrl(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
mediaType MediaType,
|
|
) (MediaUrl, error)
|
|
SetMediaUrl(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
mediaUrl MediaUrl,
|
|
mediaType MediaType,
|
|
) error
|
|
UpdateMediaFile(
|
|
ctx context.Context,
|
|
widgetID WidgetID,
|
|
file UploadFile,
|
|
fileID FileID,
|
|
filename string,
|
|
size int64,
|
|
collection string,
|
|
mediaType MediaType,
|
|
) error
|
|
}
|
|
|
|
type Error interface {
|
|
Error() string
|
|
}
|
|
|
|
type Db interface {
|
|
Exec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)
|
|
Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
|
|
}
|