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 // @Accept json
// @Produce json // @Produce json
// @Security BearerAuth // @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 400 {object} echo.HTTPError "Bad request"
// @Failure 401 {object} echo.HTTPError "Unauthorized or expired token" // @Failure 401 {object} echo.HTTPError "Unauthorized or expired token"
// @Failure 422 {object} echo.HTTPError "Validation error" // @Failure 422 {object} echo.HTTPError "Validation error"

View File

@ -153,7 +153,7 @@ const docTemplate = `{
"summary": "Get a file", "summary": "Get a file",
"parameters": [ "parameters": [
{ {
"type": "string", "type": "integer",
"description": "File ID", "description": "File ID",
"name": "file_id", "name": "file_id",
"in": "path", "in": "path",
@ -578,9 +578,12 @@ const docTemplate = `{
"summary": "Get all streamer's widgets", "summary": "Get all streamer's widgets",
"responses": { "responses": {
"200": { "200": {
"description": "GetWidgetDb has been created successfully!", "description": "Success widgets response",
"schema": { "schema": {
"type": "string" "type": "array",
"items": {
"$ref": "#/definitions/donat-widget_internal_model.GetWidgetDb"
}
} }
}, },
"400": { "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": { "donat-widget_internal_model.InnerDonatePageResponse": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -146,7 +146,7 @@
"summary": "Get a file", "summary": "Get a file",
"parameters": [ "parameters": [
{ {
"type": "string", "type": "integer",
"description": "File ID", "description": "File ID",
"name": "file_id", "name": "file_id",
"in": "path", "in": "path",
@ -571,9 +571,12 @@
"summary": "Get all streamer's widgets", "summary": "Get all streamer's widgets",
"responses": { "responses": {
"200": { "200": {
"description": "GetWidgetDb has been created successfully!", "description": "Success widgets response",
"schema": { "schema": {
"type": "string" "type": "array",
"items": {
"$ref": "#/definitions/donat-widget_internal_model.GetWidgetDb"
}
} }
}, },
"400": { "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": { "donat-widget_internal_model.InnerDonatePageResponse": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -43,6 +43,76 @@ definitions:
type: string type: string
type: array type: array
type: object 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: donat-widget_internal_model.InnerDonatePageResponse:
properties: properties:
avatar: avatar:
@ -231,7 +301,7 @@ paths:
in: path in: path
name: file_id name: file_id
required: true required: true
type: string type: integer
produces: produces:
- application/octet-stream - application/octet-stream
responses: responses:
@ -506,9 +576,11 @@ paths:
- application/json - application/json
responses: responses:
"200": "200":
description: GetWidgetDb has been created successfully! description: Success widgets response
schema: schema:
type: string items:
$ref: '#/definitions/donat-widget_internal_model.GetWidgetDb'
type: array
"400": "400":
description: Bad request description: Bad request
schema: schema:

View File

@ -6,27 +6,28 @@ import (
) )
type GetWidgetDb struct { type GetWidgetDb struct {
ID int `db:"id" json:"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"` 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"` TemplateID int `db:"template_id" json:"template_id" example:"5" format:"int64" description:"ID of the template"`
Duration int `db:"duration" json:"duration"` Duration int `db:"duration" json:"duration" example:"30" format:"int64" description:"Duration of the widget"`
MinAmount int `db:"min_amount" json:"min_amount"` MinAmount int `db:"min_amount" json:"min_amount" example:"100" format:"int64" description:"Minimum donation amount"`
MaxAmount int `db:"max_amount" json:"max_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"` 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"` 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"` 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"` 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"` 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"` ImageType string `db:"image_type" json:"image_type" example:"image/png" description:"Type of the image file"`
ImageLink string `json:"image_link"` 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"` 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"` 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"` AudioType string `db:"audio_type" json:"audio_type" example:"audio/mp3" description:"Type of the audio file"`
AudioLink string `json:"audio_link"` 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 { type WidgetWithFileLink struct {

View File

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