package hero_content

import (
	"web-qudo-be/app/module/hero_contents/controller"
	"web-qudo-be/app/module/hero_contents/repository"
	"web-qudo-be/app/module/hero_contents/service"

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

type HeroContentsRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

var NewHeroContentsModule = fx.Options(
	// repository
	fx.Provide(repository.NewHeroContentsRepository),

	// service
	fx.Provide(service.NewHeroContentsService),

	// controller
	fx.Provide(controller.NewController),

	// router
	fx.Provide(NewHeroContentsRouter),
)

// init router
func NewHeroContentsRouter(fiber *fiber.App, controller *controller.Controller) *HeroContentsRouter {
	return &HeroContentsRouter{
		App:        fiber,
		Controller: controller,
	}
}

func (_i *HeroContentsRouter) RegisterHeroContentsRoutes() {
	heroController := _i.Controller.HeroContent

	_i.App.Route("/hero-contents", func(router fiber.Router) {
		router.Get("/", heroController.Show)
		router.Post("/", heroController.Save)
		router.Put("/:id", heroController.Update)
		router.Delete("/:id", heroController.Delete)
	})
}