donat-widget/internal/model/interfaces.go
2024-10-30 00:21:57 +05:00

93 lines
4.1 KiB
Go

package model
import (
"context"
"donat-widget/internal/model/api"
"github.com/jackc/pgx/v5"
"github.com/labstack/echo/v4"
)
type WidgetService interface {
CreateWidget(ctx context.Context, streamerID StreamerID, templateId TemplateID, duration Duration, minAmount DonatAmount) (WidgetID, error)
GetWidgetByID(ctx context.Context, widgetID WidgetID) ([]*Widget, error)
GetWidgetHTML(ctx context.Context, streamerID StreamerID) (WidgetHTML, error)
GetMediaFile(ctx context.Context, widgetID WidgetID, mediaType MediaType) (DownloadFile, 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
}
type WidgetRepo interface {
CreateWidget(ctx context.Context, streamerID StreamerID, templateId TemplateID, duration Duration, minAmount DonatAmount) (WidgetID, error)
GetWidgetByStreamerID(ctx context.Context, streamerID StreamerID) ([]*Widget, error)
GetWidgetByID(ctx context.Context, widgetID WidgetID) ([]*Widget, error)
GetAllWidget(ctx context.Context, streamerID StreamerID) ([]*Widget, error)
GetMediaFile(fileID FileID) (DownloadFile, error)
GetMediaUrl(ctx context.Context, widgetID WidgetID, mediaType MediaType) (MediaUrl, error)
SetMediaFile(file UploadFile, filename string, size int64, collection string) (FileID, error)
SetMediaUrl(ctx context.Context, widgetID WidgetID, mediaUrl MediaUrl, 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)
GetDonatByStreamerID(ctx context.Context, streamerID StreamerID) ([]*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 DonatRepo interface {
CreateDonat(ctx context.Context, streamerID StreamerID, widgetID WidgetID, orderID OrderID, targetID TargetID, amount DonatAmount, text string, donatUser string) error
GetDonatByStreamerID(ctx context.Context, streamerID StreamerID) ([]*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) (TargetID, 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) (TargetID, 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 {
Insert(ctx context.Context, query string, args ...interface{}) (int64, error)
Select(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
Delete(ctx context.Context, query string, args ...interface{}) error
Update(ctx context.Context, query string, args ...interface{}) 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)
}