/
gnomdeployer
/
VUZPlus
Обзор
Документация
Войти
/
gnomdeployer
/
VUZPlus
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
server/internal/api/handler/handler.go
141 строка
5 KB
maximmalchevsky
ura
20 май 2025, 02:58
20 май 2025, 02:58
e733017
Код
Авторство
О чём код?
package handler import ( _ "vuzplus/docs" "vuzplus/internal/shared/config" "vuzplus/internal/shared/log" "vuzplus/internal/shared/repository" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" "github.com/rs/zerolog" fiberSwagger "github.com/swaggo/fiber-swagger" ) type Handler struct { repository *repository.Repository logger *zerolog.Logger conf *config.Config } func NewHandler(repository *repository.Repository, logger *zerolog.Logger, conf *config.Config) *Handler { return &Handler{repository: repository, logger: logger, conf: conf} } func (h *Handler) Router() *fiber.App { f := fiber.New(fiber.Config{ CaseSensitive: true, StrictRouting: true, }) f.Use(cors.New(cors.Config{ AllowOrigins: "*", //AllowCredentials: true, AllowHeaders: "Origin, Content-Type, Accept, Authorization", AllowMethods: "GET, HEAD, PUT, PATCH, POST, DELETE", })) f.Use(log.RequestLogger(h.logger)) f.Get("/swagger/*", fiberSwagger.WrapHandler) f.Get("/health", func(c *fiber.Ctx) error { return c.Status(fiber.StatusOK).SendString("healthy") }) f.Post("/sign-up", h.SignUp) f.Post("/sign-up/delegate", h.SignUpDelegate) f.Post("/login", h.Login) f.Get("/university", h.GetAllUniversities) f.Get("/university/id/:id", h.GetByIDUniversity) f.Get("/university/names", h.GetAllUniversitiesNames) f.Get("/program/id/:id", h.GetByIDProgram) f.Get("/program/university_id/:id", h.GetByProgramsByUniversityID) f.Get("/program/exchangeable/university_id/:id", h.GetByUniversityIDExchangeablePrograms) f.Get("/program", h.GetPrograms) f.Get("/program/exchangeable/all", h.GetExchangeablePrograms) f.Get("/discipline/program_id/:id", h.GetByProgramIDDisciplines) f.Get("/review/program_id/:id", h.GetByProgramIDReviews) f.Get("/questions/answers/program_id/:id", h.GetQuestionAndAnswersByProgramID) f.Post("/forms", h.CreateForm) authGroup := f.Group("/auth") authGroup.Use(func(c *fiber.Ctx) error { return h.WithJWTAuth(c) }) authGroup.Post("/university", h.CreateUniversity) authGroup.Put("/university", h.UpdateUniversity) authGroup.Delete("/university/:id", h.DeleteUniversity) authGroup.Post("/admin", h.CreateAdmin) authGroup.Get("/delegates/registrations", h.GetDelegatesRegistrations) authGroup.Put("/users/status", h.ChangeUserStatus) authGroup.Get("/students/registrations", h.GetStudentsRegistrations) authGroup.Get("/students", h.GetStudentsByUniversityID) authGroup.Get("/profile", h.GetProfileInfo) authGroup.Put("/profile", h.UpdateProfileInfo) authGroup.Put("/profile/password", h.UpdatePassword) authGroup.Post("/profile/telegram/connect", h.ConnectTelegram) authGroup.Post("/program", h.CreateProgram) //authGroup.Put("/direction", h.UpdateDirection) //authGroup.Delete("/direction/:id", h.DeleteDirection) authGroup.Get("/program/exchangeable/available", h.GetAvailableExchangeablePrograms) authGroup.Get("/program/participation", h.CheckUserParticipation) authGroup.Post("/discipline", h.CreateDiscipline) authGroup.Put("/discipline", h.UpdateDiscipline) authGroup.Delete("/discipline/:id", h.DeleteDiscipline) authGroup.Post("/review", h.CreateReview) authGroup.Put("/review", h.UpdateReview) authGroup.Delete("/review/:id", h.DeleteReview) authGroup.Post("/question", h.CreateQuestion) authGroup.Delete("/question/:id", h.DeleteQuestion) authGroup.Post("/answer", h.CreateAnswer) authGroup.Delete("/answer/:id", h.DeleteAnswer) authGroup.Get("/quota/program_id/:id", h.GetByProgramIDQuota) authGroup.Post("/quota", h.CreateQuota) authGroup.Put("/quota", h.UpdateQuota) authGroup.Delete("/quota/:id", h.DeleteQuota) authGroup.Post("/tasks", h.CreateTestTask) authGroup.Get("/tasks", h.GetTestTask) authGroup.Delete("/tasks", h.DeleteTestTask) authGroup.Put("/tasks", h.UpdateTestTask) authGroup.Post("tasks/solution", h.UploadTaskSolution) authGroup.Delete("tasks/solution", h.DeleteTaskSolution) authGroup.Get("/tasks/solution", h.GetStudentSolution) authGroup.Get("/tasks/solution/my", h.GetMySolution) authGroup.Put("/tasks/solution", h.UpdateTaskSolution) authGroup.Put("/tasks/solution/status", h.UpdateSolutionStatus) authGroup.Post("/application/student", h.CreateStudentProgramApplication) authGroup.Post("/application/delegate", h.CreateByDelegateProgramApplication) authGroup.Get("/application/outgoing/student", h.GetStudentOutgoingApplications) authGroup.Get("/application/ingoing/student", h.GetStudentIngoingApplications) authGroup.Get("/application/ingoing/university", h.GetUniversityIngoingApplications) authGroup.Get("/application/outgoing/university", h.GetUniversityOutgoingApplications) authGroup.Post("/application/documents", h.UploadStudentDocuments) authGroup.Put("/application/status", h.UpdateApplicationStatus) authGroup.Get("/analytics/semester/averages/:id", h.GetSemesterAveragesDirection) authGroup.Get("/analytics/semester/averages/university/:id", h.GetSemesterAveragesUniversity) authGroup.Get("/analytics/university/json", h.GetUniversityAnalyticsJSON) authGroup.Get("/analytics/university/file/:ext", h.GetUniversityAnalyticsFile) authGroup.Get("/forms", h.GetForms) return f }