diff --git a/internal/docs/docs.go b/internal/docs/docs.go index 11e77d9..2429059 100644 --- a/internal/docs/docs.go +++ b/internal/docs/docs.go @@ -1002,19 +1002,24 @@ const docTemplate = `{ "type": "object", "properties": { "file_id": { - "type": "string" + "type": "string", + "example": "550e8400-e29b-41d4-a716-446655440000" }, "file_link": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" }, "file_name": { - "type": "string" + "type": "string", + "example": "header.png" }, "file_size": { - "type": "integer" + "type": "integer", + "example": 1024 }, "file_type": { - "type": "string" + "type": "string", + "example": "image/png" } } }, @@ -1033,22 +1038,28 @@ const docTemplate = `{ "type": "object", "properties": { "avatar_img": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/avatar.png" }, "background_img": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/background.png" }, "description": { - "type": "string" + "type": "string", + "example": "Поддержи этого стримера" }, "head_img": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/header.png" }, "login": { - "type": "string" + "type": "string", + "example": "streamer123" }, "online": { - "type": "string" + "type": "string", + "example": "online" } } }, diff --git a/internal/docs/swagger.json b/internal/docs/swagger.json index a46684d..f22d563 100644 --- a/internal/docs/swagger.json +++ b/internal/docs/swagger.json @@ -995,19 +995,24 @@ "type": "object", "properties": { "file_id": { - "type": "string" + "type": "string", + "example": "550e8400-e29b-41d4-a716-446655440000" }, "file_link": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" }, "file_name": { - "type": "string" + "type": "string", + "example": "header.png" }, "file_size": { - "type": "integer" + "type": "integer", + "example": 1024 }, "file_type": { - "type": "string" + "type": "string", + "example": "image/png" } } }, @@ -1026,22 +1031,28 @@ "type": "object", "properties": { "avatar_img": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/avatar.png" }, "background_img": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/background.png" }, "description": { - "type": "string" + "type": "string", + "example": "Поддержи этого стримера" }, "head_img": { - "type": "string" + "type": "string", + "example": "https://cdn.example.com/images/header.png" }, "login": { - "type": "string" + "type": "string", + "example": "streamer123" }, "online": { - "type": "string" + "type": "string", + "example": "online" } } }, diff --git a/internal/docs/swagger.yaml b/internal/docs/swagger.yaml index 0c4f7a3..383ad68 100644 --- a/internal/docs/swagger.yaml +++ b/internal/docs/swagger.yaml @@ -150,14 +150,19 @@ definitions: donat-widget_internal_model.InnerFile: properties: file_id: + example: 550e8400-e29b-41d4-a716-446655440000 type: string file_link: + example: https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000 type: string file_name: + example: header.png type: string file_size: + example: 1024 type: integer file_type: + example: image/png type: string type: object donat-widget_internal_model.ModerationResponse: @@ -170,16 +175,22 @@ definitions: donat-widget_internal_model.OuterDonatePageResponse: properties: avatar_img: + example: https://cdn.example.com/images/avatar.png type: string background_img: + example: https://cdn.example.com/images/background.png type: string description: + example: Поддержи этого стримера type: string head_img: + example: https://cdn.example.com/images/header.png type: string login: + example: streamer123 type: string online: + example: online type: string type: object donat-widget_internal_model.UpdateFilterSettings: diff --git a/internal/model/models.go b/internal/model/models.go index 38ec2aa..df7c1cd 100644 --- a/internal/model/models.go +++ b/internal/model/models.go @@ -118,11 +118,11 @@ type DonatePage struct { } type InnerFile struct { - FileID uuid.UUID `json:"file_id"` - FileName string `json:"file_name"` - FileType string `json:"file_type"` - FileLink string `json:"file_link"` - FileSize int `json:"file_size"` + FileID uuid.UUID `json:"file_id" example:"550e8400-e29b-41d4-a716-446655440000" description:"UUID файла"` + FileName string `json:"file_name" example:"header.png" description:"Имя файла"` + FileType string `json:"file_type" example:"image/png" description:"Тип файла"` + FileLink string `json:"file_link" example:"https://cdn.example.com/images/550e8400-e29b-41d4-a716-446655440000" description:"Публичный URL файла"` + FileSize int `json:"file_size" example:"1024" description:"Размер файла в байтах"` } type InnerDonatePageResponse struct { @@ -141,12 +141,12 @@ type Moderation struct { } type OuterDonatePageResponse struct { - Login string `json:"login"` - OnLine string `json:"online"` - Description string `json:"description"` - BackgroundImg string `json:"background_img"` - AvatarImg string `json:"avatar_img"` - HeadImg string `json:"head_img"` + Login string `json:"login" example:"streamer123" description:"Логин или псевдоним стримера"` + OnLine string `json:"online" example:"online" description:"Статус стримера (online/offline)"` + Description string `json:"description" example:"Поддержи этого стримера" description:"Описание страницы доната"` + BackgroundImg string `json:"background_img" example:"https://cdn.example.com/images/background.png" description:"Ссылка на фоновое изображение"` + AvatarImg string `json:"avatar_img" example:"https://cdn.example.com/images/avatar.png" description:"Ссылка на аватар"` + HeadImg string `json:"head_img" example:"https://cdn.example.com/images/header.png" description:"Ссылка на хед-изображение"` } type Filter struct { diff --git a/internal/model/sql/query.go b/internal/model/sql/query.go index 75ed796..7fc51d1 100644 --- a/internal/model/sql/query.go +++ b/internal/model/sql/query.go @@ -117,7 +117,36 @@ WHERE dp.streamer_id = (@streamer_id); ` var GetDonationPageByLogin = ` -SELECT * FROM donate_pages WHERE streamer_login = (@streamer_login); +SELECT + dp.id, + dp.streamer_id, + dp.description, + dp.text_after_donat, + dp.streamer_login, + + -- Поля для хед-изображения + head_img.id AS head_img_id, + head_img.file_name AS head_img_file_name, + head_img.file_type AS head_img_type, + head_img.size AS head_img_size, + + -- Поля для аватара + avatar.id AS avatar_id, + avatar.file_name AS avatar_file_name, + avatar.file_type AS avatar_type, + avatar.size AS avatar_img_size, + + -- Поля для фона + background_img.id AS background_img_id, + background_img.file_name AS background_img_file_name, + background_img.file_type AS background_img_type, + background_img.size AS background_img_size + +FROM donate_pages dp +LEFT JOIN files head_img ON dp.head_img = head_img.id +LEFT JOIN files avatar ON dp.avatar = avatar.id +LEFT JOIN files background_img ON dp.background_img = background_img.id +WHERE dp.streamer_login = (@streamer_login); ` var GetWidgetsByStreamerID = `