package master_menus

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

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

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

// register bulky of MasterMenus module
var NewMasterMenusModule = fx.Options(
	// register repository of MasterMenus module
	fx.Provide(repository.NewMasterMenusRepository),

	// register service of MasterMenus module
	fx.Provide(service.NewMasterMenusService),

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

	// register router of MasterMenus module
	fx.Provide(NewMasterMenusRouter),
)

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

// register routes of MasterMenus module
func (_i *MasterMenusRouter) RegisterMasterMenusRoutes() {
	// define controllers
	masterMenusController := _i.Controller.MasterMenus

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