51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal"
|
|
)
|
|
|
|
// Service is an entity for http requests handling
|
|
type Service struct {
|
|
dal *dal.DAL
|
|
}
|
|
|
|
func New(d *dal.DAL) *Service {
|
|
return &Service{dal: d}
|
|
}
|
|
|
|
// 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)
|
|
|
|
// 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)
|
|
|
|
// 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)
|
|
}
|