2025-03-06 21:20:17 +05:00

249 lines
9.5 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"`
StreamerID int `db:"streamer_id"`
Description string `db:"description"`
TextAfterDonat string `db:"text_after_donat"`
HeadImg string `db:"head_img"`
Avatar string `db:"avatar"`
BackgroundImg string `db:"background_img"`
StreamerLogin string `db:"streamer_login"`
}
type Moderation struct {
ID int `db:"id"`
StreamerID int `db:"streamer_id"`
Enable bool `db:"enable"`
Duration int `db:"duration"`
}
type InnerDonatePageResponse struct {
Description string `json:"description"`
TextAfterDonat string `json:"text_after_donat"`
HeadImg string `json:"head_img"`
Avatar string `json:"avatar"`
BackgroundImg string `json:"background_img"`
}
type OuterDonatePageResponse struct {
Login string `json:"login"`
OnLine string `json:"online"`
Description string `json:"description"`
BackgroundImg string `json:"background_img"`
AvatarImg string `json:"avatar_img"`
HeadImg string `json:"head_img"`
}
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 Language struct {
ID int `db:"id"`
IsoCode string `db:"iso_code"`
RuName string `db:"ru_name"`
EnName string `db:"en_name"`
}
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"`
Description string `json:"description"`
TextAfterDonat string `json:"text_after_donat"`
PageBackground string `json:"page_background"`
}
type VoiceSettingsResponse struct {
VoiceSpeed int `json:"voice_speed"`
Scenery string `json:"scenery"`
VoiceSoundPercent int `json:"voice_sound_percent"`
MinPrice int `json:"min_price"`
}
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"`
}
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)
// }
//}