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