donat-widget/internal/model/interfaces.go
2025-03-06 17:12:39 +05:00

181 lines
6.7 KiB
Go

package model
import (
"donat-widget/internal/model/api"
"github.com/google/uuid"
"mime/multipart"
)
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/labstack/echo/v4"
)
type WidgetService interface {
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
CreateWidget(ctx context.Context,
streamerID int,
templateID int,
duration int,
minAmount int,
maxAmount int,
image string,
audio string,
name string,
) (WidgetID, error)
GetWidgetsByStreamer(ctx context.Context, streamerID int) ([]*WidgetWithFileLink, error)
UpdateWidget(ctx context.Context, updateWidget UpdateWidget, widgetID, accountID int) error
//GetWidgetByID(ctx context.Context, widgetID WidgetID) ([]*GetWidgetDb, 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 int,
templateID int,
duration int,
minAmount int,
maxAmount int,
image string,
audio string,
name string,
) (WidgetID, error)
CheckWidgetName(ctx context.Context, streamerID int, name string) (bool, error)
GetWidgetsByStreamerID(ctx context.Context, streamerID int) ([]*GetWidgetDb, error)
UpdateWidget(
ctx context.Context,
widgetID int,
duration *int,
minAmount *int,
maxAmount *int,
isActive *bool,
image *uuid.UUID,
audio *uuid.UUID,
name *string,
) error
WidgetByID(ctx context.Context, widgetID, accountID int) error
//GetWidgetByID(ctx context.Context, widgetID WidgetID) ([]*GetWidgetDb, error)
//GetAllWidget(ctx context.Context, streamerID StreamerID) ([]*GetWidgetDb, 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 {
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
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
GetInnerDonatPage(ctx context.Context, streamerID StreamerID) (InnerDonatePageResponse, error)
GetOuterDonatPage(ctx context.Context, streamerLogin string) (OuterDonatePageResponse, error)
UpdateDonatePage(
ctx context.Context,
streamerID StreamerID,
updateModel UpdateDonatPage,
background *multipart.FileHeader,
headImg *multipart.FileHeader,
) error
GetVoiceSettings(ctx context.Context, streamerID StreamerID) (VoiceSettingsResponse, error)
UpdateVoiceSettings(ctx context.Context, streamerID StreamerID, updateModel UpdateVoiceSettings) error
GetFiltersSettings(ctx context.Context, streamerID StreamerID) (FilterSettingResponse, error)
UpdateFiltersSettings(ctx context.Context, streamerID StreamerID, updateModel UpdateFilterSettings) error
GetModerationSettings(ctx context.Context, streamerID StreamerID) (ModerationResponse, error)
UpdateModerationSettings(ctx context.Context, streamerID StreamerID, updateModel UpdateModeration) 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
GetDonatPage(ctx context.Context, streamerID StreamerID) (DonatePage, error)
GetDonatPageByLogin(ctx context.Context, streamerLogin string) (DonatePage, error)
}
type TargetService interface {
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
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 *multipart.FileHeader, streamerID int) (string, error)
Download(filename, folder string) ([]byte, error)
Delete(filename, extension, filePath 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{}) (any, error)
Select(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
SelectOne(ctx context.Context, query string, args ...interface{}) (pgx.Row, 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(token Token) (api.CheckTokenResponse, error)
VerifyTwoFa(twoFaCode string, streamerID StreamerID) (bool, error)
}
type FileRepo interface {
AddNew(
ctx context.Context,
streamerID int,
file multipart.FileHeader,
extension, fileType string,
) (string, error)
GetByID(ctx context.Context, fileID string) ([]byte, string, error)
WidgetsFiles(ctx context.Context, fileType string, streamerID int) ([]*DataFile, error)
}
type FileService interface {
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
AddNewFile(
ctx context.Context,
file multipart.FileHeader,
streamerID int,
) (string, error)
GetByID(ctx context.Context, fileID string) ([]byte, string, error)
WidgetsFiles(ctx context.Context, fileType string, streamerID int) ([]*DataFile, error)
}