42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package controllers
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware"
|
|
)
|
|
|
|
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, accountID)
|
|
|
|
if err != nil {
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
}
|
|
return ctx.Status(fiber.StatusOK).JSON(response)
|
|
}
|
|
|
|
func (c *Controller) UpdateListSteps(ctx *fiber.Ctx) error {
|
|
accountID, ok := middleware.GetAccountId(ctx)
|
|
if !ok {
|
|
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
|
}
|
|
|
|
//accountID := "64f2cd7a7047f28fdabf6d9e"
|
|
|
|
err := c.service.UpdateListSteps(ctx.Context(), accountID)
|
|
|
|
if err != nil {
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
}
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
}
|