pagination methods update
This commit is contained in:
parent
6e73be47c2
commit
bb095a5942
2
go.mod
2
go.mod
@ -11,7 +11,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-20240421140110-96a89cd0b56a
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240421152238-836cb9fce7f1
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af
|
||||
)
|
||||
|
||||
|
4
go.sum
4
go.sum
@ -153,5 +153,9 @@ 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-20240421140110-96a89cd0b56a h1:b9QF4TYZbfQ9wDZL+LnKNk7VzLLLvfHp+m+DbA4gzCc=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240421140110-96a89cd0b56a/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240421152136-bba21decd33a h1:qP4qUVln7BXAYA8C983pa6a74arfbRJKbTGVHh+3zew=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240421152136-bba21decd33a/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240421152238-836cb9fce7f1 h1:jzhmhf7j+K6TVP5vY5/eHaA5405EqUsgfXDlHslDmBg=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240421152238-836cb9fce7f1/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=
|
||||
|
@ -5,13 +5,18 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware"
|
||||
)
|
||||
|
||||
func (c *Controller) GettingFieldsFromCash(ctx *fiber.Ctx) error {
|
||||
func (c *Controller) GetFieldsWithPagination(ctx *fiber.Ctx) error {
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
req, err := extractParams(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := c.service.GetFieldsWithPagination(ctx.Context(), req)
|
||||
response, err := c.service.GetFieldsWithPagination(ctx.Context(), req, accountID)
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
}
|
||||
|
@ -25,26 +25,26 @@ func NewController(deps Deps) *Controller {
|
||||
|
||||
func (c *Controller) Register(router fiber.Router) {
|
||||
router.Patch("/users", c.UpdateListUsers)
|
||||
router.Get("/users", c.GettingUserFromCash)
|
||||
router.Get("/users", c.GettingUserWithPagination)
|
||||
router.Delete("/utms/:quizID", c.DeletingUserUtm)
|
||||
router.Post("/utms/:quizID", c.SavingUserUtm)
|
||||
router.Get("/utms/:quizID", c.GettingUserUtm)
|
||||
router.Delete("/account", c.SoftDeleteAccount)
|
||||
router.Get("/account", c.GetCurrentAccount)
|
||||
router.Post("/account", c.ConnectAccount)
|
||||
router.Get("/steps", c.GettingStepsFromCash)
|
||||
router.Get("/steps", c.GetStepsWithPagination)
|
||||
router.Patch("/steps", c.UpdateListSteps)
|
||||
//todo поменять как было GET webhook/create
|
||||
router.Get("/", c.WebhookCreate)
|
||||
router.Get("/webhook/delete", c.WebhookDelete)
|
||||
router.Patch("/pipelines", c.UpdateListPipelines)
|
||||
router.Get("/pipelines", c.GettingPipelinesFromCash)
|
||||
router.Get("/pipelines", c.GetPipelinesWithPagination)
|
||||
router.Patch("/rules/:quizID", c.ChangeQuizSettings)
|
||||
router.Post("/rules/:quizID", c.SetQuizSettings)
|
||||
router.Get("/rules/:quizID", c.GettingQuizRules)
|
||||
router.Get("/tags", c.GettingTagsFromCash)
|
||||
router.Patch("/tags", c.UpdateListTags)
|
||||
router.Get("/fields", c.GettingFieldsFromCash)
|
||||
router.Get("/fields", c.GetFieldsWithPagination)
|
||||
router.Patch("/fields", c.UpdateListCustom)
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,18 @@ func (c *Controller) UpdateListPipelines(ctx *fiber.Ctx) error {
|
||||
return ctx.SendStatus(fiber.StatusOK)
|
||||
}
|
||||
|
||||
func (c *Controller) GettingPipelinesFromCash(ctx *fiber.Ctx) error {
|
||||
func (c *Controller) GetPipelinesWithPagination(ctx *fiber.Ctx) error {
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
req, err := extractParams(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := c.service.GetPipelinesWithPagination(ctx.Context(), req)
|
||||
response, err := c.service.GetPipelinesWithPagination(ctx.Context(), req, accountID)
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
}
|
||||
|
@ -5,13 +5,18 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware"
|
||||
)
|
||||
|
||||
func (c *Controller) GettingStepsFromCash(ctx *fiber.Ctx) error {
|
||||
func (c *Controller) GetStepsWithPagination(ctx *fiber.Ctx) error {
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
req, err := extractParams(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := c.service.GetStepsWithPagination(ctx.Context(), req)
|
||||
response, err := c.service.GetStepsWithPagination(ctx.Context(), req, accountID)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
|
@ -6,12 +6,17 @@ import (
|
||||
)
|
||||
|
||||
func (c *Controller) GettingTagsFromCash(ctx *fiber.Ctx) error {
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
req, err := extractParams(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := c.service.GetTagsWithPagination(ctx.Context(), req)
|
||||
response, err := c.service.GetTagsWithPagination(ctx.Context(), req, accountID)
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
}
|
||||
|
@ -24,13 +24,18 @@ func (c *Controller) UpdateListUsers(ctx *fiber.Ctx) error {
|
||||
return ctx.SendStatus(fiber.StatusOK)
|
||||
}
|
||||
|
||||
func (c *Controller) GettingUserFromCash(ctx *fiber.Ctx) error {
|
||||
func (c *Controller) GettingUserWithPagination(ctx *fiber.Ctx) error {
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
req, err := extractParams(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := c.service.GettingUserWithPagination(ctx.Context(), req)
|
||||
response, err := c.service.GettingUserWithPagination(ctx.Context(), req, accountID)
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func (c *Controller) DeletingUserUtm(ctx *fiber.Ctx) error {
|
||||
_, ok := middleware.GetAccountId(ctx)
|
||||
accountID, ok := middleware.GetAccountId(ctx)
|
||||
if !ok {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
@ -18,7 +18,7 @@ func (c *Controller) DeletingUserUtm(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request payload"})
|
||||
}
|
||||
|
||||
err := c.service.DeletingUserUtm(ctx.Context(), &request)
|
||||
err := c.service.DeletingUserUtm(ctx.Context(), &request, accountID)
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
)
|
||||
|
||||
func (s *Service) GetFieldsWithPagination(ctx context.Context, req *model.PaginationReq) (*model.UserListFieldsResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetFieldsWithPagination(ctx, req)
|
||||
func (s *Service) GetFieldsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListFieldsResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetFieldsWithPagination(ctx, req, accountID)
|
||||
if err != nil {
|
||||
s.logger.Error("error getting fields with pagination", zap.Error(err))
|
||||
return nil, err
|
||||
|
@ -22,8 +22,8 @@ func (s *Service) UpdateListPipelines(ctx context.Context, accountID string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) GetPipelinesWithPagination(ctx context.Context, req *model.PaginationReq) (*model.UserListPipelinesResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetPipelinesWithPagination(ctx, req)
|
||||
func (s *Service) GetPipelinesWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListPipelinesResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetPipelinesWithPagination(ctx, req, accountID)
|
||||
if err != nil {
|
||||
s.logger.Error("error getting pipelines with pagination", zap.Error(err))
|
||||
return nil, err
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
)
|
||||
|
||||
func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq) (*model.UserListStepsResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetStepsWithPagination(ctx, req)
|
||||
func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListStepsResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetStepsWithPagination(ctx, req, accountID)
|
||||
if err != nil {
|
||||
s.logger.Error("error getting steps with pagination", zap.Error(err))
|
||||
return nil, err
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
)
|
||||
|
||||
func (s *Service) GetTagsWithPagination(ctx context.Context, req *model.PaginationReq) (*model.UserListTagsResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetTagsWithPagination(ctx, req)
|
||||
func (s *Service) GetTagsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListTagsResp, error) {
|
||||
response, err := s.repository.AmoRepo.GetTagsWithPagination(ctx, req, accountID)
|
||||
if err != nil {
|
||||
s.logger.Error("error getting tags with pagination", zap.Error(err))
|
||||
return nil, err
|
||||
|
@ -22,8 +22,8 @@ func (s *Service) UpdateListUsers(ctx context.Context, accountID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) GettingUserWithPagination(ctx context.Context, req *model.PaginationReq) (*model.UserListResp, error) {
|
||||
response, err := s.repository.AmoRepo.GettingUserWithPagination(ctx, req)
|
||||
func (s *Service) GettingUserWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListResp, error) {
|
||||
response, err := s.repository.AmoRepo.GettingUserWithPagination(ctx, req, accountID)
|
||||
if err != nil {
|
||||
s.logger.Error("error getting users with pagination", zap.Error(err))
|
||||
return nil, err
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
)
|
||||
|
||||
func (s *Service) DeletingUserUtm(ctx context.Context, request *model.ListDeleteUTMIDsReq) error {
|
||||
err := s.repository.AmoRepo.DeletingUserUtm(ctx, request)
|
||||
func (s *Service) DeletingUserUtm(ctx context.Context, request *model.ListDeleteUTMIDsReq, accountID string) error {
|
||||
err := s.repository.AmoRepo.DeletingUserUtm(ctx, request, accountID)
|
||||
if err != nil {
|
||||
s.logger.Error("error deleting user utm", zap.Error(err))
|
||||
return err
|
||||
|
@ -158,7 +158,7 @@ func gettingUserFromCash(ctx context.Context, t *testing.T, repo *dal.AmoDal) er
|
||||
Size: int32(i),
|
||||
}
|
||||
|
||||
resp, err := repo.AmoRepo.GettingUserWithPagination(ctx, &req)
|
||||
resp, err := repo.AmoRepo.GettingUserWithPagination(ctx, &req, "5")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -206,7 +206,7 @@ func gettingPipelinesFromCash(ctx context.Context, t *testing.T, repo *dal.AmoDa
|
||||
Size: int32(i),
|
||||
}
|
||||
|
||||
resp, err := repo.AmoRepo.GetPipelinesWithPagination(ctx, &req)
|
||||
resp, err := repo.AmoRepo.GetPipelinesWithPagination(ctx, &req, "4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -254,7 +254,7 @@ func gettingStepsFromCash(ctx context.Context, t *testing.T, repo *dal.AmoDal) e
|
||||
Size: int32(i),
|
||||
}
|
||||
|
||||
resp, err := repo.AmoRepo.GetStepsWithPagination(ctx, &req)
|
||||
resp, err := repo.AmoRepo.GetStepsWithPagination(ctx, &req, "3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -366,7 +366,7 @@ func gettingTagsFromCash(ctx context.Context, t *testing.T, repo *dal.AmoDal) er
|
||||
Size: int32(i),
|
||||
}
|
||||
|
||||
resp, err := repo.AmoRepo.GetTagsWithPagination(ctx, &req)
|
||||
resp, err := repo.AmoRepo.GetTagsWithPagination(ctx, &req, "2")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -480,7 +480,7 @@ func gettingFieldsFromCash(ctx context.Context, t *testing.T, repo *dal.AmoDal)
|
||||
Size: int32(i),
|
||||
}
|
||||
|
||||
resp, err := repo.AmoRepo.GetFieldsWithPagination(ctx, &req)
|
||||
resp, err := repo.AmoRepo.GetFieldsWithPagination(ctx, &req, "1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user