add fix for create widget
This commit is contained in:
parent
31a2d2ec58
commit
8e91a17177
@ -46,6 +46,7 @@ func CreateWidget(widgetService model.WidgetService) echo.HandlerFunc {
|
||||
body.Image,
|
||||
body.Audio,
|
||||
body.Name,
|
||||
body.IsActive,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
|
@ -993,6 +993,10 @@ const docTemplate = `{
|
||||
"format": "uuid",
|
||||
"example": "550e8400-e29b-41d4-a716-446655440000"
|
||||
},
|
||||
"is_active": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"max_amount": {
|
||||
"type": "integer",
|
||||
"example": 100
|
||||
|
@ -986,6 +986,10 @@
|
||||
"format": "uuid",
|
||||
"example": "550e8400-e29b-41d4-a716-446655440000"
|
||||
},
|
||||
"is_active": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"max_amount": {
|
||||
"type": "integer",
|
||||
"example": 100
|
||||
|
@ -24,6 +24,9 @@ definitions:
|
||||
example: 550e8400-e29b-41d4-a716-446655440000
|
||||
format: uuid
|
||||
type: string
|
||||
is_active:
|
||||
example: true
|
||||
type: boolean
|
||||
max_amount:
|
||||
example: 100
|
||||
type: integer
|
||||
|
@ -24,6 +24,7 @@ type WidgetService interface {
|
||||
image string,
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
) (WidgetID, error)
|
||||
GetWidgetsByStreamer(ctx context.Context, streamerID int) ([]*WidgetWithFileLink, error)
|
||||
UpdateWidget(ctx context.Context, updateWidget UpdateWidget, widgetID, accountID int) error
|
||||
@ -46,6 +47,7 @@ type WidgetRepo interface {
|
||||
image string,
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
) (WidgetID, error)
|
||||
CheckWidgetName(ctx context.Context, streamerID int, name string) (bool, error)
|
||||
GetWidgetsByStreamerID(ctx context.Context, streamerID int) ([]*GetWidgetDb, error)
|
||||
|
@ -236,6 +236,7 @@ type CreateWidgetResponse struct {
|
||||
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"`
|
||||
|
@ -36,6 +36,7 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
||||
image string,
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
) (model.WidgetID, error) {
|
||||
args := pgx.NamedArgs{
|
||||
"streamer_id": streamerID,
|
||||
@ -46,6 +47,7 @@ func (widgetRepo *RepoWidget) CreateWidget(
|
||||
"image": image,
|
||||
"audio": audio,
|
||||
"name": name,
|
||||
"is_active": isActive,
|
||||
}
|
||||
widgetID, err := widgetRepo.db.Insert(ctx, sql.CreateWidget, args)
|
||||
if err != nil {
|
||||
|
@ -41,6 +41,7 @@ func (widgetService *ServiceWidget) CreateWidget(
|
||||
image string,
|
||||
audio string,
|
||||
name string,
|
||||
isActive bool,
|
||||
) (model.WidgetID, error) {
|
||||
exists, err := widgetService.widgetRepo.CheckWidgetName(ctx, streamerID, name)
|
||||
if err != nil {
|
||||
@ -62,6 +63,7 @@ func (widgetService *ServiceWidget) CreateWidget(
|
||||
image,
|
||||
audio,
|
||||
name,
|
||||
isActive,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
|
Loading…
x
Reference in New Issue
Block a user