diff --git a/go.mod b/go.mod index 28f4dd2..e6251fe 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/twmb/franz-go v1.16.1 go.uber.org/zap v1.27.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 ) diff --git a/go.sum b/go.sum index 3f250df..558a6de 100644 --- a/go.sum +++ b/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/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-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/go.mod h1:5S5YwjSXWmnEKjBjG6MtyGtFmljjukDRS8CwHk/CF/I= diff --git a/internal/controllers/steps.go b/internal/controllers/steps.go index c0fd68c..3010f5a 100644 --- a/internal/controllers/steps.go +++ b/internal/controllers/steps.go @@ -3,6 +3,7 @@ package controllers import ( "github.com/gofiber/fiber/v2" "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" + "strconv" ) 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") } + 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) if err != nil { return err } - response, err := c.service.GetStepsWithPagination(ctx.Context(), req, accountID) + response, err := c.service.GetStepsWithPagination(ctx.Context(), req, accountID, pipelineID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") diff --git a/internal/service/steps.go b/internal/service/steps.go index 48579da..3840ea9 100644 --- a/internal/service/steps.go +++ b/internal/service/steps.go @@ -7,8 +7,8 @@ import ( "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" ) -func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListStepsResp, error) { - response, err := s.repository.AmoRepo.GetStepsWithPagination(ctx, req, accountID) +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, int32(pipelineID)) if err != nil { s.logger.Error("error getting steps with pagination", zap.Error(err)) return nil, err diff --git a/openapi.yaml b/openapi.yaml index 7a317b4..97575fa 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -284,6 +284,10 @@ paths: schema: type: object properties: + pipelineID: + type: integer + description: id воронки которой принадлежат шаги + example: 123 page: type: integer description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. @@ -293,6 +297,7 @@ paths: description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. example: 25 required: + - pipelineID - page - size responses: