2024-04-04 09:42:40 +00:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
2024-04-08 08:20:10 +00:00
|
|
|
"amocrm/internal/models"
|
2024-04-04 09:42:40 +00:00
|
|
|
"amocrm/internal/service"
|
|
|
|
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DifferentController struct {
|
|
|
|
DifferentService *service.DifferentService
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDifferentController(service *service.DifferentService) *DifferentController {
|
|
|
|
return &DifferentController{
|
|
|
|
DifferentService: service,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Register(router fiber.Router) {
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Get("/steps", c.Gettingstepsfromcash)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Patch("/steps", c.Updateliststeps)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
router.Get("/webhook/create", c.Webhookcreate)
|
|
|
|
|
|
|
|
router.Get("/webhook/delete", c.Webhookdelete)
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Patch("/pipelines", c.Updatelistpipelines)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Get("/pipelines", c.Gettingpipelinesfromcash)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Patch("/rules", c.Changequizsettings)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Post("/rules", c.Setquizsettings)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Get("/rules/{quizID}", c.Gettingquizrules)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
router.Get("/tags", c.Gettingtagsfromcash)
|
|
|
|
|
|
|
|
router.Patch("/tags", c.Updatelisttags)
|
|
|
|
|
|
|
|
router.Get("/fields", c.Gettingfieldsfromcash)
|
|
|
|
|
|
|
|
router.Patch("/fields", c.Updatelistcustom)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Name() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Gettingstepsfromcash(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Gettingstepsfromcash
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
response, err := c.DifferentService.Gettingstepsfromcash(ctx.Context())
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
2024-04-08 08:20:10 +00:00
|
|
|
return ctx.Status(fiber.StatusOK).JSON(response)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Updateliststeps(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Updateliststeps
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
err := c.DifferentService.Updateliststeps(ctx.Context())
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Webhookcreate(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Webhookcreate
|
|
|
|
|
|
|
|
err := c.DifferentService.Webhookcreate(ctx.Context())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Webhookdelete(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Webhookdelete
|
|
|
|
|
|
|
|
err := c.DifferentService.Webhookdelete(ctx.Context())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Updatelistpipelines(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Updatelistpipelines
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
err := c.DifferentService.Updatelistpipelines(ctx.Context())
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Gettingpipelinesfromcash(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Gettingpipelinesfromcash
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
response, err := c.DifferentService.Gettingpipelinesfromcash(ctx.Context())
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
2024-04-08 08:20:10 +00:00
|
|
|
return ctx.Status(fiber.StatusOK).JSON(response)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Changequizsettings(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Changequizsettings
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
var request models.RulesReq
|
|
|
|
if err := ctx.BodyParser(&request); err != nil {
|
|
|
|
return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request payload"})
|
|
|
|
}
|
|
|
|
|
|
|
|
err := c.DifferentService.Changequizsettings(ctx.Context(), &request)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Setquizsettings(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Setquizsettings
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
var request models.RulesReq
|
|
|
|
if err := ctx.BodyParser(&request); err != nil {
|
|
|
|
return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request payload"})
|
|
|
|
}
|
|
|
|
|
|
|
|
err := c.DifferentService.Setquizsettings(ctx.Context(), &request)
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Gettingquizrules(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Gettingquizrules
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
response, err := c.DifferentService.Gettingquizrules(ctx.Context())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.Status(fiber.StatusOK).JSON(response)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Gettingtagsfromcash(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Gettingtagsfromcash
|
|
|
|
|
|
|
|
response, err := c.DifferentService.Gettingtagsfromcash(ctx.Context())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.Status(fiber.StatusOK).JSON(response)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Updatelisttags(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Updatelisttags
|
|
|
|
|
|
|
|
err := c.DifferentService.Updatelisttags(ctx.Context())
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
func (c *DifferentController) Gettingfieldsfromcash(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Gettingfieldsfromcash
|
2024-04-04 09:42:40 +00:00
|
|
|
|
2024-04-08 08:20:10 +00:00
|
|
|
response, err := c.DifferentService.Gettingfieldsfromcash(ctx.Context())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.Status(fiber.StatusOK).JSON(response)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DifferentController) Updatelistcustom(ctx *fiber.Ctx) error {
|
|
|
|
// Обработчик для метода Updatelistcustom
|
|
|
|
|
|
|
|
err := c.DifferentService.Updatelistcustom(ctx.Context())
|
2024-04-04 09:42:40 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
|
|
|
}
|
|
|
|
return ctx.SendStatus(fiber.StatusOK)
|
|
|
|
|
|
|
|
}
|