update method getting steps, now we need pipeline id

This commit is contained in:
Pavel 2024-05-15 20:58:14 +03:00
parent 5399e75884
commit cbe5832fdc
5 changed files with 22 additions and 4 deletions

2
go.mod

@ -13,7 +13,7 @@ require (
github.com/twmb/franz-go v1.16.1 github.com/twmb/franz-go v1.16.1
go.uber.org/zap v1.27.0 go.uber.org/zap v1.27.0
google.golang.org/protobuf v1.33.0 google.golang.org/protobuf v1.33.0
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240510090920-72cb7d7da6e9 penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240515174948-7dbce6778f6d
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af
) )

2
go.sum

@ -171,5 +171,7 @@ penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240510090920-72cb7d7da6e9 h1:rEOS5bsCduPSYv5QNvU8YvXroTOeqeSNP/833ZvCUAA= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240510090920-72cb7d7da6e9 h1:rEOS5bsCduPSYv5QNvU8YvXroTOeqeSNP/833ZvCUAA=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240510090920-72cb7d7da6e9/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240510090920-72cb7d7da6e9/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240515174948-7dbce6778f6d h1:84N3i2HVvS0qzWTM/nNTAXKTzHfq+gUaMo9fLHiTTIw=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240515174948-7dbce6778f6d/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af h1:jQ7HaXSutDX5iepU7VRImxhikK7lV/lBKkiloOZ4Emo= penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af h1:jQ7HaXSutDX5iepU7VRImxhikK7lV/lBKkiloOZ4Emo=
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af/go.mod h1:5S5YwjSXWmnEKjBjG6MtyGtFmljjukDRS8CwHk/CF/I= penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af/go.mod h1:5S5YwjSXWmnEKjBjG6MtyGtFmljjukDRS8CwHk/CF/I=

@ -3,6 +3,7 @@ package controllers
import ( import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware"
"strconv"
) )
func (c *Controller) GetStepsWithPagination(ctx *fiber.Ctx) error { func (c *Controller) GetStepsWithPagination(ctx *fiber.Ctx) error {
@ -11,12 +12,22 @@ func (c *Controller) GetStepsWithPagination(ctx *fiber.Ctx) error {
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
} }
pipelineIDStr := ctx.Query("pipelineID")
if pipelineIDStr == "" {
return ctx.Status(fiber.StatusBadRequest).SendString("pipeline id is required")
}
pipelineID, err := strconv.Atoi(pipelineIDStr)
if err != nil {
return ctx.Status(fiber.StatusBadRequest).SendString("invalid pipeline id parameter")
}
req, err := extractParams(ctx) req, err := extractParams(ctx)
if err != nil { if err != nil {
return err return err
} }
response, err := c.service.GetStepsWithPagination(ctx.Context(), req, accountID) response, err := c.service.GetStepsWithPagination(ctx.Context(), req, accountID, pipelineID)
if err != nil { if err != nil {
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")

@ -7,8 +7,8 @@ import (
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
) )
func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListStepsResp, error) { func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string, pipelineID int) (*model.UserListStepsResp, error) {
response, err := s.repository.AmoRepo.GetStepsWithPagination(ctx, req, accountID) response, err := s.repository.AmoRepo.GetStepsWithPagination(ctx, req, accountID, int32(pipelineID))
if err != nil { if err != nil {
s.logger.Error("error getting steps with pagination", zap.Error(err)) s.logger.Error("error getting steps with pagination", zap.Error(err))
return nil, err return nil, err

@ -284,6 +284,10 @@ paths:
schema: schema:
type: object type: object
properties: properties:
pipelineID:
type: integer
description: id воронки которой принадлежат шаги
example: 123
page: page:
type: integer type: integer
description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. description: Номер страницы пагинации. Если не указан, используется значение по умолчанию.
@ -293,6 +297,7 @@ paths:
description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. description: Размер страницы пагинации. Если не указан, используется значение по умолчанию.
example: 25 example: 25
required: required:
- pipelineID
- page - page
- size - size
responses: responses: