package research_journals

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

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

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

// register bulky of ResearchJournals module
var NewResearchJournalsModule = fx.Options(
	// register repository of ResearchJournals module
	fx.Provide(repository.NewResearchJournalsRepository),

	// register service of ResearchJournals module
	fx.Provide(service.NewResearchJournalsService),

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

	// register router of ResearchJournals module
	fx.Provide(NewResearchJournalsRouter),
)

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

// register routes of ResearchJournals module
func (_i *ResearchJournalsRouter) RegisterResearchJournalsRoutes() {
	// define controllers
	researchJournalsController := _i.Controller.ResearchJournals

	// define routes
	_i.App.Route("/research-journals", func(router fiber.Router) {
		router.Get("/", researchJournalsController.All)
		router.Get("/:id", researchJournalsController.Show)
		router.Post("/", researchJournalsController.Save)
		router.Put("/:id", researchJournalsController.Update)
		router.Delete("/:id", researchJournalsController.Delete)
	})
}
