package service import ( "github.com/gofiber/fiber/v2" "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" "penahub.gitlab.yandexcloud.net/backend/quiz/core.git/brokers" "penahub.gitlab.yandexcloud.net/backend/quiz/core.git/clients/auth" ) // Service is an entity for http requests handling type Service struct { dal *dal.DAL authClient *auth.AuthClient producer *brokers.Producer serviceName string } type Deps struct { Dal *dal.DAL AuthClient *auth.AuthClient Producer *brokers.Producer ServiceName string } func New(deps Deps) *Service { return &Service{ dal: deps.Dal, authClient: deps.AuthClient, producer: deps.Producer, serviceName: deps.ServiceName, } } // Register is a function for add handlers of service to external multiplexer func (s *Service) Register(app *fiber.App) { // quiz manipulating handlers app.Post("/quiz/create", s.CreateQuiz) app.Post("/quiz/getList", s.GetQuizList) app.Patch("/quiz/edit", s.UpdateQuiz) app.Post("/quiz/copy", s.CopyQuiz) app.Post("/quiz/history", s.GetQuizHistory) app.Delete("/quiz/delete", s.DeleteQuiz) app.Patch("/quiz/archive", s.ArchiveQuiz) app.Post("/quiz/move", s.QuizMove) app.Post("/quiz/template", s.TemplateCopy) // question manipulating handlers app.Post("/question/create", s.CreateQuestion) app.Post("/question/getList", s.GetQuestionList) app.Patch("/question/edit", s.UpdateQuestion) app.Post("/question/copy", s.CopyQuestion) app.Post("/question/history", s.GetQuestionHistory) app.Delete("/question/delete", s.DeleteQuestion) // account handlers app.Get("/account/get", s.getCurrentAccount) app.Post("/account/create", s.createAccount) app.Delete("/account/delete", s.deleteAccount) app.Get("/accounts", s.getAccounts) app.Get("/privilege/:userId", s.getPrivilegeByUserID) app.Delete("/account/:userId", s.deleteAccountByUserID) app.Post("/account/manualdone", s.ManualDone) // result handlers app.Post("/results/getResults/:quizId", s.GetResultsByQuizID) app.Delete("/results/delete/:resultId", s.DelResultByID) app.Patch("/result/seen", s.SetStatus) app.Post("/results/:quizID/export", s.ExportResultsToCSV) app.Get("/result/:resultID", s.GetResultAnswers) // statistics handlers app.Post("/statistic/:quizID/devices", s.GetDeviceStatistics) app.Post("/statistic/:quizID/general", s.GetGeneralStatistics) app.Post("/statistic/:quizID/questions", s.GetQuestionsStatistics) app.Post("/statistic", s.AllServiceStatistics) }