change post method
This commit is contained in:
parent
004701457c
commit
05e85e077d
@ -702,27 +702,23 @@ func GetDonatForPlaying(donatService model.DonatService) echo.HandlerFunc {
|
||||
// @Tags Donate
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param streamer-id query string true "Login стримера"
|
||||
// @Security BearerAuth
|
||||
// @Param request body model.UpdateLoginBody true "Update data"
|
||||
// @Success 200 {object} string "Successfully updated streamer login"
|
||||
// @Failure 400 {object} echo.HTTPError "Bad request"
|
||||
// @Failure 401 {object} echo.HTTPError "Unauthorized or expired token"
|
||||
// @Failure 500 {object} echo.HTTPError "Internal server error"
|
||||
// @Router /update-login-donate [patch]
|
||||
// @Router /update-login-donate [post]
|
||||
func UpdateLoginDonatePage(donatService model.DonatService) echo.HandlerFunc {
|
||||
return func(request echo.Context) error {
|
||||
ctx := context.Background()
|
||||
streamerLogin := request.QueryParam("streamer-id")
|
||||
if streamerLogin == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "streamer-id is required")
|
||||
}
|
||||
authData, err := donatService.CheckToken(request)
|
||||
if err != nil {
|
||||
slog.Error("Unauthorized")
|
||||
return echo.NewHTTPError(http.StatusUnauthorized, "Incorrect token")
|
||||
|
||||
var body model.UpdateLoginBody
|
||||
if err := validator.ParseAndValidate(&body, request); err != nil {
|
||||
slog.Error("Validation error", "error", err)
|
||||
return echo.NewHTTPError(http.StatusUnprocessableEntity, "Invalid request body")
|
||||
}
|
||||
|
||||
err = donatService.UpdateStreamerLogin(ctx, streamerLogin, authData.AccountID)
|
||||
err := donatService.UpdateStreamerLogin(ctx, body.Login, body.AccountID)
|
||||
if err != nil {
|
||||
slog.Error("Failed to update streamer login", "error", err)
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to update streamer login")
|
||||
|
@ -97,7 +97,7 @@ func IncludeDonatHandlers(
|
||||
server.PATCH(PREFIX+"/donat-moderate/:donat-id", ModerateDonat(donatService))
|
||||
|
||||
server.GET(PREFIX+"/get-donat-for-playing/:streamer-id", GetDonatForPlaying(donatService))
|
||||
server.PATCH(PREFIX+"/update-login-donate", UpdateLoginDonatePage(donatService))
|
||||
server.POST(PREFIX+"/update-login-donate", UpdateLoginDonatePage(donatService))
|
||||
}
|
||||
|
||||
func IncludeWidgetHandlers(
|
||||
|
@ -1087,12 +1087,7 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"/update-login-donate": {
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"post": {
|
||||
"description": "Updates the streamer login associated with the donate page",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@ -1106,11 +1101,13 @@ const docTemplate = `{
|
||||
"summary": "Update streamer login",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Login стримера",
|
||||
"name": "streamer-id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
"description": "Update data",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/donat-widget_internal_model.UpdateLoginBody"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@ -2062,6 +2059,17 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"donat-widget_internal_model.UpdateLoginBody": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"account_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"login": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"donat-widget_internal_model.UpdateModeration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -1080,12 +1080,7 @@
|
||||
}
|
||||
},
|
||||
"/update-login-donate": {
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"post": {
|
||||
"description": "Updates the streamer login associated with the donate page",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@ -1099,11 +1094,13 @@
|
||||
"summary": "Update streamer login",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Login стримера",
|
||||
"name": "streamer-id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
"description": "Update data",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/donat-widget_internal_model.UpdateLoginBody"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@ -2055,6 +2052,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"donat-widget_internal_model.UpdateLoginBody": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"account_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"login": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"donat-widget_internal_model.UpdateModeration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -420,6 +420,13 @@ definitions:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
donat-widget_internal_model.UpdateLoginBody:
|
||||
properties:
|
||||
account_id:
|
||||
type: integer
|
||||
login:
|
||||
type: string
|
||||
type: object
|
||||
donat-widget_internal_model.UpdateModeration:
|
||||
properties:
|
||||
duration:
|
||||
@ -1212,16 +1219,17 @@ paths:
|
||||
tags:
|
||||
- Donate
|
||||
/update-login-donate:
|
||||
patch:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Updates the streamer login associated with the donate page
|
||||
parameters:
|
||||
- description: Login стримера
|
||||
in: query
|
||||
name: streamer-id
|
||||
- description: Update data
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
type: string
|
||||
schema:
|
||||
$ref: '#/definitions/donat-widget_internal_model.UpdateLoginBody'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@ -1241,8 +1249,6 @@ paths:
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/echo.HTTPError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update streamer login
|
||||
tags:
|
||||
- Donate
|
||||
|
@ -333,3 +333,8 @@ type PlayingDonat struct {
|
||||
Amount int `json:"amount"`
|
||||
OrderID string `json:"order_id"`
|
||||
}
|
||||
|
||||
type UpdateLoginBody struct {
|
||||
AccountID int `json:"account_id"`
|
||||
Login string `json:"login"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user