278 lines
14 KiB
Go
278 lines
14 KiB
Go
package model
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"time"
|
|
)
|
|
|
|
type DataFile struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
FileType string `db:"file_type" json:"file_type"`
|
|
FileName string `db:"file_name" json:"file_name"`
|
|
Extension string `db:"extension" json:"extension"`
|
|
StreamerID int `db:"streamer_id" json:"streamer_id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
Size float32 `db:"size" json:"size"`
|
|
FileLink string `json:"file_link"`
|
|
Entity string `db:"entity"`
|
|
}
|
|
|
|
type GetWidgetDb struct {
|
|
ID int `db:"id" json:"id" example:"1" format:"int64" description:"Unique identifier of the widget"`
|
|
StreamerID int `db:"streamer_id" json:"streamer_id" example:"1001" format:"int64" description:"ID of the streamer"`
|
|
TemplateID int `db:"template_id" json:"template_id" example:"5" format:"int64" description:"ID of the template"`
|
|
Duration int `db:"duration" json:"duration" example:"30" format:"int64" description:"Duration of the widget"`
|
|
MinAmount int `db:"min_amount" json:"min_amount" example:"100" format:"int64" description:"Minimum donation amount"`
|
|
MaxAmount int `db:"max_amount" json:"max_amount" example:"1000" format:"int64" description:"Maximum donation amount"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at" format:"date-time" example:"2025-03-06T13:37:36Z" description:"Timestamp when the widget was created"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at" format:"date-time" example:"2025-03-07T10:15:30Z" description:"Timestamp when the widget was last updated"`
|
|
GroupID int `db:"group_id" json:"group_id" example:"2" format:"int64" description:"Group ID associated with the widget"`
|
|
IsActive bool `db:"is_active" json:"is_active" example:"true" description:"Whether or not this widget is active"`
|
|
|
|
// Поля для изображения
|
|
ImageFileId uuid.UUID `db:"image_id" json:"image_id" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440000" description:"UUID of the image file"`
|
|
ImageFileName string `db:"image_file_name" json:"image_file_name" example:"background.png" description:"Name of the image file"`
|
|
ImageType string `db:"image_type" json:"image_type" example:"image/png" description:"Type of the image file"`
|
|
ImageLink string `json:"image_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" description:"Public URL of the image"`
|
|
|
|
// Поля для аудио
|
|
AudioFileId uuid.UUID `db:"audio_id" json:"audio_id" format:"uuid" example:"123e4567-e89b-12d3-a456-426614174000" description:"UUID of the audio file"`
|
|
AudioFileName string `db:"audio_file_name" json:"audio_file_name" example:"alert.mp3" description:"Name of the audio file"`
|
|
AudioType string `db:"audio_type" json:"audio_type" example:"audio/mp3" description:"Type of the audio file"`
|
|
AudioLink string `json:"audio_link" example:"https://cdn.example.com/audio/123e4567-e89b-12d3-a456-426614174000" description:"Public URL of the audio"`
|
|
}
|
|
|
|
type WidgetWithFileLink struct {
|
|
GroupID int `json:"group_id"`
|
|
Widgets []*GetWidgetDb `json:"widgets"`
|
|
}
|
|
|
|
type UpdateWidget struct {
|
|
IsActive *bool `json:"is_active" example:"true" description:"Indicates whether the widget is active or not"`
|
|
Name *string `json:"name" example:"Awesome Widget" description:"Name of the widget"`
|
|
Image *uuid.UUID `json:"image" example:"d2c2f03f-3fe5-4bfc-b963-5478a057149e" description:"UUID of the widget image"`
|
|
Audio *uuid.UUID `json:"audio" example:"a0f9e244-f61f-4bfe-a7a0-3b5e91fe7364" description:"UUID of the widget audio file"`
|
|
Duration *int `json:"duration" example:"120" description:"Duration of the widget in seconds"`
|
|
MinAmount *int `json:"min_amount" example:"10" description:"Minimum amount for the widget"`
|
|
MaxAmount *int `json:"max_amount" example:"100" description:"Maximum amount for the widget"`
|
|
}
|
|
|
|
type Donat struct {
|
|
ID DonatID `db:"id"`
|
|
StreamerID StreamerID `db:"streamer_id"`
|
|
WidgetID WidgetID `db:"widget_id"`
|
|
OrderID OrderID `db:"order_id"`
|
|
TargetID TargetID `db:"target_id"`
|
|
|
|
Text string `db:"text"`
|
|
DonatUser string `db:"donat_user"`
|
|
Amount DonatAmount `db:"amount"`
|
|
|
|
Paid bool `db:"paid"`
|
|
View bool `db:"view"`
|
|
|
|
CreatedAt time.Time `db:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at"`
|
|
}
|
|
|
|
type Target struct {
|
|
ID TargetID `db:"id"`
|
|
StreamerID StreamerID `db:"streamer_id"`
|
|
|
|
Text string `db:"text"`
|
|
Collected DonatAmount `db:"collected"`
|
|
Amount DonatAmount `db:"amount"`
|
|
|
|
CreatedAt time.Time `db:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at"`
|
|
}
|
|
|
|
type DonatePage struct {
|
|
// Основные поля
|
|
ID int `db:"id" json:"id" example:"1" format:"int64" description:"Уникальный идентификатор страницы доната"`
|
|
StreamerID int `db:"streamer_id" json:"streamer_id" example:"1001" format:"int64" description:"ID стримера"`
|
|
Description string `db:"description" json:"description" example:"Поддержи этого стримера" description:"Описание страницы доната"`
|
|
TextAfterDonat string `db:"text_after_donat" json:"text_after_donat" example:"Спасибо за вашу поддержку!" description:"Текст, который отображается после доната"`
|
|
StreamerLogin string `db:"streamer_login" json:"streamer_login" example:"streamer123" description:"Логин/псевдоним стримера"`
|
|
|
|
// Поля для хед-изображения
|
|
HeadImgFileId uuid.UUID `db:"head_img_id" json:"head_img_id" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440000" description:"UUID файла хед-изображения"`
|
|
HeadImgFileName string `db:"head_img_file_name" json:"head_img_file_name" example:"header.png" description:"Имя файла хед-изображения"`
|
|
HeadImgType string `db:"head_img_type" json:"head_img_type" example:"image/png" description:"Тип файла хед-изображения"`
|
|
HeadImgLink string `json:"head_img_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" description:"Публичный URL хед-изображения"`
|
|
HeadImgSize int `db:"head_img_size" json:"head_img_size" example:"1024" description:"Размер файла хед-изображения в байтах"`
|
|
|
|
// Поля для аватара
|
|
AvatarFileId uuid.UUID `db:"avatar_id" json:"avatar_id" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440001" description:"UUID файла аватара"`
|
|
AvatarFileName string `db:"avatar_file_name" json:"avatar_file_name" example:"avatar.png" description:"Имя файла аватара"`
|
|
AvatarType string `db:"avatar_type" json:"avatar_type" example:"image/png" description:"Тип файла аватара"`
|
|
AvatarLink string `json:"avatar_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440001" description:"Публичный URL аватара"`
|
|
AvatarImgSize int `db:"avatar_img_size" json:"avatar_img_size" example:"512" description:"Размер файла аватара в байтах"`
|
|
|
|
// Поля для фона
|
|
BackgroundImgFileId uuid.UUID `db:"background_img_id" json:"background_img_id" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440002" description:"UUID файла фона"`
|
|
BackgroundImgFileName string `db:"background_img_file_name" json:"background_img_file_name" example:"background.png" description:"Имя файла фона"`
|
|
BackgroundImgType string `db:"background_img_type" json:"background_img_type" example:"image/png" description:"Тип файла фона"`
|
|
BackgroundImgLink string `json:"background_img_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440002" description:"Публичный URL фона"`
|
|
BackgroundImgSize int `db:"background_img_size" json:"background_img_size" example:"2048" description:"Размер файла фона в байтах"`
|
|
}
|
|
|
|
type InnerFile struct {
|
|
FileID uuid.UUID `json:"file_id" example:"550e8400-e29b-41d4-a716-446655440000" description:"UUID файла"`
|
|
FileName string `json:"file_name" example:"header.png" description:"Имя файла"`
|
|
FileType string `json:"file_type" example:"image/png" description:"Тип файла"`
|
|
FileLink string `json:"file_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" description:"Публичный URL файла"`
|
|
FileSize int `json:"file_size" example:"1024" description:"Размер файла в байтах"`
|
|
}
|
|
|
|
type InnerDonatePageResponse struct {
|
|
Description string `json:"description"`
|
|
TextAfterDonat string `json:"text_after_donat"`
|
|
HeadImg InnerFile `json:"head_img"`
|
|
Avatar InnerFile `json:"avatar"`
|
|
BackgroundImg InnerFile `json:"background_img"`
|
|
}
|
|
|
|
type Moderation struct {
|
|
ID int `db:"id"`
|
|
StreamerID int `db:"streamer_id"`
|
|
Enable bool `db:"enable"`
|
|
Duration int `db:"duration"`
|
|
}
|
|
|
|
type OuterDonatePageResponse struct {
|
|
Login string `json:"login" example:"streamer123" description:"Логин или псевдоним стримера"`
|
|
OnLine string `json:"online" example:"online" description:"Статус стримера (online/offline)"`
|
|
Description string `json:"description" example:"Поддержи этого стримера" description:"Описание страницы доната"`
|
|
BackgroundImg string `json:"background_img" example:"https://cdn.example.com/images/background.png" description:"Ссылка на фоновое изображение"`
|
|
AvatarImg string `json:"avatar_img" example:"https://cdn.example.com/images/avatar.png" description:"Ссылка на аватар"`
|
|
HeadImg string `json:"head_img" example:"https://cdn.example.com/images/header.png" description:"Ссылка на хед-изображение"`
|
|
}
|
|
|
|
type Filter struct {
|
|
ID int `db:"id"`
|
|
StreamerID int `db:"streamer_id"`
|
|
EnableLinks bool `db:"enable_links"`
|
|
}
|
|
|
|
type FilterWord struct {
|
|
ID int `db:"id"`
|
|
DonatFilterID int `db:"donat_filter_id"`
|
|
Word string `db:"word"`
|
|
}
|
|
|
|
type VoiceSettings struct {
|
|
ID int `db:"id"`
|
|
StreamerID int `db:"streamer_id"`
|
|
VoiceSpeed int `db:"voice_speed"`
|
|
Scenery string `db:"scenery"`
|
|
VoiceSoundPercent int `db:"voice_sound_percent"`
|
|
MinPrice int `db:"min_price"`
|
|
}
|
|
|
|
type VoiceLanguage struct {
|
|
ID int `db:"id"`
|
|
VoiceSettingID int `db:"voice_setting_id"`
|
|
LanguageID int `db:"language_id"`
|
|
}
|
|
|
|
type UpdateDonatPage struct {
|
|
ProfileAvatar *bool `json:"profile_avatar,omitempty" form:"profile_avatar" example:"true" description:"Indicates whether the profile avatar is displayed"`
|
|
Description *string `json:"description,omitempty" form:"description" example:"A great donation page" description:"Description of the donation page"`
|
|
TextAfterDonat *string `json:"text_after_donat,omitempty" form:"text_after_donat" example:"Thank you for your support!" description:"Text displayed after a donation"`
|
|
PageBackground *string `json:"page_background,omitempty" form:"page_background" example:"#13161E" description:"Color code"`
|
|
}
|
|
|
|
type Language struct {
|
|
ID int `json:"id" db:"language_id"`
|
|
ISOCode string `json:"iso_code" db:"iso_code"`
|
|
RUName string `json:"ru_name" db:"ru_name"`
|
|
ENName string `json:"en_name" db:"en_name"`
|
|
}
|
|
|
|
type VoiceSettingsResponse struct {
|
|
VoiceSpeed int `json:"voice_speed"`
|
|
Scenery string `json:"scenery"`
|
|
VoiceSoundPercent int `json:"voice_sound_percent"`
|
|
MinPrice int `json:"min_price"`
|
|
Languages []Language `json:"languages"` // Новое поле
|
|
}
|
|
|
|
type UpdateVoiceSettings struct {
|
|
Enable *bool `json:"enable"`
|
|
VoiceSpeed *int `json:"voice_speed"`
|
|
Scenery *string `json:"scenery"`
|
|
VoiceSoundPercent *int `json:"voice_sound_percent"`
|
|
MinPrice *int `json:"min_price"`
|
|
Languages []string `json:"languages"`
|
|
}
|
|
|
|
type FilterSettingResponse struct {
|
|
EnableLinks bool `json:"enable_links"`
|
|
FilteredWords []string `json:"filtered_words"`
|
|
}
|
|
|
|
type UpdateFilterSettings struct {
|
|
EnableLinks *bool `json:"enable_links"`
|
|
AddWords []string `json:"add_words"`
|
|
RemoveWords []string `json:"remove_words"`
|
|
}
|
|
|
|
type ModerationResponse struct {
|
|
Enable bool `json:"enable"`
|
|
Duration int `json:"duration"`
|
|
}
|
|
|
|
type UpdateModeration struct {
|
|
Enable *bool `json:"enable"`
|
|
Duration *int `json:"duration"`
|
|
}
|
|
|
|
type CreateWidgetResponse struct {
|
|
WidgetID WidgetID `json:"widget_id"`
|
|
}
|
|
|
|
// CreateWidgetBody структура для создания виджета
|
|
type CreateWidgetBody struct {
|
|
TemplateID int `json:"template_id" validate:"required" example:"1"`
|
|
Duration int `json:"duration" validate:"required" example:"30"`
|
|
Name string `json:"name" validate:"required" example:"My GetWidgetDb"`
|
|
Image string `json:"image" validate:"required" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440000"`
|
|
Audio string `json:"audio" validate:"required" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440001"`
|
|
MinAmount int `json:"min_amount" validate:"required" example:"10"`
|
|
MaxAmount int `json:"max_amount" validate:"required" example:"100"`
|
|
}
|
|
|
|
type DonatAndWidget struct {
|
|
Donat *Donat
|
|
Display Display
|
|
}
|
|
|
|
//func (widget *GetWidgetDb) GetMediaUrl(mediaType MediaType) MediaUrl {
|
|
// var mediaUrl MediaUrl
|
|
// if mediaType == "background_url" {
|
|
// mediaUrl = widget.Background
|
|
// } else if mediaType == "image_url" {
|
|
// mediaUrl = widget.Image
|
|
// } else if mediaType == "audio_url" {
|
|
// mediaUrl = widget.Audio
|
|
// }
|
|
// return mediaUrl
|
|
//}
|
|
//
|
|
//func (widget *GetWidgetDb) NormalizeUrl() {
|
|
// selfDomain := "http://localhost:8002/api/widget/media"
|
|
// strWidgetID := strconv.Itoa(int(widget.ID))
|
|
// if !strings.Contains(string(widget.ImageUrl), "http") && widget.ImageUrl != "" {
|
|
// widget.ImageUrl = MediaUrl(selfDomain + "/image/get/" + strWidgetID)
|
|
// }
|
|
//
|
|
// if !strings.Contains(string(widget.BackgroundUrl), "http") && widget.BackgroundUrl != "" {
|
|
// widget.BackgroundUrl = MediaUrl(selfDomain + "/background/get/" + strWidgetID)
|
|
// }
|
|
//
|
|
// if !strings.Contains(string(widget.AudioUrl), "http") && widget.AudioUrl != "" {
|
|
// widget.AudioUrl = MediaUrl(selfDomain + "/audio/get/" + strWidgetID)
|
|
// }
|
|
//}
|