package education_history

import (
	"campaign-pool-be/app/module/education_history/controller"
	"campaign-pool-be/app/module/education_history/repository"
	"campaign-pool-be/app/module/education_history/service"

	"github.com/gofiber/fiber/v2"
	"go.uber.org/fx"
)

// struct of EducationHistoryRouter
type EducationHistoryRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

// register bulky of EducationHistory module
var NewEducationHistoryModule = fx.Options(
	// register repository of EducationHistory module
	fx.Provide(repository.NewEducationHistoryRepository),

	// register service of EducationHistory module
	fx.Provide(service.NewEducationHistoryService),

	// register controller of EducationHistory module
	fx.Provide(controller.NewController),

	// register router of EducationHistory module
	fx.Provide(NewEducationHistoryRouter),
)

// init EducationHistoryRouter
func NewEducationHistoryRouter(fiber *fiber.App, controller *controller.Controller) *EducationHistoryRouter {
	return &EducationHistoryRouter{
		App:        fiber,
		Controller: controller,
	}
}

// register routes of EducationHistory module
func (_i *EducationHistoryRouter) RegisterEducationHistoryRoutes() {
	// define controllers
	educationHistoryController := _i.Controller.EducationHistory

	// define routes
	_i.App.Route("/education-history", func(router fiber.Router) {
		router.Get("/", educationHistoryController.All)
		router.Get("/:id", educationHistoryController.Show)
		router.Post("/", educationHistoryController.Save)
		router.Put("/:id", educationHistoryController.Update)
		router.Delete("/:id", educationHistoryController.Delete)
		router.Post("/:id/certificate", educationHistoryController.UploadCertificate)
	})
}
