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.Audio,
|
||||||
body.Name,
|
body.Name,
|
||||||
body.IsActive,
|
body.IsActive,
|
||||||
|
body.VolumePercent,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(err.Error())
|
slog.Error(err.Error())
|
||||||
|
@ -26,6 +26,7 @@ type WidgetService interface {
|
|||||||
audio string,
|
audio string,
|
||||||
name string,
|
name string,
|
||||||
isActive bool,
|
isActive bool,
|
||||||
|
volumePercent int,
|
||||||
) (GetWidgetDb, error)
|
) (GetWidgetDb, error)
|
||||||
GetWidgetsByStreamer(ctx context.Context, streamerID int) (AllWidgets, error)
|
GetWidgetsByStreamer(ctx context.Context, streamerID int) (AllWidgets, error)
|
||||||
UpdateWidget(ctx context.Context, updateWidget UpdateWidget, widgetID, accountID int) error
|
UpdateWidget(ctx context.Context, updateWidget UpdateWidget, widgetID, accountID int) error
|
||||||
@ -45,6 +46,7 @@ type WidgetRepo interface {
|
|||||||
audio string,
|
audio string,
|
||||||
name string,
|
name string,
|
||||||
isActive bool,
|
isActive bool,
|
||||||
|
volumePercent int,
|
||||||
) (WidgetID, error)
|
) (WidgetID, error)
|
||||||
CheckWidgetName(ctx context.Context, streamerID int, name string) (bool, error)
|
CheckWidgetName(ctx context.Context, streamerID int, name string) (bool, error)
|
||||||
GetWidgetsByStreamerID(ctx context.Context, streamerID int) ([]*GetWidgetDb, error)
|
GetWidgetsByStreamerID(ctx context.Context, streamerID int) ([]*GetWidgetDb, error)
|
||||||
|
@ -249,14 +249,15 @@ type CreateWidgetResponse struct {
|
|||||||
|
|
||||||
// CreateWidgetBody структура для создания виджета
|
// CreateWidgetBody структура для создания виджета
|
||||||
type CreateWidgetBody struct {
|
type CreateWidgetBody struct {
|
||||||
TemplateID int `json:"template_id" validate:"required" example:"1"`
|
TemplateID int `json:"template_id" validate:"required" example:"1"`
|
||||||
Duration int `json:"duration" validate:"required" example:"30"`
|
Duration int `json:"duration" validate:"required" example:"30"`
|
||||||
IsActive bool `json:"is_active" example:"true"`
|
IsActive bool `json:"is_active" example:"true"`
|
||||||
Name string `json:"name" validate:"required" example:"My GetWidgetDb"`
|
Name string `json:"name" validate:"required" example:"My GetWidgetDb"`
|
||||||
Image string `json:"image" validate:"required" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440000"`
|
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"`
|
Audio string `json:"audio" validate:"required" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440001"`
|
||||||
MinAmount int `json:"min_amount" validate:"required" example:"10"`
|
MinAmount int `json:"min_amount" validate:"required" example:"10"`
|
||||||
MaxAmount int `json:"max_amount" validate:"required" example:"100"`
|
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 {
|
type DonatAndWidget struct {
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var CreateWidget = `
|
var CreateWidget = `
|
||||||
INSERT INTO widgets (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)
|
VALUES (@streamer_id, @template_id, @image, @audio, @duration, @min_amount, @max_amount, @name, @volume_percent)
|
||||||
RETURNING id;
|
RETURNING id;
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -37,17 +37,19 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
|||||||
audio string,
|
audio string,
|
||||||
name string,
|
name string,
|
||||||
isActive bool,
|
isActive bool,
|
||||||
|
volumePercent int,
|
||||||
) (model.WidgetID, error) {
|
) (model.WidgetID, error) {
|
||||||
args := pgx.NamedArgs{
|
args := pgx.NamedArgs{
|
||||||
"streamer_id": streamerID,
|
"streamer_id": streamerID,
|
||||||
"template_id": templateID,
|
"template_id": templateID,
|
||||||
"duration": duration,
|
"duration": duration,
|
||||||
"min_amount": minAmount,
|
"min_amount": minAmount,
|
||||||
"max_amount": maxAmount,
|
"max_amount": maxAmount,
|
||||||
"image": image,
|
"image": image,
|
||||||
"audio": audio,
|
"audio": audio,
|
||||||
"name": name,
|
"name": name,
|
||||||
"is_active": isActive,
|
"is_active": isActive,
|
||||||
|
"volume_percent": volumePercent,
|
||||||
}
|
}
|
||||||
widgetID, err := widgetRepo.db.Insert(ctx, sql.CreateWidget, args)
|
widgetID, err := widgetRepo.db.Insert(ctx, sql.CreateWidget, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -49,6 +49,7 @@ func (widgetService *ServiceWidget) CreateWidget(
|
|||||||
audio string,
|
audio string,
|
||||||
name string,
|
name string,
|
||||||
isActive bool,
|
isActive bool,
|
||||||
|
volumePercent int,
|
||||||
) (model.GetWidgetDb, error) {
|
) (model.GetWidgetDb, error) {
|
||||||
exists, err := widgetService.widgetRepo.CheckWidgetName(ctx, streamerID, name)
|
exists, err := widgetService.widgetRepo.CheckWidgetName(ctx, streamerID, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,6 +71,7 @@ func (widgetService *ServiceWidget) CreateWidget(
|
|||||||
audio,
|
audio,
|
||||||
name,
|
name,
|
||||||
isActive,
|
isActive,
|
||||||
|
volumePercent,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(err.Error())
|
slog.Error(err.Error())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user