add fixes for docs in get all streamers widgets

This commit is contained in:
harold 2025-03-06 14:02:08 +05:00
parent d6d6ce73dc
commit 131acf7182
6 changed files with 287 additions and 27 deletions

View File

@ -66,7 +66,7 @@ func CreateWidget(widgetService model.WidgetService) echo.HandlerFunc {
// @Accept json
// @Produce json
// @Security BearerAuth
// @Success 200 {string} string "GetWidgetDb has been created successfully!"
// @Success 200 {array} model.GetWidgetDb "Success widgets response"
// @Failure 400 {object} echo.HTTPError "Bad request"
// @Failure 401 {object} echo.HTTPError "Unauthorized or expired token"
// @Failure 422 {object} echo.HTTPError "Validation error"

View File

@ -153,7 +153,7 @@ const docTemplate = `{
"summary": "Get a file",
"parameters": [
{
"type": "string",
"type": "integer",
"description": "File ID",
"name": "file_id",
"in": "path",
@ -578,9 +578,12 @@ const docTemplate = `{
"summary": "Get all streamer's widgets",
"responses": {
"200": {
"description": "GetWidgetDb has been created successfully!",
"description": "Success widgets response",
"schema": {
"type": "string"
"type": "array",
"items": {
"$ref": "#/definitions/donat-widget_internal_model.GetWidgetDb"
}
}
},
"400": {
@ -719,6 +722,96 @@ const docTemplate = `{
}
}
},
"donat-widget_internal_model.GetWidgetDb": {
"type": "object",
"properties": {
"audio_file_name": {
"type": "string",
"example": "alert.mp3"
},
"audio_id": {
"description": "Поля для аудио",
"type": "string",
"format": "uuid",
"example": "123e4567-e89b-12d3-a456-426614174000"
},
"audio_link": {
"type": "string",
"example": "https://cdn.example.com/audio/123e4567-e89b-12d3-a456-426614174000"
},
"audio_type": {
"type": "string",
"example": "audio/mp3"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2025-03-06T13:37:36Z"
},
"duration": {
"type": "integer",
"format": "int64",
"example": 30
},
"group_id": {
"type": "integer",
"format": "int64",
"example": 2
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"image_file_name": {
"type": "string",
"example": "background.png"
},
"image_id": {
"description": "Поля для изображения",
"type": "string",
"format": "uuid",
"example": "550e8400-e29b-41d4-a716-446655440000"
},
"image_link": {
"type": "string",
"example": "https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000"
},
"image_type": {
"type": "string",
"example": "image/png"
},
"is_active": {
"type": "boolean",
"example": true
},
"max_amount": {
"type": "integer",
"format": "int64",
"example": 1000
},
"min_amount": {
"type": "integer",
"format": "int64",
"example": 100
},
"streamer_id": {
"type": "integer",
"format": "int64",
"example": 1001
},
"template_id": {
"type": "integer",
"format": "int64",
"example": 5
},
"updated_at": {
"type": "string",
"format": "date-time",
"example": "2025-03-07T10:15:30Z"
}
}
},
"donat-widget_internal_model.InnerDonatePageResponse": {
"type": "object",
"properties": {

View File

@ -146,7 +146,7 @@
"summary": "Get a file",
"parameters": [
{
"type": "string",
"type": "integer",
"description": "File ID",
"name": "file_id",
"in": "path",
@ -571,9 +571,12 @@
"summary": "Get all streamer's widgets",
"responses": {
"200": {
"description": "GetWidgetDb has been created successfully!",
"description": "Success widgets response",
"schema": {
"type": "string"
"type": "array",
"items": {
"$ref": "#/definitions/donat-widget_internal_model.GetWidgetDb"
}
}
},
"400": {
@ -712,6 +715,96 @@
}
}
},
"donat-widget_internal_model.GetWidgetDb": {
"type": "object",
"properties": {
"audio_file_name": {
"type": "string",
"example": "alert.mp3"
},
"audio_id": {
"description": "Поля для аудио",
"type": "string",
"format": "uuid",
"example": "123e4567-e89b-12d3-a456-426614174000"
},
"audio_link": {
"type": "string",
"example": "https://cdn.example.com/audio/123e4567-e89b-12d3-a456-426614174000"
},
"audio_type": {
"type": "string",
"example": "audio/mp3"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2025-03-06T13:37:36Z"
},
"duration": {
"type": "integer",
"format": "int64",
"example": 30
},
"group_id": {
"type": "integer",
"format": "int64",
"example": 2
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"image_file_name": {
"type": "string",
"example": "background.png"
},
"image_id": {
"description": "Поля для изображения",
"type": "string",
"format": "uuid",
"example": "550e8400-e29b-41d4-a716-446655440000"
},
"image_link": {
"type": "string",
"example": "https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000"
},
"image_type": {
"type": "string",
"example": "image/png"
},
"is_active": {
"type": "boolean",
"example": true
},
"max_amount": {
"type": "integer",
"format": "int64",
"example": 1000
},
"min_amount": {
"type": "integer",
"format": "int64",
"example": 100
},
"streamer_id": {
"type": "integer",
"format": "int64",
"example": 1001
},
"template_id": {
"type": "integer",
"format": "int64",
"example": 5
},
"updated_at": {
"type": "string",
"format": "date-time",
"example": "2025-03-07T10:15:30Z"
}
}
},
"donat-widget_internal_model.InnerDonatePageResponse": {
"type": "object",
"properties": {

View File

@ -43,6 +43,76 @@ definitions:
type: string
type: array
type: object
donat-widget_internal_model.GetWidgetDb:
properties:
audio_file_name:
example: alert.mp3
type: string
audio_id:
description: Поля для аудио
example: 123e4567-e89b-12d3-a456-426614174000
format: uuid
type: string
audio_link:
example: https://cdn.example.com/audio/123e4567-e89b-12d3-a456-426614174000
type: string
audio_type:
example: audio/mp3
type: string
created_at:
example: "2025-03-06T13:37:36Z"
format: date-time
type: string
duration:
example: 30
format: int64
type: integer
group_id:
example: 2
format: int64
type: integer
id:
example: 1
format: int64
type: integer
image_file_name:
example: background.png
type: string
image_id:
description: Поля для изображения
example: 550e8400-e29b-41d4-a716-446655440000
format: uuid
type: string
image_link:
example: https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000
type: string
image_type:
example: image/png
type: string
is_active:
example: true
type: boolean
max_amount:
example: 1000
format: int64
type: integer
min_amount:
example: 100
format: int64
type: integer
streamer_id:
example: 1001
format: int64
type: integer
template_id:
example: 5
format: int64
type: integer
updated_at:
example: "2025-03-07T10:15:30Z"
format: date-time
type: string
type: object
donat-widget_internal_model.InnerDonatePageResponse:
properties:
avatar:
@ -231,7 +301,7 @@ paths:
in: path
name: file_id
required: true
type: string
type: integer
produces:
- application/octet-stream
responses:
@ -506,9 +576,11 @@ paths:
- application/json
responses:
"200":
description: GetWidgetDb has been created successfully!
description: Success widgets response
schema:
type: string
items:
$ref: '#/definitions/donat-widget_internal_model.GetWidgetDb'
type: array
"400":
description: Bad request
schema:

View File

@ -6,27 +6,28 @@ import (
)
type GetWidgetDb struct {
ID int `db:"id" json:"id"`
StreamerID int `db:"streamer_id" json:"streamer_id"`
TemplateID int `db:"template_id" json:"template_id"`
Duration int `db:"duration" json:"duration"`
MinAmount int `db:"min_amount" json:"min_amount"`
MaxAmount int `db:"max_amount" json:"max_amount"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
GroupID int `db:"group_id" json:"group_id"`
ID int `db:"id" json:"id" example:"1" format:"int64" description:"Unique identifier of the widget"`
StreamerID int `db:"streamer_id" json:"streamer_id" example:"1001" format:"int64" description:"ID of the streamer"`
TemplateID int `db:"template_id" json:"template_id" example:"5" format:"int64" description:"ID of the template"`
Duration int `db:"duration" json:"duration" example:"30" format:"int64" description:"Duration of the widget"`
MinAmount int `db:"min_amount" json:"min_amount" example:"100" format:"int64" description:"Minimum donation amount"`
MaxAmount int `db:"max_amount" json:"max_amount" example:"1000" format:"int64" description:"Maximum donation amount"`
CreatedAt time.Time `db:"created_at" json:"created_at" format:"date-time" example:"2025-03-06T13:37:36Z" description:"Timestamp when the widget was created"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at" format:"date-time" example:"2025-03-07T10:15:30Z" description:"Timestamp when the widget was last updated"`
GroupID int `db:"group_id" json:"group_id" example:"2" format:"int64" description:"Group ID associated with the widget"`
IsActive bool `db:"is_active" json:"is_active" example:"true" description:"Whether or not this widget is active"`
// Поля для изображения
ImageFileId uuid.UUID `db:"image_id" json:"image_id"`
ImageFileName string `db:"image_file_name" json:"image_file_name"`
ImageType string `db:"image_type" json:"image_type"`
ImageLink string `json:"image_link"`
ImageFileId uuid.UUID `db:"image_id" json:"image_id" format:"uuid" example:"550e8400-e29b-41d4-a716-446655440000" description:"UUID of the image file"`
ImageFileName string `db:"image_file_name" json:"image_file_name" example:"background.png" description:"Name of the image file"`
ImageType string `db:"image_type" json:"image_type" example:"image/png" description:"Type of the image file"`
ImageLink string `json:"image_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" description:"Public URL of the image"`
// Поля для аудио
AudioFileId uuid.UUID `db:"audio_id" json:"audio_id"`
AudioFileName string `db:"audio_file_name" json:"audio_file_name"`
AudioType string `db:"audio_type" json:"audio_type"`
AudioLink string `json:"audio_link"`
AudioFileId uuid.UUID `db:"audio_id" json:"audio_id" format:"uuid" example:"123e4567-e89b-12d3-a456-426614174000" description:"UUID of the audio file"`
AudioFileName string `db:"audio_file_name" json:"audio_file_name" example:"alert.mp3" description:"Name of the audio file"`
AudioType string `db:"audio_type" json:"audio_type" example:"audio/mp3" description:"Type of the audio file"`
AudioLink string `json:"audio_link" example:"https://cdn.example.com/audio/123e4567-e89b-12d3-a456-426614174000" description:"Public URL of the audio"`
}
type WidgetWithFileLink struct {

View File

@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS widgets (
streamer_id INTEGER NOT NULL,
template_id INTEGER,
group_id INTEGER NOT NULL DEFAULT 1,
is_active BOOLEAN NOT NULL DEFAULT "true",
name VARCHAR(50) NOT NULL,
image UUID REFERENCES files(id) NOT NULL ON DELETE CASCADE,