This commit is contained in:
mm 2024-10-21 13:40:48 +05:00
parent 13f296a1b2
commit a6fbd1580f
2 changed files with 6 additions and 7 deletions

View File

@ -2,7 +2,6 @@ FROM golang:1.23-alpine
WORKDIR /root WORKDIR /root
COPY . . COPY . .
RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN go mod tidy && swag init -g cmd/main.go -o api/http RUN go mod tidy && swag init -g cmd/main.go -o api/http
CMD go run cmd/main.go CMD go run cmd/main.go

View File

@ -8,14 +8,14 @@ import (
) )
func CreateTarget(targetService model.TargetService) echo.HandlerFunc { func CreateTarget(targetService model.TargetService) echo.HandlerFunc {
type Body struct { type CreateTargetBody struct {
StreamerID model.StreamerID `json:"streamer_id"` StreamerID model.StreamerID `json:"streamer_id"`
Amount model.DonatAmount `json:"amount"` Amount model.DonatAmount `json:"amount"`
Text string `json:"text"` Text string `json:"text"`
} }
return func(request echo.Context) error { return func(request echo.Context) error {
ctx := context.Background() ctx := context.Background()
var body Body var body CreateTargetBody
if err := request.Bind(&body); err != nil { if err := request.Bind(&body); err != nil {
return echo.NewHTTPError(400, err.Error()) return echo.NewHTTPError(400, err.Error())
} }
@ -33,12 +33,12 @@ func CreateTarget(targetService model.TargetService) echo.HandlerFunc {
} }
func GetAllTarget(targetService model.TargetService) echo.HandlerFunc { func GetAllTarget(targetService model.TargetService) echo.HandlerFunc {
type Body struct { type GetAllTargetBody struct {
StreamerID model.StreamerID `json:"streamer_id"` StreamerID model.StreamerID `json:"streamer_id"`
} }
return func(request echo.Context) error { return func(request echo.Context) error {
ctx := context.Background() ctx := context.Background()
var body Body var body GetAllTargetBody
if err := request.Bind(&body); err != nil { if err := request.Bind(&body); err != nil {
return echo.NewHTTPError(400, err.Error()) return echo.NewHTTPError(400, err.Error())
} }
@ -60,12 +60,12 @@ func AddAmountTarget(
targetService model.TargetService, targetService model.TargetService,
donatService model.DonatService, donatService model.DonatService,
) echo.HandlerFunc { ) echo.HandlerFunc {
type Body struct { type AddAmountTargetBody struct {
OrderID model.OrderID `json:"order_id"` OrderID model.OrderID `json:"order_id"`
} }
return func(request echo.Context) error { return func(request echo.Context) error {
ctx := context.Background() ctx := context.Background()
var body Body var body AddAmountTargetBody
if err := request.Bind(&body); err != nil { if err := request.Bind(&body); err != nil {
return echo.NewHTTPError(400, err.Error()) return echo.NewHTTPError(400, err.Error())
} }