88 lines
4.3 KiB
Go
88 lines
4.3 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"donat-widget/internal/model/api"
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/labstack/echo/v4"
|
|
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
type WidgetService interface {
|
|
CreateWidget(ctx context.Context, streamerID StreamerID, templateId TemplateID, duration Duration, minAmount DonatAmount) (WidgetID, error)
|
|
DeleteWidget(ctx context.Context, widgetID WidgetID) error
|
|
UpdateDuration(ctx context.Context, widgetID WidgetID, duration Duration) error
|
|
GetWidgetInfo(ctx context.Context, widgetID WidgetID) (*DonatAndWidget, error)
|
|
GetWidgetHTML(ctx context.Context, widgetID WidgetID) (WidgetHTML, error)
|
|
SetMediaFile(ctx context.Context, mediaType MediaType, widgetID WidgetID, file UploadFile, filename string, size int64, collection string) error
|
|
SetMediaUrl(ctx context.Context, mediaType MediaType, widgetID WidgetID, mediaURL MediaUrl) error
|
|
UpdateMediaFile(ctx context.Context, widgetID WidgetID, mediaType MediaType, file UploadFile, filename string, size int64, collection string) error
|
|
GetMediaFile(ctx context.Context, widgetID WidgetID, mediaType MediaType) (DownloadFile, error)
|
|
}
|
|
|
|
type WidgetRepo interface {
|
|
CreateWidget(ctx context.Context, streamerID StreamerID, templateId TemplateID, duration Duration, minAmount DonatAmount) (WidgetID, error)
|
|
DeleteWidget(ctx context.Context, widgetID WidgetID) error
|
|
UpdateDuration(ctx context.Context, widgetID WidgetID, duration Duration) error
|
|
GetWidget(ctx context.Context, widgetID WidgetID) (*Widget, error)
|
|
GetAllWidget(ctx context.Context, streamerID StreamerID) ([]*Widget, error)
|
|
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 DonatService interface {
|
|
CreateDonat(ctx context.Context, streamerID StreamerID, orderID OrderID, targetID TargetID, amount DonatAmount, text string, donatUser string) (api.CreatePaymentResponse, error)
|
|
GetDonatByOrderID(ctx context.Context, orderID OrderID) (*Donat, error)
|
|
MarkDonatPaid(ctx context.Context, orderID OrderID) error
|
|
MarkDonatView(ctx context.Context, DonatID DonatID) error
|
|
}
|
|
|
|
type DonatRepo interface {
|
|
CreateDonat(ctx context.Context, widgetID WidgetID, orderID OrderID, targetID TargetID, amount DonatAmount, text string, donatUser string) error
|
|
GetDonat(ctx context.Context, widgetID WidgetID) ([]*Donat, error)
|
|
GetDonatByOrderID(ctx context.Context, orderID OrderID) (*Donat, error)
|
|
MarkDonatPaid(ctx context.Context, orderID OrderID) error
|
|
MarkDonatView(ctx context.Context, DonatID DonatID) error
|
|
}
|
|
|
|
type TargetService interface {
|
|
CreateTarget(ctx context.Context, streamerID StreamerID, amount DonatAmount, text string) error
|
|
GetAllTarget(ctx context.Context, streamerID StreamerID) ([]*Target, error)
|
|
AddAmountToTarget(ctx context.Context, targetID TargetID, amount DonatAmount) error
|
|
}
|
|
|
|
type TargetRepo interface {
|
|
CreateTarget(ctx context.Context, streamerID StreamerID, amount DonatAmount, text string) error
|
|
GetAllTarget(ctx context.Context, streamerID StreamerID) ([]*Target, error)
|
|
AddAmountToTarget(ctx context.Context, targetID TargetID, amount DonatAmount) error
|
|
}
|
|
|
|
type Error interface {
|
|
Error() string
|
|
}
|
|
|
|
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 PaymentClient interface {
|
|
CreatePayment(streamerID StreamerID, amount DonatAmount, orderID OrderID) (api.CreatePaymentResponse, error)
|
|
}
|
|
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)
|
|
CreateTable(ctx context.Context, query string) error
|
|
DropTable(ctx context.Context, query string) error
|
|
}
|
|
|
|
type AuthClient interface {
|
|
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
|
|
VerifyTwoFa(twoFaCode string, streamerID StreamerID) (bool, error)
|
|
}
|