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)
|
||||
|
@ -257,6 +257,7 @@ type CreateWidgetBody struct {
|
||||
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,6 +37,7 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
volumePercent int,
|
||||
) (model.WidgetID, error) {
|
||||
args := pgx.NamedArgs{
|
||||
"streamer_id": streamerID,
|
||||
@ -48,6 +49,7 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
||||
"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