259 lines
9.3 KiB
Go
259 lines
9.3 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,
|
|
isActive bool,
|
|
) (GetWidgetDb, error)
|
|
GetWidgetsByStreamer(ctx context.Context, streamerID int) (AllWidgets, error)
|
|
UpdateWidget(ctx context.Context, updateWidget UpdateWidget, widgetID, accountID int) error
|
|
DeleteWidget(ctx context.Context, widgetID, accountID int) error
|
|
|
|
GetWidgetHTML(ctx context.Context, widgetPageID uuid.UUID) (string, error)
|
|
}
|
|
|
|
type WidgetRepo interface {
|
|
CreateWidget(ctx context.Context,
|
|
streamerID int,
|
|
templateID int,
|
|
duration int,
|
|
minAmount int,
|
|
maxAmount int,
|
|
image string,
|
|
audio string,
|
|
name string,
|
|
isActive bool,
|
|
) (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
|
|
CheckExistsWidget(ctx context.Context, widgetID, accountID int) error
|
|
GetWidgetByID(ctx context.Context, widgetID int) (GetWidgetDb, error)
|
|
DeleteWidget(ctx context.Context, widgetID, accountID int) error
|
|
|
|
CreateStreamerWidgetPage(ctx context.Context, streamerID int) error
|
|
GetStreamerWidgetPageId(ctx context.Context, streamerID int) (uuid.UUID, error)
|
|
GetStreamerIdByWidgetPageId(ctx context.Context, widgetPageId uuid.UUID) (int, error)
|
|
}
|
|
|
|
type DonatService interface {
|
|
InitNewStreamer(ctx context.Context, streamerID int, login string) error
|
|
|
|
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
|
|
|
|
CreateDonat(ctx context.Context, streamerLogin, text, donatUser string, targetID *int, amount int) (api.CreatePaymentResponse, error)
|
|
|
|
GetDonatsByStreamerID(ctx context.Context, streamerID, page, limit int) ([]*Donat, error)
|
|
GetDonatByOrderID(ctx context.Context, orderID string) (*Donat, error)
|
|
|
|
MarkDonatPaid(ctx context.Context, orderID string) error
|
|
MarkDonatView(ctx context.Context, orderID string) error
|
|
|
|
GetInnerDonatPage(ctx context.Context, streamerID int, token string) (InnerDonatePageResponse, error)
|
|
GetOuterDonatPage(ctx context.Context, streamerLogin string) (OuterDonatePageResponse, error)
|
|
UpdateDonatePage(
|
|
ctx context.Context,
|
|
streamerID int,
|
|
updateModel UpdateDonatPage,
|
|
background multipart.FileHeader,
|
|
headImg multipart.FileHeader,
|
|
avatar multipart.FileHeader,
|
|
) error
|
|
GetVoiceSettings(ctx context.Context, streamerID int) (VoiceSettingsResponse, error)
|
|
UpdateVoiceSettings(ctx context.Context, streamerID int, updateModel UpdateVoiceSettings) error
|
|
|
|
GetFiltersSettings(ctx context.Context, streamerID int) (FilterSettingResponse, error)
|
|
UpdateFiltersSettings(ctx context.Context, streamerID int, updateModel UpdateFilterSettings) error
|
|
|
|
GetModerationSettings(ctx context.Context, streamerID int) (ModerationResponse, error)
|
|
UpdateModerationSettings(ctx context.Context, streamerID int, updateModel UpdateModeration) error
|
|
|
|
GetDonationsStats(ctx context.Context, streamerID int, period string) (DonationSummaryResponse, error)
|
|
|
|
GetDonatModeration(ctx context.Context, streamerID int) (DonationModeration, error)
|
|
ModerateDonation(ctx context.Context, donatID, streamerID int, updateModel ModerationDonat) error
|
|
|
|
GetPlayingDonat(ctx context.Context, streamerID int) (PlayingDonatResponse, error)
|
|
UpdateStreamerLogin(ctx context.Context, streamerLogin string, streamerID int) error
|
|
UpdateAvatarStreamer(token, avatarId string) error
|
|
}
|
|
|
|
type DonatRepo interface {
|
|
InitNewStreamer(
|
|
ctx context.Context,
|
|
streamerID int,
|
|
login,
|
|
defaultAvatar,
|
|
defaultBackground,
|
|
defaultHead string,
|
|
) error
|
|
|
|
CreateDonat(
|
|
ctx context.Context,
|
|
streamerID int,
|
|
targetID *int,
|
|
widgetID int,
|
|
orderID uuid.UUID,
|
|
amount int,
|
|
text string,
|
|
donatUser string,
|
|
) error
|
|
|
|
GetDonatsByStreamerID(ctx context.Context, streamerID, page, limit int) ([]*Donat, error)
|
|
GetDonatByOrderID(ctx context.Context, orderID string) (*Donat, error)
|
|
|
|
MarkDonatPaid(ctx context.Context, orderID string) error
|
|
MarkDonatView(ctx context.Context, orderID string) error
|
|
|
|
GetDonatPage(ctx context.Context, streamerID int) (DonatePage, error)
|
|
GetDonatPageByLogin(ctx context.Context, streamerLogin string) (DonatePage, error)
|
|
|
|
UpdateDonatePage(
|
|
ctx context.Context,
|
|
streamerID int,
|
|
backgroundFileID *string,
|
|
headImgFileID *string,
|
|
avatarFileID *string,
|
|
description *string,
|
|
textAfterDonation *string,
|
|
profileAvatar *bool,
|
|
pageBackground *string,
|
|
) error
|
|
GetVoiceSettingsByStreamerID(ctx context.Context, streamerID int) (VoiceSettingsResponse, error)
|
|
UpdateVoiceSettings(ctx context.Context, streamerID int, updateModel UpdateVoiceSettings) error
|
|
|
|
GetLanguagesByStreamerID(ctx context.Context, streamerID int) ([]Language, error)
|
|
DeleteLanguagesByVoiceSettingID(ctx context.Context, voiceSettingID int) error
|
|
InsertLanguagesForVoiceSetting(ctx context.Context, voiceSettingID int, languageIDs []int) error
|
|
GetLanguageIDsByISOCodes(ctx context.Context, isoCodes []string) ([]int, error)
|
|
GetVoiceSettingIDByStreamerID(ctx context.Context, streamerID int) (int, error)
|
|
|
|
GetFilterSettingsByStreamerID(ctx context.Context, streamerID int) (int, bool, error)
|
|
GetFilteredWords(ctx context.Context, streamerID int) ([]string, error)
|
|
UpdateFilterSettings(ctx context.Context, streamerID int, enableLinks *bool) error
|
|
AddFilteredWords(ctx context.Context, filterID int, words []string) error
|
|
RemoveFilteredWords(ctx context.Context, filterID int, words []string) error
|
|
GetFilterIDByStreamer(ctx context.Context, streamerID int) (int, error)
|
|
|
|
GetModeration(ctx context.Context, streamerID int) (ModerationResponse, error)
|
|
UpdateModeration(ctx context.Context, streamerID int, enable *bool, duration *int) error
|
|
|
|
GetDonationsStats(ctx context.Context, streamerID int, period string) ([]DonationStat, error)
|
|
GetDonationsSummary(ctx context.Context, streamerID int, period string) (DonationSummary, error)
|
|
|
|
GetDonatModeration(ctx context.Context, streamerID int) (DonationModeration, error)
|
|
ModerateDonation(ctx context.Context, donatID, streamerID int, updateModel ModerationDonat) error
|
|
|
|
GetPlayingDonat(ctx context.Context, streamerID int) (PlayingDonat, error)
|
|
UpdateStreamerLogin(ctx context.Context, streamerLogin string, streamerID int) error
|
|
}
|
|
|
|
type TargetService interface {
|
|
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
|
|
|
|
CreateTarget(ctx context.Context, streamerID int, amount int, text string) (int, error)
|
|
GetAllTarget(ctx context.Context, streamerID int) ([]*Target, error)
|
|
AddAmountToTarget(ctx context.Context, targetID, amount int) error
|
|
}
|
|
|
|
type TargetRepo interface {
|
|
CreateTarget(ctx context.Context, streamerID int, amount int, text string) (int, error)
|
|
GetAllTarget(ctx context.Context, streamerID int) ([]*Target, error)
|
|
AddAmountToTarget(ctx context.Context, targetID int, amount int) 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
|
|
DownloadLink(fileId uuid.UUID) string
|
|
}
|
|
|
|
type PaymentClient interface {
|
|
CreatePayment(streamerID int, amount int, orderID uuid.UUID) (api.CreatePaymentResponse, error)
|
|
}
|
|
type Db interface {
|
|
Insert(ctx context.Context, query string, args ...interface{}) (any, error)
|
|
InsertReturningObj(ctx context.Context, query string, args ...interface{}) pgx.Row
|
|
Select(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
|
|
SelectOne(ctx context.Context, query string, args ...interface{}) pgx.Row
|
|
Delete(ctx context.Context, query string, args ...interface{}) error
|
|
Update(ctx context.Context, query string, args ...interface{}) error
|
|
Exec(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, entity string,
|
|
) (string, error)
|
|
GetByID(ctx context.Context, fileID string) ([]byte, string, error)
|
|
WidgetsFiles(ctx context.Context, fileType string, streamerID int) ([]*DataFile, error)
|
|
GetFileInfoById(ctx context.Context, fileID string) (DataFile, error)
|
|
}
|
|
|
|
type FileService interface {
|
|
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
|
|
|
|
AddNewFile(
|
|
ctx context.Context,
|
|
file multipart.FileHeader,
|
|
streamerID int,
|
|
entity string,
|
|
) (string, error)
|
|
GetByID(ctx context.Context, fileID string) ([]byte, string, error)
|
|
WidgetsFiles(ctx context.Context, fileType string, streamerID int) ([]*DataFile, error)
|
|
GetFileInfo(ctx context.Context, fileID string) (DataFile, error)
|
|
}
|
|
|
|
type StreamerClient interface {
|
|
GetAvatarIdByToken(token string) (string, error)
|
|
GetAvatarById(accountId string) (string, error)
|
|
UpdateAvatarID(token string, avatarUUID string) error
|
|
}
|