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)
|
||||||
|
@ -257,6 +257,7 @@ type CreateWidgetBody struct {
|
|||||||
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,6 +37,7 @@ 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,
|
||||||
@ -48,6 +49,7 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
|||||||
"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