add router for get donat paid success message
This commit is contained in:
parent
d8f158b0c2
commit
cd52493f82
@ -6,6 +6,7 @@ import (
|
|||||||
_ "donat-widget/internal/model/api"
|
_ "donat-widget/internal/model/api"
|
||||||
"donat-widget/pkg/custom_response"
|
"donat-widget/pkg/custom_response"
|
||||||
"donat-widget/pkg/validator"
|
"donat-widget/pkg/validator"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@ -743,3 +744,42 @@ func UpdateLoginDonatePage(donatService model.DonatService) echo.HandlerFunc {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMessageAfterDonat godoc
|
||||||
|
// @Summary Get message after donat
|
||||||
|
// @Description Получает список донатов для указанного стримера с пагинацией
|
||||||
|
// @Tags Donate
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param order-id path string true "OrderID стримера"
|
||||||
|
// @Success 200 {object} model.TextAfterPaidDonat "Успешный возврат списка донатов"
|
||||||
|
// @Failure 400 {object} echo.HTTPError "Некорректный формат streamerID"
|
||||||
|
// @Failure 500 {object} echo.HTTPError "Внутренняя ошибка сервера"
|
||||||
|
// @Router /text-after-donat/{order-id} [get]
|
||||||
|
func GetMessageAfterDonat(donatService model.DonatService) echo.HandlerFunc {
|
||||||
|
return func(request echo.Context) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
orderId, err := uuid.Parse(request.Param("order-id"))
|
||||||
|
if err != nil {
|
||||||
|
return echo.NewHTTPError(http.StatusUnprocessableEntity, "Invalid order id")
|
||||||
|
}
|
||||||
|
|
||||||
|
textAfterDonat, err := donatService.GetTextAfterDonatByOrder(
|
||||||
|
ctx,
|
||||||
|
orderId,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error(err.Error())
|
||||||
|
if err.Error() == "not found" {
|
||||||
|
return echo.NewHTTPError(http.StatusNotFound, "Not found active paid donat ")
|
||||||
|
}
|
||||||
|
return request.JSON(http.StatusInternalServerError, err.Error())
|
||||||
|
}
|
||||||
|
textAfterDonatResp := model.TextAfterPaidDonat{TextAfterDonat: textAfterDonat}
|
||||||
|
|
||||||
|
slog.Info("get text afetr donat successfully")
|
||||||
|
return request.JSON(200, textAfterDonatResp)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -105,6 +105,7 @@ func IncludeDonatHandlers(
|
|||||||
server.PATCH(PREFIX+"/donat-moderate/:donat-id", ModerateDonat(donatService))
|
server.PATCH(PREFIX+"/donat-moderate/:donat-id", ModerateDonat(donatService))
|
||||||
|
|
||||||
server.GET(PREFIX+"/get-donat-for-playing/:streamer-id", GetDonatForPlaying(donatService))
|
server.GET(PREFIX+"/get-donat-for-playing/:streamer-id", GetDonatForPlaying(donatService))
|
||||||
|
server.GET(PREFIX+"/text-after-donat/:order-id", GetMessageAfterDonat(donatService))
|
||||||
server.POST(PREFIX+"/update-login-donate", UpdateLoginDonatePage(donatService))
|
server.POST(PREFIX+"/update-login-donate", UpdateLoginDonatePage(donatService))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,6 +1105,50 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/text-after-donat/{order-id}": {
|
||||||
|
"get": {
|
||||||
|
"description": "Получает список донатов для указанного стримера с пагинацией",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Donate"
|
||||||
|
],
|
||||||
|
"summary": "Get message after donat",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OrderID стримера",
|
||||||
|
"name": "order-id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Успешный возврат списка донатов",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/donat-widget_internal_model.TextAfterPaidDonat"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Некорректный формат streamerID",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/echo.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Внутренняя ошибка сервера",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/echo.HTTPError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/update-login-donate": {
|
"/update-login-donate": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Updates the streamer login associated with the donate page",
|
"description": "Updates the streamer login associated with the donate page",
|
||||||
@ -2108,6 +2152,14 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"donat-widget_internal_model.TextAfterPaidDonat": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"text_after_donat": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"donat-widget_internal_model.UpdateFilterSettings": {
|
"donat-widget_internal_model.UpdateFilterSettings": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -1098,6 +1098,50 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/text-after-donat/{order-id}": {
|
||||||
|
"get": {
|
||||||
|
"description": "Получает список донатов для указанного стримера с пагинацией",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Donate"
|
||||||
|
],
|
||||||
|
"summary": "Get message after donat",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OrderID стримера",
|
||||||
|
"name": "order-id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Успешный возврат списка донатов",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/donat-widget_internal_model.TextAfterPaidDonat"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Некорректный формат streamerID",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/echo.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Внутренняя ошибка сервера",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/echo.HTTPError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/update-login-donate": {
|
"/update-login-donate": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Updates the streamer login associated with the donate page",
|
"description": "Updates the streamer login associated with the donate page",
|
||||||
@ -2101,6 +2145,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"donat-widget_internal_model.TextAfterPaidDonat": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"text_after_donat": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"donat-widget_internal_model.UpdateFilterSettings": {
|
"donat-widget_internal_model.UpdateFilterSettings": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -441,6 +441,11 @@ definitions:
|
|||||||
description: Добавляем новые поля для настроек голоса
|
description: Добавляем новые поля для настроек голоса
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
donat-widget_internal_model.TextAfterPaidDonat:
|
||||||
|
properties:
|
||||||
|
text_after_donat:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
donat-widget_internal_model.UpdateFilterSettings:
|
donat-widget_internal_model.UpdateFilterSettings:
|
||||||
properties:
|
properties:
|
||||||
add_words:
|
add_words:
|
||||||
@ -1260,6 +1265,35 @@ paths:
|
|||||||
summary: Get outer donate page info
|
summary: Get outer donate page info
|
||||||
tags:
|
tags:
|
||||||
- Donate
|
- Donate
|
||||||
|
/text-after-donat/{order-id}:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Получает список донатов для указанного стримера с пагинацией
|
||||||
|
parameters:
|
||||||
|
- description: OrderID стримера
|
||||||
|
in: path
|
||||||
|
name: order-id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Успешный возврат списка донатов
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/donat-widget_internal_model.TextAfterPaidDonat'
|
||||||
|
"400":
|
||||||
|
description: Некорректный формат streamerID
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/echo.HTTPError'
|
||||||
|
"500":
|
||||||
|
description: Внутренняя ошибка сервера
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/echo.HTTPError'
|
||||||
|
summary: Get message after donat
|
||||||
|
tags:
|
||||||
|
- Donate
|
||||||
/update-login-donate:
|
/update-login-donate:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
|
@ -107,6 +107,7 @@ type DonatService interface {
|
|||||||
GetPlayingDonat(ctx context.Context, streamerID int) (PlayingDonatResponse, error)
|
GetPlayingDonat(ctx context.Context, streamerID int) (PlayingDonatResponse, error)
|
||||||
UpdateStreamerLogin(ctx context.Context, streamerLogin string, streamerID int) error
|
UpdateStreamerLogin(ctx context.Context, streamerLogin string, streamerID int) error
|
||||||
UpdateAvatarStreamer(token, avatarId string) error
|
UpdateAvatarStreamer(token, avatarId string) error
|
||||||
|
GetTextAfterDonatByOrder(ctx context.Context, orderID uuid.UUID) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DonatRepo interface {
|
type DonatRepo interface {
|
||||||
|
@ -380,3 +380,7 @@ type CreateDonatResponse struct {
|
|||||||
PaymentUrl string `json:"payment_url"`
|
PaymentUrl string `json:"payment_url"`
|
||||||
OrderID uuid.UUID `json:"order_id"`
|
OrderID uuid.UUID `json:"order_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TextAfterPaidDonat struct {
|
||||||
|
TextAfterDonat string `json:"text_after_donat"`
|
||||||
|
}
|
||||||
|
@ -94,6 +94,7 @@ text,
|
|||||||
amount,
|
amount,
|
||||||
donat_user,
|
donat_user,
|
||||||
accepted_time,
|
accepted_time,
|
||||||
|
paid_time,
|
||||||
show_name,
|
show_name,
|
||||||
show_text,
|
show_text,
|
||||||
play_content,
|
play_content,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"donat-widget/internal/model"
|
"donat-widget/internal/model"
|
||||||
"donat-widget/internal/model/api"
|
"donat-widget/internal/model/api"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@ -810,6 +811,25 @@ func (donatService *ServiceDonat) UpdateAvatarStreamer(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (donatService *ServiceDonat) GetTextAfterDonatByOrder(
|
||||||
|
ctx context.Context,
|
||||||
|
orderID uuid.UUID,
|
||||||
|
) (string, error) {
|
||||||
|
donat, err := donatService.donatRepo.GetDonatByOrderID(ctx, orderID.String())
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if donat.Paid == nil {
|
||||||
|
return "", errors.New("not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
donatePage, err := donatService.donatRepo.GetDonatPage(ctx, donat.StreamerID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return donatePage.TextAfterDonat, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (donatService *ServiceDonat) replaceFilteredWords(text string, words []string) string {
|
func (donatService *ServiceDonat) replaceFilteredWords(text string, words []string) string {
|
||||||
if len(words) == 0 {
|
if len(words) == 0 {
|
||||||
return text
|
return text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user