add volume percent for create new widget
This commit is contained in:
parent
db55335add
commit
c33fa8a4f4
@ -48,6 +48,7 @@ func CreateWidget(widgetService model.WidgetService) echo.HandlerFunc {
|
||||
body.Audio,
|
||||
body.Name,
|
||||
body.IsActive,
|
||||
body.VolumePercent,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
|
@ -26,6 +26,7 @@ type WidgetService interface {
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
volumePercent int,
|
||||
) (GetWidgetDb, error)
|
||||
GetWidgetsByStreamer(ctx context.Context, streamerID int) (AllWidgets, error)
|
||||
UpdateWidget(ctx context.Context, updateWidget UpdateWidget, widgetID, accountID int) error
|
||||
@ -45,6 +46,7 @@ type WidgetRepo interface {
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
volumePercent int,
|
||||
) (WidgetID, error)
|
||||
CheckWidgetName(ctx context.Context, streamerID int, name string) (bool, error)
|
||||
GetWidgetsByStreamerID(ctx context.Context, streamerID int) ([]*GetWidgetDb, error)
|
||||
|
@ -249,14 +249,15 @@ type CreateWidgetResponse struct {
|
||||
|
||||
// CreateWidgetBody структура для создания виджета
|
||||
type CreateWidgetBody struct {
|
||||
TemplateID int `json:"template_id" validate:"required" example:"1"`
|
||||
Duration int `json:"duration" validate:"required" example:"30"`
|
||||
IsActive bool `json:"is_active" example:"true"`
|
||||
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"`
|
||||
TemplateID int `json:"template_id" validate:"required" example:"1"`
|
||||
Duration int `json:"duration" validate:"required" example:"30"`
|
||||
IsActive bool `json:"is_active" example:"true"`
|
||||
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"`
|
||||
VolumePercent int `json:"volume_percent" example:"50" description:"Volume percentage of the widget"`
|
||||
}
|
||||
|
||||
type DonatAndWidget struct {
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
)
|
||||
|
||||
var CreateWidget = `
|
||||
INSERT INTO widgets (streamer_id, template_id, image, audio, duration, min_amount, max_amount, name)
|
||||
VALUES (@streamer_id, @template_id, @image, @audio, @duration, @min_amount, @max_amount, @name)
|
||||
INSERT INTO widgets (streamer_id, template_id, image, audio, duration, min_amount, max_amount, name, volume_percent)
|
||||
VALUES (@streamer_id, @template_id, @image, @audio, @duration, @min_amount, @max_amount, @name, @volume_percent)
|
||||
RETURNING id;
|
||||
`
|
||||
|
||||
|
@ -37,17 +37,19 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
volumePercent int,
|
||||
) (model.WidgetID, error) {
|
||||
args := pgx.NamedArgs{
|
||||
"streamer_id": streamerID,
|
||||
"template_id": templateID,
|
||||
"duration": duration,
|
||||
"min_amount": minAmount,
|
||||
"max_amount": maxAmount,
|
||||
"image": image,
|
||||
"audio": audio,
|
||||
"name": name,
|
||||
"is_active": isActive,
|
||||
"streamer_id": streamerID,
|
||||
"template_id": templateID,
|
||||
"duration": duration,
|
||||
"min_amount": minAmount,
|
||||
"max_amount": maxAmount,
|
||||
"image": image,
|
||||
"audio": audio,
|
||||
"name": name,
|
||||
"is_active": isActive,
|
||||
"volume_percent": volumePercent,
|
||||
}
|
||||
widgetID, err := widgetRepo.db.Insert(ctx, sql.CreateWidget, args)
|
||||
if err != nil {
|
||||
|
@ -49,6 +49,7 @@ func (widgetService *ServiceWidget) CreateWidget(
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
volumePercent int,
|
||||
) (model.GetWidgetDb, error) {
|
||||
exists, err := widgetService.widgetRepo.CheckWidgetName(ctx, streamerID, name)
|
||||
if err != nil {
|
||||
@ -70,6 +71,7 @@ func (widgetService *ServiceWidget) CreateWidget(
|
||||
audio,
|
||||
name,
|
||||
isActive,
|
||||
volumePercent,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
|
Loading…
x
Reference in New Issue
Block a user